NimaKL's picture
Rename app-gradle.py to app.py
52747bb
raw
history blame
1.22 kB
import gradio as gr
from transformers import pipeline, AutoTokenizer, AutoModelForSequenceClassification
model_name = "NimaKL/FireWatch_tiny_75k"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
def predict(text):
inputs = tokenizer(text, return_tensors="pt")
outputs = model(**inputs)
logits = outputs.logits
label_id = logits.argmax(axis=1).item()
return "Danger of fire hazard!" if label_id == 1 else "It is unlikely that a fire will start in this area."
io = gr.Interface(
fn=predict,
inputs="text",
outputs="text",
title="FireWatch",
description="Predict whether a data row describes a fire hazard or not.",
output_description="Prediction",
examples=[['-26.76123, 147.15512, 393.02, 203.63'], ['-26.7598, 147.14514, 361.54, 79.4'], ['-25.70059, 149.48932, 313.9, 5.15'], ['-24.4318, 151.83102, 307.98, 8.79'], ['-23.21878, 148.91298, 314.08, 7.4'], ['7.87518, 19.9241, 316.32, 39.63'], ['-20.10942, 148.14326, 314.39, 8.8'], ['7.87772, 19.9048, 304.14, 13.43'], ['-20.79866, 124.46834, 366.74, 89.06']]
,
output_component_names=["Prediction"],
theme="Streamlit"
)
io.launch()