Empire72's picture
Update app.py
3467823 verified
import gradio as gr
import tensorflow as tf
import numpy as np
from PIL import Image
# Load the TensorFlow SavedModel
model = tf.saved_model.load("saved_model")
# Grab the callable signature (first one usually works)
infer = list(model.signatures.values())[0]
labels = ["cool", "neutral", "warm"]
def predict(image):
image = image.resize((224, 224))
img_array = np.array(image) / 255.0
img_array = np.expand_dims(img_array, axis=0).astype(np.float32)
output = infer(tf.constant(img_array))
preds = list(output.values())[0].numpy()
label = labels[np.argmax(preds)]
confidence = float(np.max(preds))
return f"Predicted Undertone: {label.capitalize()} ({confidence*100:.2f}%)"
gr.Interface(
fn=predict,
inputs=gr.Image(type="pil", label="Upload your wrist photo"),
outputs="text",
title="Wrist Undertone Detector 🩵🩷💛",
description="Upload a wrist photo to detect your undertone: Cool, Neutral, or Warm.",
allow_flagging="never"
).launch()