Spaces:
Runtime error
Runtime error
code update
Browse files
app.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
from base64 import b64encode
|
2 |
-
|
3 |
import numpy as np
|
4 |
import torch
|
5 |
from diffusers import AutoencoderKL, LMSDiscreteScheduler, UNet2DConditionModel
|
@@ -247,7 +247,7 @@ def image_generator(prompt = "dog", loss_function=None):
|
|
247 |
seed_values = [8,16,50,80,128]
|
248 |
height = 512 # default height of Stable Diffusion
|
249 |
width = 512 # default width of Stable Diffusion
|
250 |
-
num_inference_steps =
|
251 |
guidance_scale = 7.5 # Scale for classifier-free guidance
|
252 |
num_styles = len(style_files)
|
253 |
|
@@ -269,3 +269,21 @@ def image_generator(prompt = "dog", loss_function=None):
|
|
269 |
|
270 |
return display_images_in_rows(generated_sd_images, titles)
|
271 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
from base64 import b64encode
|
2 |
+
import gradio as gr
|
3 |
import numpy as np
|
4 |
import torch
|
5 |
from diffusers import AutoencoderKL, LMSDiscreteScheduler, UNet2DConditionModel
|
|
|
247 |
seed_values = [8,16,50,80,128]
|
248 |
height = 512 # default height of Stable Diffusion
|
249 |
width = 512 # default width of Stable Diffusion
|
250 |
+
num_inference_steps = 1 # Number of denoising steps
|
251 |
guidance_scale = 7.5 # Scale for classifier-free guidance
|
252 |
num_styles = len(style_files)
|
253 |
|
|
|
269 |
|
270 |
return display_images_in_rows(generated_sd_images, titles)
|
271 |
|
272 |
+
|
273 |
+
# Create a wrapper function for show_misclassified_images()
|
274 |
+
def image_generator_wrapper(prompt = "dog", loss_function=None):
|
275 |
+
prompt = string(prompt)
|
276 |
+
if loss_function == "Yes":
|
277 |
+
loss_function = vibrance_loss
|
278 |
+
else:
|
279 |
+
loss_function = None
|
280 |
+
|
281 |
+
return image_generator(prompt, loss_function)
|
282 |
+
|
283 |
+
description = "Generate an image with a prompt and apply loss if you wish to"
|
284 |
+
|
285 |
+
demo = gr.Interface(image_generator_wrapper,
|
286 |
+
inputs=[gr.Textbox(label="Enter prompt for generating", type="str", default="dog sitting on a bench"),
|
287 |
+
gr.Radio(["Yes", "No"], value="No" , label="Apply vibrance loss")],
|
288 |
+
outputs=gr.Plot(), title = "Stable Diffusion", description=description)
|
289 |
+
demo.launch()
|