Spaces:
Running
on
Zero
Running
on
Zero
chore: remove torch compile
Browse files- diffusion.py +29 -38
diffusion.py
CHANGED
@@ -74,37 +74,6 @@ def image_generation_config_ui():
|
|
74 |
]
|
75 |
|
76 |
|
77 |
-
@spaces.GPU(duration=30)
|
78 |
-
def generate(
|
79 |
-
pipe,
|
80 |
-
prompt: str,
|
81 |
-
image_size: str = "768x1344",
|
82 |
-
quality_tags: str = QUALITY_TAGS["default"], # Light v3.1
|
83 |
-
negative_prompt: str = NEGATIVE_PROMPT["default"], # Light v3.1
|
84 |
-
num_inference_steps: int = 25,
|
85 |
-
guidance_scale: float = 7.0,
|
86 |
-
) -> Image.Image:
|
87 |
-
width, height = IMAGE_SIZES[image_size]
|
88 |
-
|
89 |
-
prompt = ", ".join([prompt, quality_tags])
|
90 |
-
|
91 |
-
print("prompt", prompt)
|
92 |
-
print("negative_prompt", negative_prompt)
|
93 |
-
print("height", height)
|
94 |
-
print("width", width)
|
95 |
-
print("num_inference_steps", num_inference_steps)
|
96 |
-
print("guidance_scale", guidance_scale)
|
97 |
-
|
98 |
-
return pipe(
|
99 |
-
prompt=prompt,
|
100 |
-
negative_prompt=negative_prompt,
|
101 |
-
height=height,
|
102 |
-
width=width,
|
103 |
-
num_inference_steps=num_inference_steps,
|
104 |
-
guidance_scale=guidance_scale,
|
105 |
-
).images
|
106 |
-
|
107 |
-
|
108 |
class ImageGenerator:
|
109 |
pipe: StableDiffusionXLPipeline
|
110 |
|
@@ -126,10 +95,32 @@ class ImageGenerator:
|
|
126 |
|
127 |
self.pipe.to(device)
|
128 |
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
]
|
75 |
|
76 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
class ImageGenerator:
|
78 |
pipe: StableDiffusionXLPipeline
|
79 |
|
|
|
95 |
|
96 |
self.pipe.to(device)
|
97 |
|
98 |
+
@spaces.GPU(duration=30)
|
99 |
+
def generate(
|
100 |
+
self,
|
101 |
+
prompt: str,
|
102 |
+
image_size: str = "768x1344",
|
103 |
+
quality_tags: str = QUALITY_TAGS["default"], # Light v3.1
|
104 |
+
negative_prompt: str = NEGATIVE_PROMPT["default"], # Light v3.1
|
105 |
+
num_inference_steps: int = 25,
|
106 |
+
guidance_scale: float = 7.0,
|
107 |
+
) -> Image.Image:
|
108 |
+
width, height = IMAGE_SIZES[image_size]
|
109 |
+
|
110 |
+
prompt = ", ".join([prompt, quality_tags])
|
111 |
+
|
112 |
+
print("prompt", prompt)
|
113 |
+
print("negative_prompt", negative_prompt)
|
114 |
+
print("height", height)
|
115 |
+
print("width", width)
|
116 |
+
print("num_inference_steps", num_inference_steps)
|
117 |
+
print("guidance_scale", guidance_scale)
|
118 |
+
|
119 |
+
return self.pipe(
|
120 |
+
prompt=prompt,
|
121 |
+
negative_prompt=negative_prompt,
|
122 |
+
height=height,
|
123 |
+
width=width,
|
124 |
+
num_inference_steps=num_inference_steps,
|
125 |
+
guidance_scale=guidance_scale,
|
126 |
+
).images
|