import gradio as gr from transformers import pipeline # Cargamos el modelo traductor y creamos el pipeline para traducir al ingles spanish_model_name = "Helsinki-NLP/opus-mt-es-en" translator_es_en = pipeline("translation", model=spanish_model_name) def translate(text): prompt_es = text english_text = translator_es_en(prompt_es) prompt_en = english_text[0]['translation_text'] return prompt_en title="Texto a Imagen en Español con Stable Diffusion 2.0" article = """ El modelo usa: - Texto a Imagen [Stable Diffusion 2.0](https://huggingface.co/stabilityai/stable-diffusion-2), - Para las traducciones [Helsinki-NLP](https://huggingface.co/Helsinki-NLP) \n ... y mucha magia ☺ """ gr.Interface(fn=translate, inputs= gr.Textbox("", max_lines = 2, label = "Inserte su texto aqui"), outputs = "text").load("models/stabilityai/stable-diffusion-2", title = title, article=article).launch(debug=True)