import gradio as gr from transformers import pipeline text_generator = pipeline(model="ai-forever/Kandinsky_2.1") def generate_text(prompt, quality): length_dict = {"Low": 25, "Medium (Default)": 50, "High": 100} length = length_dict[quality] return text_generator(prompt, max_length=length, do_sample=True)[0]['generated_text'] iface = gr.Interface( fn=generate_text, inputs=["textbox", gr.inputs.Dropdown(["Low", "Medium (Default)", "High"], label="Quality")], outputs=gr.outputs.Image(label="Generated image:") ) iface.launch()