File size: 721 Bytes
dadd386
afa2cab
dadd386
afa2cab
 
 
 
dadd386
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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()