File size: 1,420 Bytes
3ff10a0
ab3f808
a4fcc7e
559ec57
24d3233
b9cfa97
e3cbd34
24d3233
0a761bc
93eec9d
e6ac0b5
 
56d3554
 
0e74aec
 
 
c10febf
bd85065
4ed1df8
c0d6cc2
 
 
 
 
 
 
 
 
 
4ed1df8
a4fcc7e
d365b80
98224c2
cd13712
41739ba
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
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('eee2.keras')

def image_mod(image):
    raw_image = image
    temp_image = "temporary_image.jpg"
    cv2.imwrite(temp_image, raw_image)
    
    img = cv2.imread("temporary_image.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(yhat)
    display = str(display)
    #if display == "0":
    #    message = "Rainy" # Jida,_Zhuhai,_rainy_day.jpg
    #if display == "1":
    #    message = "Sunny" # Morning_fog_-_Flickr_-_tmoravec.jpg
    #if display == "2":
    #    message = "Foggy" # Stuyvesant_Fish_House_25_E78_St_cloudy_jeh.jpg
    #if display == "3":
    #    message = "Cloudy" #Snow_on_Branches,_Beechview,_2020-12-17,_01.jpg
    #if display == "4":
    #    message = "Snowy" # Daedalus_000355_171913_516869_4578_(36155269413).jpg
    return display

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","Stuyvesant_Fish_House_25_E78_St_cloudy_jeh.jpg","Morning_fog_-_Flickr_-_tmoravec.jpg","Jida,_Zhuhai,_rainy_day.jpg","Snowy_Nashua.jpg"]).launch()