Spaces:
Sleeping
Sleeping
File size: 1,025 Bytes
57fb0f8 a98860d 57fb0f8 a98860d 57fb0f8 a98860d 57fb0f8 a98860d 57fb0f8 a98860d 35fcc70 57fb0f8 a98860d 57fb0f8 a98860d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
import gradio as gr
from detection_pipeline import DetectionModel
if gr.NO_RELOAD:
model = DetectionModel()
preds = []
def predict(image, threshold):
global preds
preds = model(image)
return filter_preds(image, threshold)
def filter_preds(image, threshold):
preds_ = list(filter(lambda x: x[4] > threshold/100, preds))
output = model.visualize(image, preds_)
return output
with gr.Blocks() as interface:
with gr.Row():
with gr.Column():
image = gr.Image(label="Input", value="sample/1.jpg")
with gr.Column():
output = gr.Image(label="Output")
with gr.Row():
with gr.Column():
threshold = gr.Slider(0, 100, 30, step=5, label="Threshold")
threshold.release(filter_preds, inputs=[image, threshold], outputs=output)
with gr.Column():
button = gr.Button(value="Detect")
button.click(predict, [image, threshold], output)
if __name__ == "__main__":
interface.launch() |