Spaces:
Runtime error
Runtime error
File size: 1,227 Bytes
fed1544 45cf92d fed1544 f7eeb0f fed1544 7ed43db 64c398d 6b5b43a e35b449 64c398d fed1544 814d854 347c196 fed1544 69698cc 814d854 4bcb8b4 b79f841 64c398d b79f841 fed1544 24c188b 559e299 fed1544 |
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 39 40 |
import gradio as gr
import os
import torch
from PIL import Image
#subprocess.run(["mv","content/custom_data.yaml","./yolov5/data"])
def load_model():
'''
Loading hub model & setting the preferences for the model
'''
model = torch.hub.load('ultralytics/yolov5', 'custom', path='Content/best.pt')
model.conf = 0.38
model.dnn=True
model.line_thickness=16
return model
model=load_model()
#, force_reload=True
def detect(inp):
#g = (size / max(inp.size)) # gain
#im = im.resize((int(x * g) for x in im.size), Image.ANTIALIAS) # resize
results = model(inp,size=640) # inference
results.render() # updates results.imgs with boxes and labels
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/10.jpg','Content/18.jpg'])
io.launch(debug=False,share=True)
|