import gradio as gr import random import string text_gen=gr.Interface.load("spaces/Omnibus/MagicPrompt-Stable-Diffusion") proc1=gr.Interface.load("models/dreamlike-art/dreamlike-photoreal-2.0", preprocess=True, postprocess=False) proc2=gr.Interface.load("models/dreamlike-art/dreamlike-photoreal-2.0", preprocess=True, postprocess=False) proc3=gr.Interface.load("models/dreamlike-art/dreamlike-photoreal-2.0", preprocess=True, postprocess=False) proc4=gr.Interface.load("models/dreamlike-art/dreamlike-photoreal-2.0", preprocess=True, postprocess=False) proc5=gr.Interface.load("models/dreamlike-art/dreamlike-diffusion-1.0", preprocess=True, postprocess=False) proc6=gr.Interface.load("models/dreamlike-art/dreamlike-diffusion-1.0", preprocess=True, postprocess=False) proc7=gr.Interface.load("models/dreamlike-art/dreamlike-diffusion-1.0", preprocess=True, postprocess=False) proc8=gr.Interface.load("models/dreamlike-art/dreamlike-diffusion-1.0", preprocess=True, postprocess=False) def send_it1(inputs, proc1=proc1): output1=proc1(inputs) return(output1) def send_it2(inputs, proc2=proc2): output2=proc2(inputs) return(output2) def send_it3(inputs, proc3=proc3): output3=proc3(inputs) return(output3) def send_it4(inputs, proc4=proc4): output4=proc4(inputs) return(output4) def send_it5(inputs, proc5=proc5): output5=proc5(inputs) return(output5) def send_it6(inputs, proc6=proc6): output6=proc6(inputs) return(output6) def send_it7(inputs, proc7=proc7): output7=proc7(inputs) return(output7) def send_it8(inputs, proc8=proc8): output8=proc8(inputs) return(output8) def get_prompts(prompt_text): return text_gen(prompt_text) def add_noise(prompt_text): noise = ''.join(random.choice(string.ascii_letters) for i in range(random.randint(1,5))) return prompt_text + noise with gr.Blocks() as myface: with gr.Row(): input_text=gr.Textbox(label="Short Prompt") see_prompts=gr.Button("Magic Prompt") with gr.Row(): prompt=gr.Textbox(label="Prettified Prompt") run=gr.Button("Launch") with gr.Row(): output1=gr.Image(label="DreamlikeArt PhotoReal 1") output2=gr.Image(label="DreamlikeArt PhotoReal 2") output3=gr.Image(label="DreamlikeArt PhotoReal 3") output4=gr.Image(label="DreamlikeArt PhotoReal 4") with gr.Row(): output5=gr.Image(label="DreamlikeArt Diffusion 1") output6=gr.Image(label="DreamlikeArt Diffusion 2") output7=gr.Image(label="DreamlikeArt Diffusion 3") output8=gr.Image(label="DreamlikeArt Diffusion 4") see_prompts.click(lambda: prompt.set_input(get_prompts(input_text.get_input()))) run.click(lambda: [output1.set_input(send_it1(add_noise(prompt.get_input()))), output2.set_input(send_it2(add_noise(prompt.get_input()))), output3.set_input(send_it3(add_noise(prompt.get_input()))), output4.set_input(send_it4(add_noise(prompt.get_input()))), output5.set_input(send_it5(add_noise(prompt.get_input()))), output6.set_input(send_it6(add_noise(prompt.get_input()))), output7.set_input(send_it7(add_noise(prompt.get_input()))), output8.set_input(send_it8(add_noise(prompt.get_input())))])