appinitdev commited on
Commit
4ccdc1d
路
verified 路
1 Parent(s): 43ee218

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -4
app.py CHANGED
@@ -1,13 +1,20 @@
1
  import torch
2
  from diffusers import FluxPipeline
3
 
4
- # Cargar el pipeline con cuantizaci贸n de 4 bits
 
 
 
 
5
  pipe = FluxPipeline.from_pretrained(
6
  "black-forest-labs/FLUX.1-dev",
7
  torch_dtype=torch.bfloat16,
8
- load_in_4bit=True, # Esta es la clave para reducir la memoria
9
- device_map="auto"
10
  )
11
 
12
- # Luego carga tu LoRA como ya sab铆as
 
 
 
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")