spreaticsjcastle
commited on
Commit
·
94da2f2
1
Parent(s):
9ffc800
add face detection
Browse files
app.py
CHANGED
@@ -1,14 +1,34 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
-
|
4 |
-
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
output = gr.Textbox(label="Output Box")
|
9 |
-
greet_btn = gr.Button("Greet")
|
10 |
-
greet_btn.click(fn=greet, inputs=name, outputs=output, api_name="greet")
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
if __name__ == "__main__":
|
13 |
demo.launch()
|
14 |
-
|
|
|
|
1 |
import gradio as gr
|
2 |
+
# load libraries
|
3 |
+
from huggingface_hub import hf_hub_download
|
4 |
+
from ultralytics import YOLO
|
5 |
+
from supervision import Detections
|
6 |
+
from PIL import Image
|
7 |
|
8 |
+
# download model
|
9 |
+
model_path = hf_hub_download(
|
10 |
+
repo_id="arnabdhar/YOLOv8-Face-Detection", filename="model.pt"
|
11 |
+
)
|
12 |
|
13 |
+
# load model
|
14 |
+
model = YOLO(model_path)
|
|
|
|
|
|
|
15 |
|
16 |
+
import cv2
|
17 |
+
import numpy as np
|
18 |
+
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 |
+
for x, y, x2, y2 in arr_int:
|
26 |
+
cv2.rectangle(input_img, (x, y), (x2, y2), (0, 255, 0), 2)
|
27 |
+
|
28 |
+
return input_img
|
29 |
+
|
30 |
+
demo = gr.Interface(sepia, gr.Image(), "image")
|
31 |
if __name__ == "__main__":
|
32 |
demo.launch()
|
33 |
+
|
34 |
+
|