Spaces:
Runtime error
Runtime error
Upload app.py with huggingface_hub
Browse files123456789101112131415161718192021222324252627import gradio as grimport tensorflow as tfimport tensorflow_hub as hubimport numpy as np
model = tf.keras.models.load_model("model.h5", custom_objects={'KerasLayer': hub.KerasLayer})class_names = ['in dress code', 'not in dress code']IMG_SIZE = 224
def preprocess_image(image): image = tf.convert_to_tensor(image, dtype=tf.float32) image = tf.image.resize(image, (IMG_SIZE, IMG_SIZE)) / 255.0 return tf.expand_dims(image, axis=0)
def predict_dress_code(image): processed = preprocess_image(image) preds = model.predict(processed) label = class_names[np.argmax(preds)] confidence = float(np.max(preds)) return f"{label} ({confidence:.2f})"
iface = gr.Interface(fn=predict_dress_code, inputs=gr.Image(type="numpy"), outputs="text", title="Dress Code Violation Detector")
iface.launch()app.pyAdded+27