Spaces:
Runtime error
Runtime error
File size: 1,732 Bytes
e5f84b0 |
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
import gradio as gr
from matplotlib.pyplot import title
import numpy as np
import tensorflow as tf
import random
from tensorflow import keras
damage_types = np.array(sorted(['yes', 'no']))
disaster_types = np.array(sorted(['volcano', 'flooding', 'earthquake', 'fire', 'wind', 'tsunami']))
# model = keras.models.load_model('Disaster-Classification')
def damage_classification(img):
prediction = np.random.rand(1, 2)[0]
return {damage_types[i]: prediction[i] for i in range(len(damage_types))}
def disaster_classification(img):
image = np.zeros((1, 1024, 1024, 3), dtype=np.uint8)
image[0] = img
# prediction = model.predict(image).tolist()[0]
prediction = np.random.rand(1, 6)[0]
return {disaster_types[i]: prediction[i] for i in range(len(disaster_types))}
iface = gr.Interface(
fn = [damage_classification, disaster_classification],
inputs = gr.inputs.Image(shape=(1024, 1024), image_mode='RGB', invert_colors=False, source="upload", type='numpy'),
outputs = gr.outputs.Label(),
allow_screenshot=True,
allow_flagging='never',
examples=[
'./sample_images/hurricane.png',
'./sample_images/volcano.png',
'./sample_images/wildfire.png'
],
thumbnail='./soteria-logo.png',
title="Soteria - AI for Natural Disaster Response",
description="""
Check out our project @ https://github.com/Soteria-ai/Soteria, see below for more explantation!
""",
theme="grass",
article="""
Explantation
Model #1 - Damage Classification: weather a diasater has happened or not
Model #2 - Disaster Classificaiton: what type of disaster happened?
"""
)
iface.launch(share=False, show_error=True, inline=True, debug=True) |