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()