Commit
·
c21f330
1
Parent(s):
046a2a3
Debug
Browse files
app.py
CHANGED
|
@@ -8,8 +8,10 @@ rudalle = gr.Interface.load("spaces/multimodalart/rudalle")
|
|
| 8 |
print(rudalle)
|
| 9 |
guided = gr.Interface.load("spaces/EleutherAI/clip-guided-diffusion")
|
| 10 |
print(guided)
|
| 11 |
-
def text2image_latent(text,steps,width,height,images,diversity):
|
|
|
|
| 12 |
image = latent(text, steps, width, height, images, diversity)[0]
|
|
|
|
| 13 |
return(image)
|
| 14 |
|
| 15 |
def text2image_rudalle(text,aspect,model):
|
|
@@ -17,32 +19,39 @@ def text2image_rudalle(text,aspect,model):
|
|
| 17 |
print(image)
|
| 18 |
return(image)
|
| 19 |
|
|
|
|
| 20 |
def text2image_guided(text):
|
| 21 |
-
image = guided(text,
|
|
|
|
|
|
|
| 22 |
return(image)
|
| 23 |
|
| 24 |
block = gr.Blocks()
|
| 25 |
|
| 26 |
with block:
|
| 27 |
text = gr.inputs.Textbox(placeholder="Try writing something..")
|
| 28 |
-
|
|
|
|
|
|
|
| 29 |
steps = gr.inputs.Slider(label="Steps - more steps can increase quality but will take longer to generate",default=45,maximum=50,minimum=1,step=1)
|
| 30 |
width = gr.inputs.Radio(label="Width", choices=[32,64,128,256],default=256)
|
| 31 |
height = gr.inputs.Radio(label="Height", choices=[32,64,128,256],default=256)
|
| 32 |
images = gr.inputs.Slider(label="Images - How many images you wish to generate", default=2, step=1, minimum=1, maximum=4)
|
| 33 |
diversity = gr.inputs.Slider(label="Diversity scale - How different from one another you wish the images to be",default=5.0, minimum=1.0, maximum=15.0)
|
| 34 |
get_image_latent = gr.Button("Generate Image")
|
| 35 |
-
with gr.Tab("
|
|
|
|
| 36 |
aspect = gr.inputs.Radio(label="Aspect Ratio", choices=["Square", "Horizontal", "Vertical"],default="Square")
|
| 37 |
model = gr.inputs.Dropdown(label="Model", choices=["Surrealism","Realism", "Emoji"], default="Surrealism")
|
| 38 |
get_image_rudalle = gr.Button("Generate Image")
|
| 39 |
-
with gr.Tab("
|
|
|
|
| 40 |
get_image_guided = gr.Button("Generate Image")
|
| 41 |
get_image = gr.Button("Generate Image")
|
| 42 |
with gr.Column():
|
| 43 |
with gr.Row():
|
| 44 |
image = gr.outputs.Image()
|
| 45 |
-
|
| 46 |
get_image_latent.click(text2image_latent, inputs=[text,steps,width,height,images,diversity], outputs=image)
|
| 47 |
get_image_rudalle.click(text2image_rudalle, inputs=[text,aspect,model], outputs=image)
|
| 48 |
get_image_guided.click(text2image_guided, inputs=text, outputs=image)
|
|
|
|
| 8 |
print(rudalle)
|
| 9 |
guided = gr.Interface.load("spaces/EleutherAI/clip-guided-diffusion")
|
| 10 |
print(guided)
|
| 11 |
+
def text2image_latent(which_tab,text,steps,width,height,images,diversity):
|
| 12 |
+
print(which_tab)
|
| 13 |
image = latent(text, steps, width, height, images, diversity)[0]
|
| 14 |
+
|
| 15 |
return(image)
|
| 16 |
|
| 17 |
def text2image_rudalle(text,aspect,model):
|
|
|
|
| 19 |
print(image)
|
| 20 |
return(image)
|
| 21 |
|
| 22 |
+
|
| 23 |
def text2image_guided(text):
|
| 24 |
+
image = guided(text,'',10,600,0,0,0,random.randint(0,2147483647),'',50,32)
|
| 25 |
+
print(image)
|
| 26 |
+
image = image[0]
|
| 27 |
return(image)
|
| 28 |
|
| 29 |
block = gr.Blocks()
|
| 30 |
|
| 31 |
with block:
|
| 32 |
text = gr.inputs.Textbox(placeholder="Try writing something..")
|
| 33 |
+
which_tab = "Latent Diffusion"
|
| 34 |
+
with gr.Tab("latent"):
|
| 35 |
+
which_tab = "Latent Diffusion"
|
| 36 |
steps = gr.inputs.Slider(label="Steps - more steps can increase quality but will take longer to generate",default=45,maximum=50,minimum=1,step=1)
|
| 37 |
width = gr.inputs.Radio(label="Width", choices=[32,64,128,256],default=256)
|
| 38 |
height = gr.inputs.Radio(label="Height", choices=[32,64,128,256],default=256)
|
| 39 |
images = gr.inputs.Slider(label="Images - How many images you wish to generate", default=2, step=1, minimum=1, maximum=4)
|
| 40 |
diversity = gr.inputs.Slider(label="Diversity scale - How different from one another you wish the images to be",default=5.0, minimum=1.0, maximum=15.0)
|
| 41 |
get_image_latent = gr.Button("Generate Image")
|
| 42 |
+
with gr.Tab("rudalle"):
|
| 43 |
+
which_tab = "ruDALLE"
|
| 44 |
aspect = gr.inputs.Radio(label="Aspect Ratio", choices=["Square", "Horizontal", "Vertical"],default="Square")
|
| 45 |
model = gr.inputs.Dropdown(label="Model", choices=["Surrealism","Realism", "Emoji"], default="Surrealism")
|
| 46 |
get_image_rudalle = gr.Button("Generate Image")
|
| 47 |
+
with gr.Tab("guided"):
|
| 48 |
+
which_tab = "Guided Diffusion"
|
| 49 |
get_image_guided = gr.Button("Generate Image")
|
| 50 |
get_image = gr.Button("Generate Image")
|
| 51 |
with gr.Column():
|
| 52 |
with gr.Row():
|
| 53 |
image = gr.outputs.Image()
|
| 54 |
+
print(which_tab)
|
| 55 |
get_image_latent.click(text2image_latent, inputs=[text,steps,width,height,images,diversity], outputs=image)
|
| 56 |
get_image_rudalle.click(text2image_rudalle, inputs=[text,aspect,model], outputs=image)
|
| 57 |
get_image_guided.click(text2image_guided, inputs=text, outputs=image)
|