Spaces:
Sleeping
Sleeping
Commit
•
aad2ddd
1
Parent(s):
d857e4f
Update app.py
Browse files
app.py
CHANGED
@@ -16,7 +16,6 @@ with open('loras.json', 'r') as f:
|
|
16 |
# Initialize the base model
|
17 |
base_model = "black-forest-labs/FLUX.1-dev"
|
18 |
pipe = DiffusionPipeline.from_pretrained(base_model, torch_dtype=torch.bfloat16)
|
19 |
-
pipe.to("cuda")
|
20 |
|
21 |
MAX_SEED = 2**32-1
|
22 |
|
@@ -50,6 +49,7 @@ def update_selection(evt: gr.SelectData):
|
|
50 |
|
51 |
@spaces.GPU(duration=80)
|
52 |
def generate_image(prompt, trigger_word, steps, seed, cfg_scale, width, height, lora_scale, progress):
|
|
|
53 |
|
54 |
generator = torch.Generator(device="cuda").manual_seed(seed)
|
55 |
|
@@ -87,7 +87,7 @@ def run_lora(prompt, cfg_scale, steps, selected_index, randomize_seed, seed, wid
|
|
87 |
seed = random.randint(0, MAX_SEED)
|
88 |
|
89 |
image = generate_image(prompt, trigger_word, steps, seed, cfg_scale, width, height, lora_scale, progress)
|
90 |
-
|
91 |
pipe.unload_lora_weights()
|
92 |
return image, seed
|
93 |
|
|
|
16 |
# Initialize the base model
|
17 |
base_model = "black-forest-labs/FLUX.1-dev"
|
18 |
pipe = DiffusionPipeline.from_pretrained(base_model, torch_dtype=torch.bfloat16)
|
|
|
19 |
|
20 |
MAX_SEED = 2**32-1
|
21 |
|
|
|
49 |
|
50 |
@spaces.GPU(duration=80)
|
51 |
def generate_image(prompt, trigger_word, steps, seed, cfg_scale, width, height, lora_scale, progress):
|
52 |
+
pipe.to("cuda")
|
53 |
|
54 |
generator = torch.Generator(device="cuda").manual_seed(seed)
|
55 |
|
|
|
87 |
seed = random.randint(0, MAX_SEED)
|
88 |
|
89 |
image = generate_image(prompt, trigger_word, steps, seed, cfg_scale, width, height, lora_scale, progress)
|
90 |
+
pipe.to("cpu")
|
91 |
pipe.unload_lora_weights()
|
92 |
return image, seed
|
93 |
|