Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
from transformers import pipeline, AutoTokenizer, AutoModelForSequenceClassification
|
3 |
|
4 |
model_name = "NimaKL/FireWatch_tiny_75k"
|
@@ -12,6 +13,17 @@ def predict(text):
|
|
12 |
label_id = logits.argmax(axis=1).item()
|
13 |
return "Danger of fire hazard!" if label_id == 1 else "It is unlikely that a fire will start in this area."
|
14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
io = gr.Interface(
|
16 |
fn=predict,
|
17 |
inputs="text",
|
@@ -19,10 +31,14 @@ io = gr.Interface(
|
|
19 |
title="FireWatch",
|
20 |
description="Predict whether a data row describes a fire hazard or not.",
|
21 |
output_description="Prediction",
|
22 |
-
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']]
|
23 |
-
,
|
24 |
output_component_names=["Prediction"],
|
25 |
-
theme="Streamlit"
|
|
|
|
|
26 |
)
|
27 |
|
|
|
|
|
|
|
28 |
io.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
from IPython.display import IFrame
|
3 |
from transformers import pipeline, AutoTokenizer, AutoModelForSequenceClassification
|
4 |
|
5 |
model_name = "NimaKL/FireWatch_tiny_75k"
|
|
|
13 |
label_id = logits.argmax(axis=1).item()
|
14 |
return "Danger of fire hazard!" if label_id == 1 else "It is unlikely that a fire will start in this area."
|
15 |
|
16 |
+
# Define a custom CSS style
|
17 |
+
custom_style = """
|
18 |
+
body {
|
19 |
+
background-color: #F262626;
|
20 |
+
}
|
21 |
+
"""
|
22 |
+
|
23 |
+
# Define the function to display the Google Sheets document
|
24 |
+
def show_sheet():
|
25 |
+
return IFrame("https://docs.google.com/spreadsheets/d/1b2aAZ8ue5NI7hZ-MiNc8y4dFthbrRiXlsaEeYSHgNCM/edit?usp=sharing", width=800, height=600)
|
26 |
+
|
27 |
io = gr.Interface(
|
28 |
fn=predict,
|
29 |
inputs="text",
|
|
|
31 |
title="FireWatch",
|
32 |
description="Predict whether a data row describes a fire hazard or not.",
|
33 |
output_description="Prediction",
|
34 |
+
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']],
|
|
|
35 |
output_component_names=["Prediction"],
|
36 |
+
theme="Streamlit",
|
37 |
+
css=custom_style,
|
38 |
+
article="<h2>FireWatch App</h2><p>This app predicts whether a data row describes a fire hazard or not. The prediction is based on a machine learning model that has been trained on a dataset of data rows.</p><h2>Data Rows Sheet</h2>"
|
39 |
)
|
40 |
|
41 |
+
# Add the IFrame component to the app
|
42 |
+
io.add_component("Sample Data Sheet", gr.outputs.HTML, show_sheet)
|
43 |
+
|
44 |
io.launch()
|