till-onethousand commited on
Commit
0af20d7
·
1 Parent(s): 7770ab4
Files changed (2) hide show
  1. README.md +3 -2
  2. app.py +4 -9
README.md CHANGED
@@ -6,7 +6,8 @@ sdk: gradio
6
  sdk_version: 4.44.0
7
  app_file: app.py
8
  pinned: false
9
- license: agpl-3.0
10
  ---
11
 
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
6
  sdk_version: 4.44.0
7
  app_file: app.py
8
  pinned: false
 
9
  ---
10
 
11
+ Get `yolov2.weights` from https://pjreddie.com/darknet/yolov2/.
12
+
13
+ Get `model/` from https://pjreddie.com/darknet/install/ building it on a machine with the same architecture as the machine where it is deployed.
app.py CHANGED
@@ -1,17 +1,14 @@
1
  import os
2
 
3
  import gradio as gr
4
- import PIL.Image as Image
5
-
6
- from ultralytics import ASSETS, YOLO
7
 
8
  model = None
9
 
10
 
11
- def predict_image(img, conf_threshold, iou_threshold, model_name):
12
  """Predicts objects in an image using a YOLOv8 model with adjustable confidence and IOU thresholds."""
13
  os.chdir('/home/user/app/model')
14
- os.system(f'/home/user/app/model/darknet detect /home/user/app/model/cfg/yolov2.cfg /home/user/app/model/yolov2.weights {img}')
15
 
16
  return '/home/user/app/model/predictions.jpg'
17
 
@@ -21,12 +18,10 @@ iface = gr.Interface(
21
  inputs=[
22
  gr.Image(type="filepath", label="Upload Image"),
23
  gr.Slider(minimum=0, maximum=1, value=0.25, label="Confidence threshold"),
24
- gr.Slider(minimum=0, maximum=1, value=0.45, label="IoU threshold"),
25
- gr.Radio(choices=["yolo11n", "yolo11s", "yolo11n-seg", "yolo11s-seg", "yolo11n-pose", "yolo11s-pose"], label="Model Name", value="yolo11n"),
26
  ],
27
  outputs=gr.Image(type="filepath", label="Result"),
28
- title="Ultralytics Gradio Application 🚀",
29
- description="Upload images for inference. The Ultralytics YOLO11n model is used by default.",
30
  )
31
 
32
  iface.launch()
 
1
  import os
2
 
3
  import gradio as gr
 
 
 
4
 
5
  model = None
6
 
7
 
8
+ def predict_image(img, conf_threshold):
9
  """Predicts objects in an image using a YOLOv8 model with adjustable confidence and IOU thresholds."""
10
  os.chdir('/home/user/app/model')
11
+ os.system(f'/home/user/app/model/darknet detect /home/user/app/model/cfg/yolov2.cfg /home/user/app/model/yolov2.weights {img} -thresh {conf_threshold}')
12
 
13
  return '/home/user/app/model/predictions.jpg'
14
 
 
18
  inputs=[
19
  gr.Image(type="filepath", label="Upload Image"),
20
  gr.Slider(minimum=0, maximum=1, value=0.25, label="Confidence threshold"),
 
 
21
  ],
22
  outputs=gr.Image(type="filepath", label="Result"),
23
+ title="OneThousand YoloV2 Person Detection",
24
+ description="Upload images for object detecting using YoloV2 model (https://pjreddie.com/darknet/yolov2/). Inference can take up to 15s.",
25
  )
26
 
27
  iface.launch()