EOC123 commited on
Commit
f8cd642
·
1 Parent(s): dd008ea
Files changed (2) hide show
  1. app.py +12 -14
  2. 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
- # 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()
 
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