Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -187,7 +187,7 @@ class PipelineManager:
|
|
187 |
# Apply memory optimizations to txt2img pipeline
|
188 |
self._optimize_pipeline(self.txt2img_pipe)
|
189 |
|
190 |
-
# Create img2img pipeline sharing components
|
191 |
self.img2img_pipe = StableDiffusionXLImg2ImgPipeline(
|
192 |
vae=self.txt2img_pipe.vae,
|
193 |
text_encoder=self.txt2img_pipe.text_encoder,
|
@@ -196,8 +196,7 @@ class PipelineManager:
|
|
196 |
tokenizer_2=self.txt2img_pipe.tokenizer_2,
|
197 |
unet=self.txt2img_pipe.unet,
|
198 |
scheduler=self.txt2img_pipe.scheduler,
|
199 |
-
safety_checker
|
200 |
-
requires_safety_checker=False
|
201 |
)
|
202 |
|
203 |
# Apply memory optimizations to img2img pipeline
|
@@ -421,7 +420,7 @@ def generate_txt2img(prompt: str, negative_prompt: str, steps: int, guidance_sca
|
|
421 |
logger.error(f"Generation error: {e}")
|
422 |
return None, None, f"❌ Generation failed: {str(e)}"
|
423 |
finally:
|
424 |
-
pipe_manager.clear_memory() # Ensure memory is cleared even if an
|
425 |
|
426 |
@spaces.GPU(duration=120) # Increased duration for model loading and generation
|
427 |
def generate_img2img(input_image: Image.Image, prompt: str, negative_prompt: str,
|
|
|
187 |
# Apply memory optimizations to txt2img pipeline
|
188 |
self._optimize_pipeline(self.txt2img_pipe)
|
189 |
|
190 |
+
# Create img2img pipeline sharing components
|
191 |
self.img2img_pipe = StableDiffusionXLImg2ImgPipeline(
|
192 |
vae=self.txt2img_pipe.vae,
|
193 |
text_encoder=self.txt2img_pipe.text_encoder,
|
|
|
196 |
tokenizer_2=self.txt2img_pipe.tokenizer_2,
|
197 |
unet=self.txt2img_pipe.unet,
|
198 |
scheduler=self.txt2img_pipe.scheduler,
|
199 |
+
# Removed safety_checker and requires_safety_checker as they are not valid for this constructor
|
|
|
200 |
)
|
201 |
|
202 |
# Apply memory optimizations to img2img pipeline
|
|
|
420 |
logger.error(f"Generation error: {e}")
|
421 |
return None, None, f"❌ Generation failed: {str(e)}"
|
422 |
finally:
|
423 |
+
pipe_manager.clear_memory() # Ensure memory is cleared even if an occurs
|
424 |
|
425 |
@spaces.GPU(duration=120) # Increased duration for model loading and generation
|
426 |
def generate_img2img(input_image: Image.Image, prompt: str, negative_prompt: str,
|