test
Browse files- app.py +12 -14
- requirements.txt +4 -0
app.py
CHANGED
@@ -5,26 +5,24 @@ from supervision import Detections
|
|
5 |
from PIL import Image
|
6 |
import cv2
|
7 |
import supervision as sv
|
|
|
8 |
|
9 |
-
# download model
|
10 |
model_path = hf_hub_download(repo_id="arnabdhar/YOLOv8-Face-Detection", filename="model.pt")
|
11 |
|
12 |
# load model
|
13 |
model = YOLO(model_path)
|
14 |
|
15 |
-
|
16 |
-
image_path = "aespa.jpg"
|
17 |
-
output = model(Image.open(image_path))
|
18 |
-
results = Detections.from_ultralytics(output[0])
|
19 |
|
20 |
-
|
|
|
21 |
|
22 |
-
bounding_box_annotator = sv.BoundingBoxAnnotator()
|
23 |
-
annotated_frame = bounding_box_annotator.annotate(
|
24 |
-
|
25 |
-
|
26 |
-
)
|
|
|
27 |
|
28 |
-
|
29 |
-
|
30 |
-
cv2.destroyAllWindows()
|
|
|
5 |
from PIL import Image
|
6 |
import cv2
|
7 |
import supervision as sv
|
8 |
+
import gradio as gr
|
9 |
|
|
|
10 |
model_path = hf_hub_download(repo_id="arnabdhar/YOLOv8-Face-Detection", filename="model.pt")
|
11 |
|
12 |
# load model
|
13 |
model = YOLO(model_path)
|
14 |
|
15 |
+
def process_image(image):
|
|
|
|
|
|
|
16 |
|
17 |
+
output = model(image)
|
18 |
+
results = Detections.from_ultralytics(output[0])
|
19 |
|
20 |
+
bounding_box_annotator = sv.BoundingBoxAnnotator()
|
21 |
+
annotated_frame = bounding_box_annotator.annotate(
|
22 |
+
scene = image.copy(),
|
23 |
+
detections = results
|
24 |
+
)
|
25 |
+
return annotated_frame
|
26 |
|
27 |
+
demo = gr.Interface(fn=process_image, inputs="image", outputs="image")
|
28 |
+
demo.launch()
|
|
requirements.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
opencv-python
|
2 |
+
huggingface_hub
|
3 |
+
ultralytics
|
4 |
+
supervision
|