bit / app.py
0xrushi's picture
Create app.py
d1fc7e7
raw
history blame
No virus
1.01 kB
import gradio as gr
import os
from huggingface_hub import from_pretrained_keras
import tensorflow as tf
model = from_pretrained_keras("rushic24/bit")
allImages = []
directory = 'images'
CLASSES = ['daisy', 'dandelion', 'roses', 'sunflowers', 'tulips']
# iterate over files in images directory
for filename in os.listdir(directory):
f = os.path.join(directory, filename)
if os.path.isfile(f):
allImages.append(f)
def flower_classifier(image):
image = tf.image.resize(image, (224, 224))
image = image / 255.0
image = tf.expand_dims(image, 0)
pred = model(image)
labeldict = dict(zip([CLASSES[i] for i in range(len(pred))], pred))
return labeldict
iface = gr.Interface(flower_classifier,
title = "Award-Winning Deep Learning Project",
examples = allImages,
inputs = gr.inputs.Image(),
outputs = gr.outputs.Label(num_top_classes=5),
capture_session=True)
iface.launch(debug=True)