arnaucas's picture
Upload 2 files
461fa19
raw
history blame
902 Bytes
import gradio as gr
import os
from transformers import pipeline
from pathlib import Path
example_imgs = ["examples/img0.jpg",
"examples/img1.jpg",
"examples/img2.jpg",
"examples/img3.jpg"]
pipe = pipeline("image-classification", model="arnaucas/wildfire-classifier")
def inference(image):
if image in example_imgs:
image = "./examples/" + image
output = pipe(image)
result = {item['label']: item['score'] for item in output}
return result
gr.Interface(
fn=inference,
title="Wildfire Detection",
description = "Predict whether an image contains wildfire or not",
inputs="image",
examples=example_imgs,
outputs=gr.outputs.Label(num_top_classes=2, label='Classifiaction'),
cache_examples=False,
article = "Author: <a href=\"https://www.linkedin.com/in/arnau-castellano/\">Arnau Castellano</a>",
)