Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -40,8 +40,9 @@ def randomize_seed_fn(seed: int, randomize_seed: bool) -> int:
|
|
| 40 |
|
| 41 |
from diffusers import DiffusionPipeline
|
| 42 |
|
|
|
|
| 43 |
base_model = "black-forest-labs/FLUX.1-dev"
|
| 44 |
-
pipe = DiffusionPipeline.from_pretrained(base_model, torch_dtype=torch.
|
| 45 |
lora_repo = "strangerzonehf/Flux-Super-Realism-LoRA"
|
| 46 |
trigger_word = "Super Realism" # Leave blank if no trigger word is needed.
|
| 47 |
pipe.load_lora_weights(lora_repo)
|
|
@@ -89,6 +90,8 @@ def generate_image_flux(
|
|
| 89 |
positive_prompt = apply_style(style_name, prompt)
|
| 90 |
if trigger_word:
|
| 91 |
positive_prompt = f"{trigger_word} {positive_prompt}"
|
|
|
|
|
|
|
| 92 |
images = pipe(
|
| 93 |
prompt=positive_prompt,
|
| 94 |
width=width,
|
|
|
|
| 40 |
|
| 41 |
from diffusers import DiffusionPipeline
|
| 42 |
|
| 43 |
+
# Use torch.float16 for better stability on NVIDIA GPUs
|
| 44 |
base_model = "black-forest-labs/FLUX.1-dev"
|
| 45 |
+
pipe = DiffusionPipeline.from_pretrained(base_model, torch_dtype=torch.float16)
|
| 46 |
lora_repo = "strangerzonehf/Flux-Super-Realism-LoRA"
|
| 47 |
trigger_word = "Super Realism" # Leave blank if no trigger word is needed.
|
| 48 |
pipe.load_lora_weights(lora_repo)
|
|
|
|
| 90 |
positive_prompt = apply_style(style_name, prompt)
|
| 91 |
if trigger_word:
|
| 92 |
positive_prompt = f"{trigger_word} {positive_prompt}"
|
| 93 |
+
# Clear GPU cache before generating to help avoid memory fragmentation errors.
|
| 94 |
+
torch.cuda.empty_cache()
|
| 95 |
images = pipe(
|
| 96 |
prompt=positive_prompt,
|
| 97 |
width=width,
|