Spaces:
Sleeping
Sleeping
File size: 1,004 Bytes
9201e90 b77cc5e b7975ba d48676a da1a26d 9201e90 d48676a 9201e90 d48676a 9201e90 d48676a 9201e90 d48676a | 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 38 | import gradio as gr
import numpy as np
import uuid
from PIL import Image
import os
def inference(img):
name_tag = uuid.uuid4()
script_command = f"python yolov9/detect_dual.py --source {img} --img 640 --device cpu --weights yolov9/runs/train/exp2/weights/best.pt --name {name_tag}"
os.system(script_command)
return f"yolov9/runs/detect/{name_tag}/{img.split('/')[-1]}"
title = "Sketch GUI Element Detection"
description = "This is a demo for detecting GUI elements in a sketch image. Upload a sketch image and the model will detect the GUI elements in the image."
img_input = gr.Image(
type="filepath", label="Upload a sketch image", width=300, height=300
)
prediction_output = gr.Image(label="Output Image", width=640, height=640)
example_lst = [
["test_images/Shipping-1.png"],
]
demo = gr.Interface(
fn=inference,
inputs=img_input,
outputs=prediction_output,
title=title,
description=description,
examples=example_lst,
)
demo.launch(share=True)
|