mnauf commited on
Commit
9c982cf
1 Parent(s): 7fcc746

Added examples

Browse files
Files changed (2) hide show
  1. app.py +11 -0
  2. sample_solution.py +0 -6
app.py CHANGED
@@ -1,3 +1,5 @@
 
 
1
  import gradio as gr
2
  from sample_solution import main as detect_bees
3
 
@@ -27,6 +29,15 @@ with gr.Blocks() as block:
27
 
28
  btn = gr.Button(value="Count the number of Bees")
29
  btn.click(detect_bees, inputs=[file_input], outputs=[file_output], queue=True)
 
 
 
 
 
 
 
 
 
30
 
31
  block.queue(concurrency_count=5).launch()
32
  # block.queue().launch()
 
1
+ import os
2
+
3
  import gradio as gr
4
  from sample_solution import main as detect_bees
5
 
 
29
 
30
  btn = gr.Button(value="Count the number of Bees")
31
  btn.click(detect_bees, inputs=[file_input], outputs=[file_output], queue=True)
32
+ examples_dir = os.listdir(os.path.join(os.path.dirname(__file__), "examples"))
33
+ print(examples_dir)
34
+ gr.Examples(
35
+ examples=[os.path.join(os.path.dirname(__file__), "examples", example_img) for example_img in examples_dir],
36
+ inputs=file_input,
37
+ outputs=file_output,
38
+ fn=detect_bees,
39
+ cache_examples=True,
40
+ )
41
 
42
  block.queue(concurrency_count=5).launch()
43
  # block.queue().launch()
sample_solution.py CHANGED
@@ -260,12 +260,6 @@ def predict_bees(opt):
260
 
261
 
262
  def main(image):
263
- # print(image)
264
- # print(image.shape)
265
- # print()
266
- # cv2.imshow("sdfsd", image)
267
- print("List of files: ", os.listdir("./"))
268
- print("Model exists?: ", "custom_model.pt" in os.listdir("./"))
269
  image_path = os.path.join("images", str(time.time()) + ".jpg")
270
  image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
271
  cv2.imwrite(image_path, image)
 
260
 
261
 
262
  def main(image):
 
 
 
 
 
 
263
  image_path = os.path.join("images", str(time.time()) + ".jpg")
264
  image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
265
  cv2.imwrite(image_path, image)