Commit
·
c1ba02e
1
Parent(s):
95e3fe3
add Annotator
Browse files
app.py
CHANGED
|
@@ -2,7 +2,7 @@ import gradio as gr
|
|
| 2 |
# load libraries
|
| 3 |
from huggingface_hub import hf_hub_download
|
| 4 |
from ultralytics import YOLO
|
| 5 |
-
|
| 6 |
from PIL import Image
|
| 7 |
|
| 8 |
# download model
|
|
@@ -19,13 +19,15 @@ import gradio as gr
|
|
| 19 |
|
| 20 |
def sepia(input_img):
|
| 21 |
output = model(input_img)
|
| 22 |
-
results = Detections.from_ultralytics(output[0])
|
| 23 |
-
arr_int = results.xyxy.astype(int)
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
-
return
|
| 29 |
|
| 30 |
demo = gr.Interface(sepia, gr.Image(), "image")
|
| 31 |
if __name__ == "__main__":
|
|
|
|
| 2 |
# load libraries
|
| 3 |
from huggingface_hub import hf_hub_download
|
| 4 |
from ultralytics import YOLO
|
| 5 |
+
import supervision as sv
|
| 6 |
from PIL import Image
|
| 7 |
|
| 8 |
# download model
|
|
|
|
| 19 |
|
| 20 |
def sepia(input_img):
|
| 21 |
output = model(input_img)
|
| 22 |
+
results = sv.Detections.from_ultralytics(output[0])
|
|
|
|
| 23 |
|
| 24 |
+
bounding_box_annotator = sv.BoundingBoxAnnotator()
|
| 25 |
+
annotated_frame = bounding_box_annotator.annotate(
|
| 26 |
+
scene = input_img.copy(),
|
| 27 |
+
detections = results
|
| 28 |
+
)
|
| 29 |
|
| 30 |
+
return annotated_frame
|
| 31 |
|
| 32 |
demo = gr.Interface(sepia, gr.Image(), "image")
|
| 33 |
if __name__ == "__main__":
|