Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,14 +8,11 @@ import torch
|
|
| 8 |
ldm_pipeline = LatentDiffusionPipeline.from_pretrained("CompVis/ldm-text2im-large-256")
|
| 9 |
images = []
|
| 10 |
|
| 11 |
-
def predict(prompt, steps=100, seed=42, guidance_scale=
|
| 12 |
torch.cuda.empty_cache()
|
| 13 |
generator = torch.manual_seed(seed)
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
image_processed = (image_processed + 1.0) * 127.5
|
| 17 |
-
image_processed = image_processed.clamp(0, 255).numpy().astype(np.uint8)
|
| 18 |
-
return PIL.Image.fromarray(image_processed[0])
|
| 19 |
|
| 20 |
random_seed = random.randint(0, 2147483647)
|
| 21 |
gr.Interface(
|
|
@@ -24,7 +21,7 @@ gr.Interface(
|
|
| 24 |
gr.inputs.Textbox(label='Prompt', default='a chalk pastel drawing of a llama wearing a wizard hat'),
|
| 25 |
gr.inputs.Slider(1, 100, label='Inference Steps', default=50, step=1),
|
| 26 |
gr.inputs.Slider(0, 2147483647, label='Seed', default=random_seed, step=1),
|
| 27 |
-
gr.inputs.Slider(1.0, 20.0, label='Guidance Scale - how much the prompt will influence the results', default=
|
| 28 |
],
|
| 29 |
outputs=gr.Image(shape=[256,256], type="pil", elem_id="output_image"),
|
| 30 |
css="#output_image{width: 256px}",
|
|
|
|
| 8 |
ldm_pipeline = LatentDiffusionPipeline.from_pretrained("CompVis/ldm-text2im-large-256")
|
| 9 |
images = []
|
| 10 |
|
| 11 |
+
def predict(prompt, steps=100, seed=42, guidance_scale=6.0):
|
| 12 |
torch.cuda.empty_cache()
|
| 13 |
generator = torch.manual_seed(seed)
|
| 14 |
+
images = ldm_pipeline([prompt], generator=generator, num_inference_steps=steps, eta=0.3, guidance_scale=guidance_scale)
|
| 15 |
+
return images[0]
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
random_seed = random.randint(0, 2147483647)
|
| 18 |
gr.Interface(
|
|
|
|
| 21 |
gr.inputs.Textbox(label='Prompt', default='a chalk pastel drawing of a llama wearing a wizard hat'),
|
| 22 |
gr.inputs.Slider(1, 100, label='Inference Steps', default=50, step=1),
|
| 23 |
gr.inputs.Slider(0, 2147483647, label='Seed', default=random_seed, step=1),
|
| 24 |
+
gr.inputs.Slider(1.0, 20.0, label='Guidance Scale - how much the prompt will influence the results', default=6.0, step=0.1),
|
| 25 |
],
|
| 26 |
outputs=gr.Image(shape=[256,256], type="pil", elem_id="output_image"),
|
| 27 |
css="#output_image{width: 256px}",
|