File size: 512 Bytes
2b6c388
 
 
 
 
 
 
0776098
 
2b6c388
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import os
import numpy as np
import gradio as gr

import tensorflow as tf
from tensorflow.keras.models import load_model

#CloudDeploymentTest/
model = load_model('model.keras')
labels = ["bird", "cat", "deer", "dog"]

def pred(input_img):
    prediction = model.predict(np.array([input_img])/255) #/255 to normalize (rgb)
    prediction = np.argmax(prediction)
    prediction = labels[prediction]
    return prediction

demo = gr.Interface(pred, gr.Image(), "text")

if __name__ == "__main__":
    demo.launch()