import gradio as gr # processor = ViTImageProcessor.from_pretrained('google/vit-base-patch16-224') # model = ViTForImageClassification.from_pretrained('google/vit-base-patch16-224') from transformers import pipeline import base64 import os with open("Iso_Logotipo_Ceibal.png", "rb") as image_file: encoded_image = base64.b64encode(image_file.read()).decode() classifier = pipeline(model="google/vit-base-patch16-224") # classifier("https://huggingface.co/datasets/Narsil/image_dummy/raw/main/parrots.png") def clasificador(image): results = classifier(image) result = {} for item in results: result[translate_text(item['label'])] = item['score'] return result es_en_translator = pipeline("translation",model = "Helsinki-NLP/opus-mt-es-en") def translate_text(text): print(text) text = es_en_translator(text)[0].get("translation_text") print(text) return text with gr.Blocks(title = "Uso de AI para la clasificación de imágenes.") as demo: gr.Markdown("""