Spaces:
Runtime error
Runtime error
File size: 952 Bytes
2df745a 98b5462 7fe0e10 461fa19 13ef97c 2df745a 461fa19 98b5462 461fa19 98b5462 13ef97c 75256e8 98b5462 1282b23 98b5462 fbcb518 98b5462 1282b23 |
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 |
import gradio as gr
import os
from transformers import pipeline
from pathlib import Path
from PIL import Image
import numpy as np
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):
image = Image.fromarray(np.uint8(image)).convert('RGB')
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.Label(),
cache_examples=False,
theme='earneleh/paris',
article = "Author: <a href=\"https://www.linkedin.com/in/arnau-castellano/\">Arnau Castellano</a>",
).launch(debug=True, enable_queue=True) |