appinitdev commited on
Commit
6614b19
路
verified 路
1 Parent(s): 4ccdc1d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -13
app.py CHANGED
@@ -1,20 +1,12 @@
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")
 
1
  import torch
2
  from diffusers import FluxPipeline
3
 
4
+ # Usamos la variante en precisi贸n FP8, que reduce la huella de memoria a la mitad
 
 
 
 
5
  pipe = FluxPipeline.from_pretrained(
6
  "black-forest-labs/FLUX.1-dev",
7
+ torch_dtype=torch.float8_e4m3fn,
8
+ device_map="balanced"
9
+ ).to("cuda")
 
 
 
 
10
 
11
+ # Cargar el LoRA
12
  pipe.load_lora_weights("joyfox/Kontext-Cosplay-Lora", weight_name="kontext_cosplay_lora_20000.safetensors")