Spaces:
Runtime error
Runtime error
import tensorflow as tf | |
from keras.models import load_model | |
import gradio as gr | |
from matplotlib import pyplot as plt | |
import cv2 | |
import numpy as np | |
model = load_model('eee.keras') | |
def image_mod(image_mod): | |
img = cv2.imread("Foggy_morning_Bucharest.jpg") | |
resize = tf.image.resize(img, (256, 256)) | |
plt.imshow(resize.numpy().astype(int)) | |
yhat = model.predict(np.expand_dims(resize,0)) | |
display = np.argmax(yhat) | |
display = str(display) | |
if display == "0": | |
message = "Rainy" # Jida,_Zhuhai,_rainy_day.jpg | |
if display == "1": | |
message = "Foggy" | |
if display == "2": | |
message = "Cloudy" | |
if display == "3": | |
message = "Snowy" #Snow_on_Branches,_Beechview,_2020-12-17,_01.jpg | |
if display == "4": | |
message = "Sunny" # Daedalus_000355_171913_516869_4578_(36155269413).jpg | |
return message | |
gr.Interface(fn=image_mod, | |
inputs=gr.Image(shape=(256, 256)), | |
outputs=gr.Label(num_top_classes=3), | |
examples=["Daedalus_000355_171913_516869_4578_(36155269413).jpg","Utah_solar;_a_photovoltaic_power_station_(36293687776).jpg","Foggy_morning_Bucharest.jpg","Jida,_Zhuhai,_rainy_day.jpg","Snow_on_Branches,_Beechview,_2020-12-17,_01.jpg"]).launch() |