ValorantTracker / app.py
SamDaLamb's picture
Update app.py
05f9833 verified
raw
history blame
1.68 kB
import gradio as gr
def greet(name):
return "Hello " + name + "!!"
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
def speclab(img):
# initialize the model
model = torch.hub.load('Nano1337/SpecLab', 'srdetect', force_reload=True) # for some reasons loads the model in src rather than demo
model.eval()
# preprocess image to be used as input
transforms = A.Compose([
A.Normalize(mean=(0.5, 0.5, 0.5), std=(0.5, 0.5, 0.5)),
ToTensorV2()
])
input = transforms(image=img)['image']
input = input.unsqueeze(0)
# model prediction
output = model(input)
# overlay output onto original image
img[output==255] = [0, 255, 0]
return img
# define app features and run
title = "SpecLab Demo"
description = "<p style='text-align: center'>Gradio demo for an ASPP model architecture trained on the SpecLab dataset. To use it, simply add your image, or click one of the examples to load them. Since this demo is run on CPU only, please allow additional time for processing. </p>"
article = "<p style='text-align: center'><a href='https://github.com/Nano1337/SpecLab'>Github Repo</a></p>"
css = "#0 {object-fit: contain;} #1 {object-fit: contain;}"
demo = gr.Interface(fn=speclab,
title=title,
description=description,
article=article,
inputs=gr.Image(elem_id=0, show_label=False),
outputs=gr.Image(elem_id=1, show_label=False),
css=css,
examples=examples,
cache_examples=True,
allow_flagging='never')
demo.launch()