Spaces:
Sleeping
Sleeping
update
Browse files
app.py
CHANGED
|
@@ -6,14 +6,18 @@ import torch
|
|
| 6 |
|
| 7 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 8 |
|
|
|
|
|
|
|
| 9 |
if torch.cuda.is_available():
|
| 10 |
torch.cuda.max_memory_allocated(device=device)
|
| 11 |
-
pipe = DiffusionPipeline.from_pretrained(
|
| 12 |
pipe.enable_xformers_memory_efficient_attention()
|
| 13 |
pipe = pipe.to(device)
|
|
|
|
| 14 |
else:
|
| 15 |
-
pipe = DiffusionPipeline.from_pretrained(
|
| 16 |
pipe = pipe.to(device)
|
|
|
|
| 17 |
|
| 18 |
MAX_SEED = np.iinfo(np.int32).max
|
| 19 |
MAX_IMAGE_SIZE = 1024
|
|
@@ -38,9 +42,9 @@ def infer(prompt, negative_prompt, seed, randomize_seed, width, height, guidance
|
|
| 38 |
return image
|
| 39 |
|
| 40 |
examples = [
|
| 41 |
-
"
|
| 42 |
-
"
|
| 43 |
-
"A
|
| 44 |
]
|
| 45 |
|
| 46 |
css="""
|
|
@@ -59,7 +63,7 @@ with gr.Blocks(css=css) as demo:
|
|
| 59 |
|
| 60 |
with gr.Column(elem_id="col-container"):
|
| 61 |
gr.Markdown(f"""
|
| 62 |
-
#
|
| 63 |
Currently running on {power_device}.
|
| 64 |
""")
|
| 65 |
|
|
|
|
| 6 |
|
| 7 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 8 |
|
| 9 |
+
base_model = "stabilityai/stable-diffusion-xl-base-1.0"
|
| 10 |
+
|
| 11 |
if torch.cuda.is_available():
|
| 12 |
torch.cuda.max_memory_allocated(device=device)
|
| 13 |
+
pipe = DiffusionPipeline.from_pretrained(base_model, torch_dtype=torch.float16, variant="fp16", use_safetensors=True)
|
| 14 |
pipe.enable_xformers_memory_efficient_attention()
|
| 15 |
pipe = pipe.to(device)
|
| 16 |
+
pipe.load_lora_weights("Fer14/sdxl-coffe-machines", weights_name ="pytorch_lora_weights.safetensors")
|
| 17 |
else:
|
| 18 |
+
pipe = DiffusionPipeline.from_pretrained(base_model, use_safetensors=True)
|
| 19 |
pipe = pipe.to(device)
|
| 20 |
+
pipe.load_lora_weights("Fer14/sdxl-coffe-machines", weights_name ="pytorch_lora_weights.safetensors")
|
| 21 |
|
| 22 |
MAX_SEED = np.iinfo(np.int32).max
|
| 23 |
MAX_IMAGE_SIZE = 1024
|
|
|
|
| 42 |
return image
|
| 43 |
|
| 44 |
examples = [
|
| 45 |
+
"A cream espresso machine with steam wand for milk frothing, retro-shaped, with no screen and three silver buttons",
|
| 46 |
+
"A beige espresso coffee machine with a wooden handle, rectangular shaped, with no screen and three silver buttons",
|
| 47 |
+
"A red espresso coffee machine with portafilter handle and milk frother, cylindrical shaped, with no screen and three silver buttons",
|
| 48 |
]
|
| 49 |
|
| 50 |
css="""
|
|
|
|
| 63 |
|
| 64 |
with gr.Column(elem_id="col-container"):
|
| 65 |
gr.Markdown(f"""
|
| 66 |
+
# Coffee Machine Generator ☕
|
| 67 |
Currently running on {power_device}.
|
| 68 |
""")
|
| 69 |
|