LunarEcho1's picture
Create app.py
661cf1b verified
Raw
History Blame Contribute Delete
532 Bytes
import gradio as gr
from transformers import pipeline
# Load your model from the Hugging Face Hub
classifier = pipeline("text-classification", model="LunarEcho1/my-food-classifier")
# Inference function
def classify(text):
prediction = classifier(text)[0]
label = prediction["label"]
score = round(prediction["score"], 3)
return f"{label} ({score})"
# Create the Gradio interface
demo = gr.Interface(fn=classify, inputs="text", outputs="text", title="🍔 Food or Not Classifier")
# Launch the app
demo.launch()