Spaces:
Sleeping
Sleeping
File size: 1,377 Bytes
0a400bc 0be1742 0a400bc c840ca5 0a400bc 0be1742 44da644 0be1742 0a400bc 0be1742 44da644 3432102 44da644 3432102 44da644 0be1742 c840ca5 44da644 0be1742 0a400bc |
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 37 38 39 40 41 42 43 44 |
import numpy as np
import tensorflow as tf
import gradio as gr
# Load your trained model
best_model = tf.keras.models.load_model("best_EffiB0.keras")
# Define your class names
class_names = ["cardboard", "glass", "metal", "paper", "plastic", "trash"]
num_classes = len(class_names)
IMAGE_SIZE = (124, 124) #
def classify_image(img):
img = tf.image.resize(img, IMAGE_SIZE)[None, ...]
preds = best_model.predict(img)
return {class_names[i]: float(preds[0, i]) for i in range(num_classes)}
custom_footer = """
<p style="text-align: center;">
Developed with ❤️ by <strong>Adhiraj</strong>
</p>
<p style="text-align: center;">
<a href="https://www.linkedin.com/in/akathedeveloper/" target="_blank" style="display: inline-block; margin: 0 10px;">
<img src="https://cdn-icons-png.flaticon.com/512/174/174857.png" alt="LinkedIn" width="30">
</a>
<a href="https://github.com/akathedeveloper" target="_blank" style="display: inline-block; margin: 0 10px;">
<img src="https://cdn-icons-png.flaticon.com/512/25/25231.png" alt="GitHub" width="30">
</a>
</p>
"""
demo = gr.Interface(
fn=classify_image,
inputs=gr.Image(type="numpy"),
outputs=gr.Label(num_top_classes=3),
title="Garbage Classifier",
description="Classify images into cardboard, glass, metal, paper, plastic, or trash.",
article=custom_footer
)
demo.launch()
|