Viihtorugo
commited on
Commit
·
739786c
1
Parent(s):
0c0efd7
First version of my app
Browse files- app.py +20 -0
- requirements.txt +4 -0
app.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Carregar um modelo pré-treinado
|
| 5 |
+
classifier = pipeline("image-classification", model="google/vit-base-patch16-224")
|
| 6 |
+
|
| 7 |
+
def classify_image(image):
|
| 8 |
+
results = classifier(image)
|
| 9 |
+
return {result["label"]: result["score"] for result in results}
|
| 10 |
+
|
| 11 |
+
# Criar interface com Gradio
|
| 12 |
+
iface = gr.Interface(
|
| 13 |
+
fn=classify_image,
|
| 14 |
+
inputs=gr.Image(type="pil"),
|
| 15 |
+
outputs=gr.Label(),
|
| 16 |
+
title="Classificação de Imagem",
|
| 17 |
+
description="Envie uma imagem e veja a classificação gerada pelo modelo Vision Transformer."
|
| 18 |
+
)
|
| 19 |
+
|
| 20 |
+
iface.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
transformers
|
| 3 |
+
torch
|
| 4 |
+
torchvision
|