retest
Browse files
test.py
CHANGED
@@ -1,21 +1,19 @@
|
|
1 |
-
%pip install -r requirements.txt
|
2 |
-
%pip install gradio
|
3 |
-
|
4 |
import gradio as gr
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
|
|
19 |
if __name__ == "__main__":
|
20 |
-
demo.launch()
|
21 |
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from huggingface_hub import hf_hub_download
|
3 |
+
from ultralytics import YOLO
|
4 |
+
from supervision import Detections
|
5 |
+
from PIL import Image
|
6 |
+
import cv2
|
7 |
+
model_path = hf_hub_download(repo_id="arnabdhar/YOLOv8-Face-Detection", filename="model.pt")
|
8 |
+
model = YOLO(model_path)
|
9 |
+
def greet(img):
|
10 |
+
output = model(img)
|
11 |
+
results = Detections.from_ultralytics(output[0])
|
12 |
+
arr_int = results.xyxy.astype(int)
|
13 |
+
for x, y, x2, y2 in arr_int:
|
14 |
+
cv2.rectangle(img, (x, y), (x2, y2), (0, 255, 0), 2)
|
15 |
+
return img
|
16 |
+
demo = gr.Interface(fn=greet, inputs="image", outputs="image")
|
17 |
if __name__ == "__main__":
|
18 |
+
demo.launch(show_api=False, share=True)
|
19 |
|