|
import gradio as gr |
|
import os |
|
import torch |
|
from PIL import Image |
|
|
|
|
|
|
|
|
|
def find(name, path): |
|
for root, dirs, files in os.walk(path): |
|
if name in files: |
|
return os.path.join(root, name) |
|
|
|
model = torch.hub.load('ultralytics/yolov5', 'custom', path='Content/best.pt') |
|
model.conf = 0.38 |
|
model.hide_conf=True |
|
|
|
def detect(inp): |
|
|
|
|
|
results = model(inp,size=640) |
|
results.render() |
|
return Image.fromarray(results.imgs[0]) |
|
|
|
|
|
inp = gr.inputs.Image(type='pil', label="Original Image") |
|
output = gr.outputs.Image(type="pil", label="Output Image") |
|
|
|
|
|
io=gr.Interface(fn=detect, inputs=inp, outputs=output, title='Party Symbol Detection',examples=['Content/4.jpg','Content/18.jpg']) |
|
io.launch(debug=False,share=True) |
|
|
|
|
|
|
|
|
|
|