Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -114,11 +114,48 @@ def plex(qr_code_value, text, neg_prompt, modil, one, two, three):
|
|
114 |
image = pipe([prompt]*2,images,num_inference_steps=one,generator=generator,strength=two,negative_prompt=[neg_prompt]*2,controlnet_conditioning_scale=three,)
|
115 |
for i, imge in enumerate(image["images"]):
|
116 |
apol.append(imge)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
apol.append(original)
|
118 |
apol.append(cannyimage)
|
119 |
apol.append(pannyimage)
|
120 |
return apol
|
121 |
|
122 |
-
iface = gr.Interface(fn=plex, inputs=[gr.Textbox(label="QR Code URL"),gr.Textbox(label="prompt"),gr.Textbox(label="neg prompt"),gr.Dropdown(choices=models, label="some sd models", value=models[0], type="value"), gr.Slider(label="num inference steps", minimum=1, step=1, maximum=5, value=5), gr.Slider(label="prompt strength", minimum=0.01, step=0.01, maximum=0.99, value=0.20), gr.Slider(label="controlnet scale", minimum=0.01, step=0.01, maximum=0.99, value=0.80)], outputs=gr.Gallery(label="out", columns=
|
123 |
iface.queue(max_size=1)
|
124 |
iface.launch(max_threads=1)
|
|
|
114 |
image = pipe([prompt]*2,images,num_inference_steps=one,generator=generator,strength=two,negative_prompt=[neg_prompt]*2,controlnet_conditioning_scale=three,)
|
115 |
for i, imge in enumerate(image["images"]):
|
116 |
apol.append(imge)
|
117 |
+
|
118 |
+
img = load_image(imge)
|
119 |
+
img.save('./image.png', 'PNG')
|
120 |
+
img = img.resize((512, 512))
|
121 |
+
img = img.convert("RGBA")
|
122 |
+
img.save('./image.png', 'PNG')
|
123 |
+
|
124 |
+
iog = load_image(original)
|
125 |
+
iog.save('./imoge.png', 'PNG')
|
126 |
+
iog = iog.resize((512, 512))
|
127 |
+
iog = iog.convert("RGBA")
|
128 |
+
iog.save('./imoge.png', 'PNG')
|
129 |
+
doto = iog.getdata()
|
130 |
+
|
131 |
+
new_data = []
|
132 |
+
for item in doto:
|
133 |
+
if item[0] in list(range(200, 256)):
|
134 |
+
new_data.append((255, 255, 255, 0))
|
135 |
+
else:
|
136 |
+
new_data.append(item)
|
137 |
+
iog.putdata(new_data)
|
138 |
+
iog.save('./image.png', 'PNG')
|
139 |
+
|
140 |
+
pixel_data1 = list(iog.getdata())
|
141 |
+
pixel_data2 = list(img.getdata())
|
142 |
+
|
143 |
+
new_pixel_data = [pixel if pixel[3] > 0 else pixel_data2[i] for i, pixel in enumerate(pixel_data1)]
|
144 |
+
if new_image:
|
145 |
+
new_imoge = Image.new("RGBA", img.size)
|
146 |
+
new_imoge.putdata(new_pixel_data)
|
147 |
+
new_imoge.save('./new_imoge.png', 'PNG')
|
148 |
+
apol.append(new_imoge)
|
149 |
+
else:
|
150 |
+
new_image = Image.new("RGBA", img.size)
|
151 |
+
new_image.putdata(new_pixel_data)
|
152 |
+
new_image.save('./new_image.png', 'PNG')
|
153 |
+
apol.append(new_image)
|
154 |
apol.append(original)
|
155 |
apol.append(cannyimage)
|
156 |
apol.append(pannyimage)
|
157 |
return apol
|
158 |
|
159 |
+
iface = gr.Interface(fn=plex, inputs=[gr.Textbox(label="QR Code URL"),gr.Textbox(label="prompt"),gr.Textbox(label="neg prompt"),gr.Dropdown(choices=models, label="some sd models", value=models[0], type="value"), gr.Slider(label="num inference steps", minimum=1, step=1, maximum=5, value=5), gr.Slider(label="prompt strength", minimum=0.01, step=0.01, maximum=0.99, value=0.20), gr.Slider(label="controlnet scale", minimum=0.01, step=0.01, maximum=0.99, value=0.80)], outputs=gr.Gallery(label="out", columns=2),description="Running on cpu, very slow! by JoPmt.")
|
160 |
iface.queue(max_size=1)
|
161 |
iface.launch(max_threads=1)
|