File size: 635 Bytes
d335d6f
 
d07d948
d335d6f
d07d948
 
d335d6f
d07d948
d335d6f
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import gradio as gr
from transformers import pipeline
text_generator = pipeline(model="ai-forever/Kandinsky_2.1", task="text2img")

def generate_text(prompt, quality="High (Default)"):
    length_dict = {"Low": 50, "High (Default)": 100, "High": 175}
    length = length_dict[quality]
    return text_generator(prompt, h=768, w=768, num_steps=legnth, batch_size=1, sampler='p_sampler', prior_steps="5", prior_cf_scale=4,)[0]

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()