Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,13 +1,20 @@
|
|
| 1 |
import torch
|
| 2 |
from diffusers import FluxPipeline
|
| 3 |
|
| 4 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
pipe = FluxPipeline.from_pretrained(
|
| 6 |
"black-forest-labs/FLUX.1-dev",
|
| 7 |
torch_dtype=torch.bfloat16,
|
| 8 |
-
load_in_4bit=True
|
| 9 |
-
|
| 10 |
)
|
| 11 |
|
| 12 |
-
#
|
|
|
|
|
|
|
|
|
|
| 13 |
pipe.load_lora_weights("joyfox/Kontext-Cosplay-Lora", weight_name="kontext_cosplay_lora_20000.safetensors")
|
|
|
|
| 1 |
import torch
|
| 2 |
from diffusers import FluxPipeline
|
| 3 |
|
| 4 |
+
# 1. Definir el dispositivo
|
| 5 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 6 |
+
|
| 7 |
+
# 2. Cargar el modelo con cuantizaci贸n (si tienes bitsandbytes instalado)
|
| 8 |
+
# Si sigues teniendo error de memoria, intenta usar "black-forest-labs/FLUX.1-schnell"
|
| 9 |
pipe = FluxPipeline.from_pretrained(
|
| 10 |
"black-forest-labs/FLUX.1-dev",
|
| 11 |
torch_dtype=torch.bfloat16,
|
| 12 |
+
# load_in_4bit=True requiere configuraciones adicionales en diffusers,
|
| 13 |
+
# prueba primero sin 茅l, usando solamente bfloat16 para ahorrar VRAM.
|
| 14 |
)
|
| 15 |
|
| 16 |
+
# 3. Mover el pipeline a la GPU despu茅s de cargarlo
|
| 17 |
+
pipe.to(device)
|
| 18 |
+
|
| 19 |
+
# 4. Cargar el LoRA
|
| 20 |
pipe.load_lora_weights("joyfox/Kontext-Cosplay-Lora", weight_name="kontext_cosplay_lora_20000.safetensors")
|