Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -59,14 +59,14 @@ if is_colab:
|
|
59 |
|
60 |
else: # download all models
|
61 |
vae = AutoencoderKL.from_pretrained(current_model.path, subfolder="vae", torch_dtype=torch.float16)
|
62 |
-
for model in models
|
63 |
try:
|
64 |
unet = UNet2DConditionModel.from_pretrained(model.path, subfolder="unet", torch_dtype=torch.float16)
|
65 |
model.pipe_t2i = StableDiffusionPipeline.from_pretrained(model.path, unet=unet, vae=vae, torch_dtype=torch.float16, scheduler=scheduler)
|
66 |
model.pipe_i2i = StableDiffusionImg2ImgPipeline.from_pretrained(model.path, unet=unet, vae=vae, torch_dtype=torch.float16, scheduler=scheduler)
|
67 |
except:
|
68 |
models.remove(model)
|
69 |
-
pipe = models[
|
70 |
|
71 |
if torch.cuda.is_available():
|
72 |
pipe = pipe.to("cuda")
|
@@ -165,7 +165,7 @@ def replace_nsfw_images(results):
|
|
165 |
results.images[i] = Image.open("nsfw.png")
|
166 |
return results.images[0]
|
167 |
|
168 |
-
css = """.finetuned-diffusion-div div{display:inline-flex;align-items:center;gap:.8rem;font-size:1.75rem}.finetuned-diffusion-div div h1{font-weight:900;margin-bottom:7px}.finetuned-diffusion-div p{margin-bottom:10px;font-size:94%}
|
169 |
"""
|
170 |
with gr.Blocks(css=css) as demo:
|
171 |
gr.HTML(
|
@@ -225,8 +225,8 @@ with gr.Blocks(css=css) as demo:
|
|
225 |
image = gr.Image(label="Image", height=256, tool="editor", type="pil")
|
226 |
strength = gr.Slider(label="Transformation strength", minimum=0, maximum=1, step=0.01, value=0.5)
|
227 |
|
228 |
-
model_name.change(lambda x: gr.update(visible = x == models[0].name), inputs=model_name, outputs=custom_model_group)
|
229 |
if is_colab:
|
|
|
230 |
custom_model_path.change(custom_model_changed, inputs=custom_model_path, outputs=None)
|
231 |
# n_images.change(lambda n: gr.Gallery().style(grid=[2 if n > 1 else 1], height="auto"), inputs=n_images, outputs=gallery)
|
232 |
|
@@ -244,7 +244,7 @@ with gr.Blocks(css=css) as demo:
|
|
244 |
|
245 |
gr.HTML("""
|
246 |
<p>Models by <a href="https://huggingface.co/nitrosocke">@nitrosocke</a>, <a href="https://twitter.com/haruu1367">@haruu1367</a>, <a href="https://twitter.com/DGSpitzer">@Helixngc7293</a>, <a href="https://twitter.com/dal_mack">@dal_mack</a>, <a href="https://twitter.com/prompthero">@prompthero</a> and others. ❤️</p>
|
247 |
-
<p>Space by: <a href="https://twitter.com/hahahahohohe"><img src="https://img.shields.io/twitter/follow/hahahahohohe?label=%40anzorq&style=social" alt="Twitter Follow"></a></p>
|
248 |
<p><img src="https://visitor-badge.glitch.me/badge?page_id=anzorq.finetuned_diffusion" alt="visitors"></p>
|
249 |
""")
|
250 |
|
|
|
59 |
|
60 |
else: # download all models
|
61 |
vae = AutoencoderKL.from_pretrained(current_model.path, subfolder="vae", torch_dtype=torch.float16)
|
62 |
+
for model in models:
|
63 |
try:
|
64 |
unet = UNet2DConditionModel.from_pretrained(model.path, subfolder="unet", torch_dtype=torch.float16)
|
65 |
model.pipe_t2i = StableDiffusionPipeline.from_pretrained(model.path, unet=unet, vae=vae, torch_dtype=torch.float16, scheduler=scheduler)
|
66 |
model.pipe_i2i = StableDiffusionImg2ImgPipeline.from_pretrained(model.path, unet=unet, vae=vae, torch_dtype=torch.float16, scheduler=scheduler)
|
67 |
except:
|
68 |
models.remove(model)
|
69 |
+
pipe = models[0].pipe_t2i
|
70 |
|
71 |
if torch.cuda.is_available():
|
72 |
pipe = pipe.to("cuda")
|
|
|
165 |
results.images[i] = Image.open("nsfw.png")
|
166 |
return results.images[0]
|
167 |
|
168 |
+
css = """.finetuned-diffusion-div div{display:inline-flex;align-items:center;gap:.8rem;font-size:1.75rem}.finetuned-diffusion-div div h1{font-weight:900;margin-bottom:7px}.finetuned-diffusion-div p{margin-bottom:10px;font-size:94%}a{text-decoration:underline}.tabs{margin-top:0;margin-bottom:0}#gallery{min-height:20rem}
|
169 |
"""
|
170 |
with gr.Blocks(css=css) as demo:
|
171 |
gr.HTML(
|
|
|
225 |
image = gr.Image(label="Image", height=256, tool="editor", type="pil")
|
226 |
strength = gr.Slider(label="Transformation strength", minimum=0, maximum=1, step=0.01, value=0.5)
|
227 |
|
|
|
228 |
if is_colab:
|
229 |
+
model_name.change(lambda x: gr.update(visible = x == models[0].name), inputs=model_name, outputs=custom_model_group)
|
230 |
custom_model_path.change(custom_model_changed, inputs=custom_model_path, outputs=None)
|
231 |
# n_images.change(lambda n: gr.Gallery().style(grid=[2 if n > 1 else 1], height="auto"), inputs=n_images, outputs=gallery)
|
232 |
|
|
|
244 |
|
245 |
gr.HTML("""
|
246 |
<p>Models by <a href="https://huggingface.co/nitrosocke">@nitrosocke</a>, <a href="https://twitter.com/haruu1367">@haruu1367</a>, <a href="https://twitter.com/DGSpitzer">@Helixngc7293</a>, <a href="https://twitter.com/dal_mack">@dal_mack</a>, <a href="https://twitter.com/prompthero">@prompthero</a> and others. ❤️</p>
|
247 |
+
<p>Space by: <a href="https://twitter.com/hahahahohohe"><img src="https://img.shields.io/twitter/follow/hahahahohohe?label=%40anzorq&style=social" alt="Twitter Follow"></a></p><br>
|
248 |
<p><img src="https://visitor-badge.glitch.me/badge?page_id=anzorq.finetuned_diffusion" alt="visitors"></p>
|
249 |
""")
|
250 |
|