freddyaboulton HF staff commited on
Commit
1535831
·
1 Parent(s): f8727f7
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -9,7 +9,11 @@ model = YOLOv10.from_pretrained(f'jameslahm/yolov10s')
9
  @spaces.GPU
10
  def yolov10_inference(image, conf_threshold):
11
  width, _ = image.size
 
 
12
  results = model.predict(source=image, imgsz=width, conf=conf_threshold)
 
 
13
  annotated_image = results[0].plot()
14
  return annotated_image[:, :, ::-1]
15
 
@@ -18,7 +22,7 @@ def app():
18
  with gr.Blocks():
19
  with gr.Row():
20
  with gr.Column():
21
- image = gr.Image(type="pil", label="Image", visible=True)
22
  conf_threshold = gr.Slider(
23
  label="Confidence Threshold",
24
  minimum=0.0,
@@ -26,10 +30,6 @@ def app():
26
  step=0.05,
27
  value=0.25,
28
  )
29
-
30
- with gr.Column():
31
- output_image = gr.Image(type="numpy", label="Annotated Image", visible=True)
32
-
33
  image.stream(
34
  fn=yolov10_inference,
35
  inputs=[image, conf_threshold],
 
9
  @spaces.GPU
10
  def yolov10_inference(image, conf_threshold):
11
  width, _ = image.size
12
+ import time
13
+ start = time.time()
14
  results = model.predict(source=image, imgsz=width, conf=conf_threshold)
15
+ end = time.time()
16
+ print("time", end - start)
17
  annotated_image = results[0].plot()
18
  return annotated_image[:, :, ::-1]
19
 
 
22
  with gr.Blocks():
23
  with gr.Row():
24
  with gr.Column():
25
+ image = gr.Image(type="pil", label="Image", visible=True, sources="webcam", height=500, width=500)
26
  conf_threshold = gr.Slider(
27
  label="Confidence Threshold",
28
  minimum=0.0,
 
30
  step=0.05,
31
  value=0.25,
32
  )
 
 
 
 
33
  image.stream(
34
  fn=yolov10_inference,
35
  inputs=[image, conf_threshold],