apolinario
commited on
Merge branch 'main' of https://huggingface.co/spaces/multimodalart/mindseye
Browse files
README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
---
|
2 |
-
title: MindsEye
|
3 |
emoji: 💻
|
4 |
colorFrom: pink
|
5 |
colorTo: yellow
|
|
|
1 |
---
|
2 |
+
title: MindsEye Lite
|
3 |
emoji: 💻
|
4 |
colorFrom: pink
|
5 |
colorTo: yellow
|
app.py
CHANGED
@@ -21,7 +21,6 @@ def text2image_latent(text,steps,width,height,images,diversity):
|
|
21 |
image_str = image_str.replace("data:image/png;base64,","")
|
22 |
decoded_bytes = base64.decodebytes(bytes(image_str, "utf-8"))
|
23 |
img = Image.open(io.BytesIO(decoded_bytes))
|
24 |
-
#image_arrays.append(numpy.asarray(img))
|
25 |
url = shortuuid.uuid()
|
26 |
temp_dir = './tmp'
|
27 |
if not os.path.exists(temp_dir):
|
@@ -39,16 +38,15 @@ def text2image_vqgan(text,width,height,style,steps,flavor):
|
|
39 |
results = vqgan(text,width,height,style,steps,flavor)
|
40 |
return([results])
|
41 |
|
42 |
-
def text2image_diffusion(steps_diff, images_diff, weight, clip):
|
43 |
-
results = diffusion(steps_diff, images_diff, weight, clip)
|
44 |
image_paths = []
|
45 |
image_arrays = []
|
46 |
for image in results:
|
47 |
-
image_str = image
|
48 |
image_str = image_str.replace("data:image/png;base64,","")
|
49 |
decoded_bytes = base64.decodebytes(bytes(image_str, "utf-8"))
|
50 |
img = Image.open(io.BytesIO(decoded_bytes))
|
51 |
-
#image_arrays.append(numpy.asarray(img))
|
52 |
url = shortuuid.uuid()
|
53 |
temp_dir = './tmp'
|
54 |
if not os.path.exists(temp_dir):
|
@@ -87,16 +85,16 @@ with gr.Blocks() as mindseye:
|
|
87 |
width_vq = gr.inputs.Slider(label="Width", default=256, minimum=32, step=32, maximum=512)
|
88 |
height_vq= gr.inputs.Slider(label="Height", default=256, minimum=32, step=32, maximum=512)
|
89 |
style = gr.inputs.Dropdown(label="Style - Hyper Fast Results is fast but compromises a bit of the quality",choices=["Default","Balanced","Detailed","Consistent Creativity","Realistic","Smooth","Subtle MSE","Hyper Fast Results"],default="Hyper Fast Results")
|
90 |
-
|
91 |
flavor = gr.inputs.Dropdown(label="Flavor - pick a flavor for the style of the images, based on the images below",choices=["ginger", "cumin", "holywater", "zynth", "wyvern", "aaron", "moth", "juu"])
|
92 |
-
get_image_vqgan = gr.
|
93 |
with gr.TabItem("Guided Diffusion"):
|
94 |
gr.Markdown("Guided Diffusion models produce superb quality results. V-Diffusion is its latest implementation")
|
95 |
steps_diff = gr.inputs.Slider(label="Steps - more steps can increase quality but will take longer to generate",default=40,maximum=80,minimum=1,step=1)
|
96 |
images_diff = gr.inputs.Slider(label="Number of images in parallel", default=2, maximum=4, minimum=1, step=1)
|
97 |
weight = gr.inputs.Slider(label="Weight - how closely the image should resemble the prompt", default=5, maximum=15, minimum=0, step=1)
|
98 |
clip = gr.inputs.Checkbox(label="CLIP Guided - improves coherence with complex prompts, makes it slower")
|
99 |
-
get_image_diffusion = gr.
|
100 |
with gr.Row():
|
101 |
with gr.Tabs():
|
102 |
#with gr.TabItem("Image output"):
|
@@ -106,6 +104,6 @@ with gr.Blocks() as mindseye:
|
|
106 |
|
107 |
get_image_latent.click(text2image_latent, inputs=[text,steps,width,height,images,diversity], outputs=gallery)
|
108 |
get_image_rudalle.click(text2image_rudalle, inputs=[text,aspect,model], outputs=gallery)
|
109 |
-
get_image_vqgan.click(text2image_vqgan, inputs=[text,width_vq,height_vq,style,
|
110 |
-
get_image_diffusion.click(text2image_diffusion, inputs=[steps_diff, images_diff, weight, clip],outputs=gallery)
|
111 |
mindseye.launch()
|
|
|
21 |
image_str = image_str.replace("data:image/png;base64,","")
|
22 |
decoded_bytes = base64.decodebytes(bytes(image_str, "utf-8"))
|
23 |
img = Image.open(io.BytesIO(decoded_bytes))
|
|
|
24 |
url = shortuuid.uuid()
|
25 |
temp_dir = './tmp'
|
26 |
if not os.path.exists(temp_dir):
|
|
|
38 |
results = vqgan(text,width,height,style,steps,flavor)
|
39 |
return([results])
|
40 |
|
41 |
+
def text2image_diffusion(text,steps_diff, images_diff, weight, clip):
|
42 |
+
results = diffusion(text, steps_diff, images_diff, weight, clip)
|
43 |
image_paths = []
|
44 |
image_arrays = []
|
45 |
for image in results:
|
46 |
+
image_str = image
|
47 |
image_str = image_str.replace("data:image/png;base64,","")
|
48 |
decoded_bytes = base64.decodebytes(bytes(image_str, "utf-8"))
|
49 |
img = Image.open(io.BytesIO(decoded_bytes))
|
|
|
50 |
url = shortuuid.uuid()
|
51 |
temp_dir = './tmp'
|
52 |
if not os.path.exists(temp_dir):
|
|
|
85 |
width_vq = gr.inputs.Slider(label="Width", default=256, minimum=32, step=32, maximum=512)
|
86 |
height_vq= gr.inputs.Slider(label="Height", default=256, minimum=32, step=32, maximum=512)
|
87 |
style = gr.inputs.Dropdown(label="Style - Hyper Fast Results is fast but compromises a bit of the quality",choices=["Default","Balanced","Detailed","Consistent Creativity","Realistic","Smooth","Subtle MSE","Hyper Fast Results"],default="Hyper Fast Results")
|
88 |
+
steps_vq = gr.inputs.Slider(label="Steps - more steps can increase quality but will take longer to generate. All styles that are not Hyper Fast need at least 200 steps",default=50,maximum=300,minimum=1,step=1)
|
89 |
flavor = gr.inputs.Dropdown(label="Flavor - pick a flavor for the style of the images, based on the images below",choices=["ginger", "cumin", "holywater", "zynth", "wyvern", "aaron", "moth", "juu"])
|
90 |
+
get_image_vqgan = gr.Button("Generate Image",css=css_mt)
|
91 |
with gr.TabItem("Guided Diffusion"):
|
92 |
gr.Markdown("Guided Diffusion models produce superb quality results. V-Diffusion is its latest implementation")
|
93 |
steps_diff = gr.inputs.Slider(label="Steps - more steps can increase quality but will take longer to generate",default=40,maximum=80,minimum=1,step=1)
|
94 |
images_diff = gr.inputs.Slider(label="Number of images in parallel", default=2, maximum=4, minimum=1, step=1)
|
95 |
weight = gr.inputs.Slider(label="Weight - how closely the image should resemble the prompt", default=5, maximum=15, minimum=0, step=1)
|
96 |
clip = gr.inputs.Checkbox(label="CLIP Guided - improves coherence with complex prompts, makes it slower")
|
97 |
+
get_image_diffusion = gr.Button("Generate Image",css=css_mt)
|
98 |
with gr.Row():
|
99 |
with gr.Tabs():
|
100 |
#with gr.TabItem("Image output"):
|
|
|
104 |
|
105 |
get_image_latent.click(text2image_latent, inputs=[text,steps,width,height,images,diversity], outputs=gallery)
|
106 |
get_image_rudalle.click(text2image_rudalle, inputs=[text,aspect,model], outputs=gallery)
|
107 |
+
get_image_vqgan.click(text2image_vqgan, inputs=[text,width_vq,height_vq,style,steps_vq,flavor],outputs=gallery)
|
108 |
+
get_image_diffusion.click(text2image_diffusion, inputs=[text, steps_diff, images_diff, weight, clip],outputs=gallery)
|
109 |
mindseye.launch()
|