xiang-wuu commited on
Commit
d3ca638
1 Parent(s): c55ea97

main app file updated to relocate detect and classify methods to seperate modules

Browse files
Files changed (1) hide show
  1. app.py +6 -26
app.py CHANGED
@@ -1,30 +1,10 @@
1
- import os
2
  import gradio as gr
3
- import numpy as np
4
- import supervision as sv
5
- from ultralytics import YOLO
6
-
7
-
8
- os.system("wget https://media.roboflow.com/notebooks/examples/dog.jpeg")
9
- os.system("wget https://media.roboflow.com/notebooks/examples/dog-2.jpeg")
10
-
11
-
12
- def detect(image, weights):
13
- model = YOLO(weights + '.pt')
14
- result = model(image, verbose=False)[0]
15
- detections = sv.Detections.from_ultralytics(result)
16
- box_annotator = sv.BoxAnnotator()
17
- annotated_image = box_annotator.annotate(image.copy(), detections=detections)
18
-
19
- return annotated_image
20
 
21
 
22
  if __name__ == '__main__':
23
- gr.Interface(
24
- detect, [gr.Image(type="numpy"), gr.Dropdown(choices=["yolov5s", "yolov8s"])],
25
- gr.Image(type="numpy"),
26
- title="supervision",
27
- examples=[["dog.jpeg", "yolov5s"], ["dog-2.jpeg", "yolov8s"]],
28
- description=
29
- "Gradio based demo for <a href='https://github.com/roboflow/supervision' style='text-decoration: underline' target='_blank'>roboflow/supervision</a>, We write your reusable computer vision tools."
30
- ).launch()
 
 
1
  import gradio as gr
2
+ from classify_utils import classify_tab
3
+ from detect_utils import detect_tab
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
 
5
 
6
  if __name__ == '__main__':
7
+ gr.TabbedInterface(
8
+ [detect_tab, classify_tab],
9
+ tab_names=['Image Detection', 'Image Classification']
10
+ ).queue().launch()