mrolando commited on
Commit
c8f645f
1 Parent(s): fa0513b

first commit

Browse files
Files changed (3) hide show
  1. Iso_Logotipo_Ceibal.png +0 -0
  2. app.py +50 -0
  3. requirements.txt +2 -0
Iso_Logotipo_Ceibal.png ADDED
app.py ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ # processor = ViTImageProcessor.from_pretrained('google/vit-base-patch16-224')
4
+ # model = ViTForImageClassification.from_pretrained('google/vit-base-patch16-224')
5
+
6
+ from transformers import pipeline
7
+
8
+ import base64
9
+
10
+ with open("Iso_Logotipo_Ceibal.png", "rb") as image_file:
11
+ encoded_image = base64.b64encode(image_file.read()).decode()
12
+
13
+
14
+ classifier = pipeline(model="google/vit-base-patch16-224")
15
+ # classifier("https://huggingface.co/datasets/Narsil/image_dummy/raw/main/parrots.png")
16
+ def clasificador(image):
17
+ results = classifier(image)
18
+ result = {}
19
+ for item in results:
20
+ result[translate_text(item['label'])] = item['score']
21
+ return result
22
+
23
+
24
+ es_en_translator = pipeline("translation",model = "Helsinki-NLP/opus-mt-en-es")
25
+ def translate_text(text):
26
+ text = es_en_translator(text)[0].get("translation_text")
27
+ return text
28
+
29
+ with gr.Blocks() as demo:
30
+ gr.Markdown("""
31
+ <center>
32
+ <h1>
33
+ Uso de AI para la clasificación de imágenes.
34
+ </h1>
35
+ <img src='data:image/jpg;base64,{}' width=200px>
36
+ <h3>
37
+ Con este espacio podrás clasificar imágenes y objetos a partir de una imagen.
38
+ </h3>
39
+
40
+ </center>
41
+ """.format(encoded_image))
42
+ with gr.Row():
43
+ with gr.Column():
44
+ inputt = gr.Image(type="pil", label="Ingresá la imagen a clasificar.")
45
+ button = gr.Button(value="Clasificar")
46
+ with gr.Column():
47
+ output = gr.Label()
48
+ button.click(clasificador,inputt,output)
49
+
50
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ gradio
2
+ transformers