Spaces:
Running
Running
import gradio as gr | |
from transformers import AutoModelForImageClassification, AutoFeatureExtractor, pipeline | |
model = AutoModelForImageClassification.from_pretrained("mestrevh/computer-vision-beans", use_safetensors=True) | |
feature_extractor = AutoFeatureExtractor.from_pretrained("mestrevh/computer-vision-beans") | |
classifier = pipeline("image-classification", model=model, feature_extractor=feature_extractor) | |
# Função de classificação | |
def predict_image(image): | |
return classifier(image) | |
# Interface Gradio | |
interface = gr.Interface(fn=predict_image, | |
inputs=gr.inputs.Image(type="pil"), | |
outputs="label", | |
live=True) | |
interface.launch() | |