Food-Classifier / app.py
ZachBeesley's picture
Update app.py
f8398e5
raw
history blame contribute delete
636 Bytes
from transformers import AutoImageProcessor
from transformers import TFAutoModelForImageClassification
import tensorflow as tf
def classifier(image):
image_processor = AutoImageProcessor.from_pretrained("ZachBeesley/Food-Classifier")
inputs = image_processor(image, return_tensors="tf")
model = TFAutoModelForImageClassification.from_pretrained("ZachBeesley/Food-Classifier")
logits = model(**inputs).logits
predicted_class_id = int(tf.math.argmax(logits, axis=-1)[0])
return model.config.id2label[predicted_class_id]
import gradio as gr
demo = gr.Interface(fn=classifier, inputs="image", outputs="label")
demo.launch()