File size: 618 Bytes
3cbf1d1
 
 
 
 
fbd683f
3cbf1d1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import gradio as gr
import torch
from PIL import Image

# Load the model using torch.hub (you must have the model locally)
model_name = "skin_burn_2022_8_21 (1).pt"
model =torch.hub.load("WongKinYiu/yolov7", 'custom',model_name)

def predict(img):
    # Run inference with YOLO model
    results = model(img)
    # Convert the result to an image
    result_img = Image.fromarray(results.render())
    return result_img

# Define a Gradio interface
iface = gr.Interface(
    fn=predict,  # the function to wrap
    inputs=gr.inputs.Image(),  # input type
    outputs=gr.outputs.Image()  # output type
)

iface.launch()