Spaces:
Running
Running
import os | |
import gradio as gr | |
model = None | |
def predict_image(img, conf_threshold): | |
"""Predicts objects in an image using a YOLOv8 model with adjustable confidence and IOU thresholds.""" | |
os.chdir('/home/user/app/model') | |
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}') | |
return '/home/user/app/model/predictions.jpg' | |
iface = gr.Interface( | |
fn=predict_image, | |
inputs=[ | |
gr.Image(type="filepath", label="Upload Image"), | |
gr.Slider(minimum=0, maximum=1, value=0.25, label="Confidence threshold"), | |
], | |
outputs=gr.Image(type="filepath", label="Result"), | |
title="OneThousand YoloV2 Person Detection", | |
description="Upload images for object detecting using YoloV2 model (https://pjreddie.com/darknet/yolov2/). Inference can take up to 15s.", | |
) | |
iface.launch() |