| import gradio as gr | |
| import tensorflow as tf | |
| from PIL import Image | |
| import numpy as np | |
| model = tf.keras.models.load_model("model.h5") | |
| def predict(img): | |
| img = img.resize((224, 224)) | |
| img_array = np.expand_dims(np.array(img) / 255.0, axis=0) | |
| preds = model.predict(img_array) | |
| labels = ["cool", "neutral", "warm"] | |
| return {labels[i]: float(preds[0][i]) for i in range(3)} | |
| gr.Interface(fn=predict, inputs=gr.Image(), outputs=gr.Label()).launch() | |