Spaces:
Runtime error
Runtime error
Commit
·
63212f4
1
Parent(s):
da25700
Update app.py
Browse files
app.py
CHANGED
|
@@ -19,16 +19,17 @@ login(token=os.environ.get('HF_KEY'))
|
|
| 19 |
# font=[gr.themes.GoogleFont("Open Sans"), "ui-sans-serif", "system-ui", "sans-serif"],
|
| 20 |
# )
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
def infer(prompt):
|
| 23 |
-
|
| 24 |
-
pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16, variant="fp16", use_safetensors=True)
|
| 25 |
-
pipe = pipe.to(device)
|
| 26 |
-
pipe.enable_xformers_memory_efficient_attention()
|
| 27 |
-
torch.cuda.empty_cache()
|
| 28 |
-
generator = torch.Generator(device=device).manual_seed(seed)
|
| 29 |
-
int_image = pipe(prompt, negative_prompt=negative_prompt, num_inference_steps=steps, height=height, width=width, guidance_scale=scale, num_images_per_prompt=1, generator=generator).images
|
| 30 |
torch.cuda.empty_cache()
|
| 31 |
-
|
| 32 |
return int_image
|
| 33 |
|
| 34 |
css = """
|
|
|
|
| 19 |
# font=[gr.themes.GoogleFont("Open Sans"), "ui-sans-serif", "system-ui", "sans-serif"],
|
| 20 |
# )
|
| 21 |
|
| 22 |
+
device = 'cpu'
|
| 23 |
+
torch.cuda.max_memory_allocated(device='cpu')
|
| 24 |
+
pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16, variant="fp16", use_safetensors=True)
|
| 25 |
+
pipe = pipe.to(device)
|
| 26 |
+
pipe.enable_xformers_memory_efficient_attention()
|
| 27 |
+
torch.cuda.empty_cache()
|
| 28 |
+
generator = torch.Generator(device=device).manual_seed(seed)
|
| 29 |
+
|
| 30 |
def infer(prompt):
|
| 31 |
+
int_image = pipe(prompt,num_images_per_prompt=1, generator=generator).images
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
torch.cuda.empty_cache()
|
|
|
|
| 33 |
return int_image
|
| 34 |
|
| 35 |
css = """
|