hjmo commited on
Commit
d26a5d4
1 Parent(s): 728e015
Files changed (1) hide show
  1. test.py +16 -18
test.py CHANGED
@@ -1,21 +1,19 @@
1
- %pip install -r requirements.txt
2
- %pip install gradio
3
-
4
  import gradio as gr
5
- import numpy as np
6
-
7
- def sepia(input_img):
8
- sepia_filter - np.array([
9
- [0.393, 0.769, 0.189],
10
- [0.349, 0.686, 0.168],
11
- [0.272, 0.534, 0.131]
12
- ])
13
- sepia_img = input_img.dot(sepia_filter.T)
14
- sepia_img /= sepia_img.max()
15
- return sepia_img
16
-
17
- demo = gr.Interface(sepia, gr.Image(), "Image")
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