hhxxhh commited on
Commit
3a2845e
1 Parent(s): 0734137
Files changed (1) hide show
  1. app.py +38 -0
app.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from huggingface_hub import hf_hub_download
2
+ from ultralytics import YOLO
3
+ import gradio as gr
4
+ from PIL import Image
5
+ import cv2
6
+ import numpy as np
7
+ import torch
8
+
9
+ path = hf_hub_download("Bingsu/adetailer", "person_yolov8s-seg.pt")
10
+ model = YOLO(path)
11
+
12
+
13
+
14
+ def infer(img: Image.Image):
15
+ img = "https://farm5.staticflickr.com/4139/4887614566_6b57ec4422_z.jpg"
16
+ output = model(img)
17
+ pred = output[0].plot()
18
+ pred = cv2.cvtColor(pred, cv2.COLOR_BGR2RGB)
19
+ pred = Image.fromarray(pred)
20
+ return pred
21
+
22
+
23
+ inputs = gr.inputs.Image(type='pil', label="Original Image")
24
+ outputs = [
25
+ # gr.outputs.Image(type="numpy",label="Mask").style(height=600),
26
+ gr.outputs.Image(type="numpy",label="Mask"),
27
+ # gr.outputs.Image(type="numpy",label="Foreground"),
28
+ ]
29
+
30
+ examples = [
31
+ ['fox.jpg'],
32
+ ['parrot.jpg']
33
+ ]
34
+
35
+ gr.Interface(infer, inputs, outputs, title=f"anime seg", allow_flagging=False).launch(server_name=f"10.17.1.16", server_port=6019)
36
+
37
+ if __name__ == "__main__":
38
+ a = 1