alvinc80 commited on
Commit
3eef6bb
Β·
1 Parent(s): 38be9c1
Files changed (3) hide show
  1. README.md +2 -2
  2. app.py +35 -0
  3. requirements.txt +2 -0
README.md CHANGED
@@ -1,8 +1,8 @@
1
  ---
2
  title: 5950119M
3
  emoji: 🌍
4
- colorFrom: blue
5
- colorTo: gray
6
  sdk: gradio
7
  sdk_version: 5.9.1
8
  app_file: app.py
 
1
  ---
2
  title: 5950119M
3
  emoji: 🌍
4
+ colorFrom: indigo
5
+ colorTo: red
6
  sdk: gradio
7
  sdk_version: 5.9.1
8
  app_file: app.py
app.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from ultralytics import YOLO
2
+ from PIL import Image
3
+ import gradio as gr
4
+ from huggingface_hub import snapshot_download
5
+ import os
6
+
7
+
8
+ def load_model(repo_id):
9
+ download_dir = snapshot_download(repo_id)
10
+ print(download_dir)
11
+ path = os.path.join(download_dir, "best_int8_openvino_model")
12
+ print(path)
13
+ detection_model = YOLO(path, task='detect')
14
+ return detection_model
15
+
16
+
17
+ def predict(pilimg):
18
+
19
+ source = pilimg
20
+ # x = np.asarray(pilimg)
21
+ # print(x.shape)
22
+ result = detection_model.predict(source, conf=0.5, iou=0.6)
23
+ img_bgr = result[0].plot()
24
+ out_pilimg = Image.fromarray(img_bgr[..., ::-1]) # RGB-order PIL image
25
+
26
+ return out_pilimg
27
+
28
+
29
+ REPO_ID = "alvinc/hats_shoes_yolov8"
30
+ detection_model = load_model(REPO_ID)
31
+
32
+ gr.Interface(fn=predict,
33
+ inputs=gr.Image(type="pil"),
34
+ outputs=gr.Image(type="pil")
35
+ ).launch(share=True)
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ ultralytics
2
+ huggingface_hub