Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -5,11 +5,13 @@ import numpy as np
|
|
5 |
import PIL
|
6 |
import cv2
|
7 |
|
|
|
|
|
|
|
8 |
print('\nDEBUG: Version: 3')
|
9 |
|
10 |
#pipeline = LDMTextToImagePipeline.from_pretrained("fusing/latent-diffusion-text2im-large")
|
11 |
-
|
12 |
-
generator = torch.manual_seed(42)
|
13 |
|
14 |
FOOTER = '<img id="visitor-badge" alt="visitor badge" src="https://visitor-badge.glitch.me/badge?page_id=milyiyo.testing-diffusers" />'
|
15 |
|
@@ -31,9 +33,15 @@ def genimage(prompt, iterations):
|
|
31 |
#img = cv2.imread(file_name)
|
32 |
##cv2_imshow(img)
|
33 |
#return img
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
iface = gr.Interface(
|
36 |
-
fn=
|
37 |
inputs=["text", "number"],
|
38 |
outputs=gr.Image(shape=[256,256], type="pil", elem_id="output_image"))
|
39 |
iface.launch()
|
|
|
5 |
import PIL
|
6 |
import cv2
|
7 |
|
8 |
+
import PIL.Image
|
9 |
+
import random
|
10 |
+
|
11 |
print('\nDEBUG: Version: 3')
|
12 |
|
13 |
#pipeline = LDMTextToImagePipeline.from_pretrained("fusing/latent-diffusion-text2im-large")
|
14 |
+
ldm_pipeline = LDMTextToImagePipeline.from_pretrained("CompVis/ldm-text2im-large-256")
|
|
|
15 |
|
16 |
FOOTER = '<img id="visitor-badge" alt="visitor badge" src="https://visitor-badge.glitch.me/badge?page_id=milyiyo.testing-diffusers" />'
|
17 |
|
|
|
33 |
#img = cv2.imread(file_name)
|
34 |
##cv2_imshow(img)
|
35 |
#return img
|
36 |
+
|
37 |
+
def predict(prompt, steps=100):
|
38 |
+
torch.cuda.empty_cache()
|
39 |
+
generator = torch.manual_seed(42)
|
40 |
+
images = ldm_pipeline([prompt], generator=generator, num_inference_steps=steps, eta=0.3, guidance_scale=6.0)["sample"]
|
41 |
+
return images[0]
|
42 |
|
43 |
iface = gr.Interface(
|
44 |
+
fn=predict,
|
45 |
inputs=["text", "number"],
|
46 |
outputs=gr.Image(shape=[256,256], type="pil", elem_id="output_image"))
|
47 |
iface.launch()
|