EOC123 commited on
Commit
dd008ea
·
1 Parent(s): f07f26f
Files changed (1) hide show
  1. app.py +28 -5
app.py CHANGED
@@ -1,7 +1,30 @@
1
- import gradio as gr
 
 
 
 
 
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!"
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # load libraries
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
+ 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
+ # inference
16
+ image_path = "aespa.jpg"
17
+ output = model(Image.open(image_path))
18
+ results = Detections.from_ultralytics(output[0])
19
+
20
+ src = cv2.imread("aespa.jpg")
21
+
22
+ bounding_box_annotator = sv.BoundingBoxAnnotator()
23
+ annotated_frame = bounding_box_annotator.annotate(
24
+ scene = src.copy(),
25
+ detections = results
26
+ )
27
+
28
+ cv2.imshow("faces", annotated_frame)
29
+ cv2.waitKey()
30
+ cv2.destroyAllWindows()