atalaydenknalbant commited on
Commit
8918054
·
verified ·
1 Parent(s): 7065ee0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -11
app.py CHANGED
@@ -1,26 +1,18 @@
1
  import gradio as gr
2
- import spaces
3
  import supervision as sv
4
  import PIL.Image as Image
5
  from ultralytics import YOLO, YOLOv10
6
  from huggingface_hub import hf_hub_download
7
 
8
-
9
  def download_models(model_id):
10
  hf_hub_download("atalaydenknalbant/asl-models", filename=f"{model_id}", local_dir=f"./")
11
  return f"./{model_id}"
12
 
13
-
14
-
15
  box_annotator = sv.BoxAnnotator()
16
  category_dict = {0: 'A', 1: 'B', 2: 'C', 3: 'D', 4: 'E', 5: 'F', 6: 'G', 7: 'H', 8: 'I',
17
  9: 'J', 10: 'K', 11: 'L', 12: 'M', 13: 'N', 14: 'O', 15: 'P', 16: 'Q',
18
  17: 'R', 18: 'S', 19: 'T', 20: 'U', 21: 'V', 22: 'W', 23: 'X', 24: 'Y', 25: 'Z'}
19
 
20
-
21
-
22
-
23
- @spaces.GPU(duration=200)
24
  def yolo_inference(image, model_id, conf_threshold, iou_threshold):
25
  model_path = download_models(model_id)
26
  if model_id[:7] == 'yolov10':
@@ -42,7 +34,7 @@ def app():
42
  with gr.Blocks():
43
  with gr.Row():
44
  with gr.Column():
45
- image = gr.Image(type="pil", label="Image")
46
 
47
  model_id = gr.Dropdown(
48
  label="Model",
@@ -71,7 +63,7 @@ def app():
71
  yolov10_infer = gr.Button(value="Detect Objects")
72
 
73
  with gr.Column():
74
- output_image = gr.Image(type="pil", label="Annotated Image")
75
 
76
  yolov10_infer.click(
77
  fn=yolo_inference,
@@ -116,4 +108,4 @@ with gradio_app:
116
  with gr.Column():
117
  app()
118
 
119
- gradio_app.launch(debug=True)
 
1
  import gradio as gr
 
2
  import supervision as sv
3
  import PIL.Image as Image
4
  from ultralytics import YOLO, YOLOv10
5
  from huggingface_hub import hf_hub_download
6
 
 
7
  def download_models(model_id):
8
  hf_hub_download("atalaydenknalbant/asl-models", filename=f"{model_id}", local_dir=f"./")
9
  return f"./{model_id}"
10
 
 
 
11
  box_annotator = sv.BoxAnnotator()
12
  category_dict = {0: 'A', 1: 'B', 2: 'C', 3: 'D', 4: 'E', 5: 'F', 6: 'G', 7: 'H', 8: 'I',
13
  9: 'J', 10: 'K', 11: 'L', 12: 'M', 13: 'N', 14: 'O', 15: 'P', 16: 'Q',
14
  17: 'R', 18: 'S', 19: 'T', 20: 'U', 21: 'V', 22: 'W', 23: 'X', 24: 'Y', 25: 'Z'}
15
 
 
 
 
 
16
  def yolo_inference(image, model_id, conf_threshold, iou_threshold):
17
  model_path = download_models(model_id)
18
  if model_id[:7] == 'yolov10':
 
34
  with gr.Blocks():
35
  with gr.Row():
36
  with gr.Column():
37
+ image = gr.Image(type="pil", label="Image", tool="editor")
38
 
39
  model_id = gr.Dropdown(
40
  label="Model",
 
63
  yolov10_infer = gr.Button(value="Detect Objects")
64
 
65
  with gr.Column():
66
+ output_image = gr.Image(type="pil", label="Annotated Image", interactive=False)
67
 
68
  yolov10_infer.click(
69
  fn=yolo_inference,
 
108
  with gr.Column():
109
  app()
110
 
111
+ gradio_app.launch(debug=True)