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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -21
app.py CHANGED
@@ -1,22 +1,13 @@
1
  import torch
2
- from diffusers import DiffusionPipeline
3
- import gradio as gr
4
-
5
- # 1. Cargar el pipeline base (aseg煤rate de tener acceso/permisos si es necesario)
6
- base_model_id = "black-forest-labs/FLUX.1-dev"
7
- pipe = DiffusionPipeline.from_pretrained(base_model_id, torch_dtype=torch.bfloat16)
8
- pipe.to("cuda")
9
-
10
- # 2. Cargar el adaptador LoRA desde el Hub
11
- # Al cargar el LoRA as铆, el pipeline lo integra autom谩ticamente
12
- pipe.load_lora_weights("joyfox/Kontext-Cosplay-Lora", weight_name="kontext_cosplay_lora_20000.safetensors")
13
-
14
- def generate_image(prompt):
15
- # La trigger phrase 'r2cos' es esencial seg煤n la documentaci贸n del autor
16
- full_prompt = f"{prompt}, r2cos"
17
- image = pipe(full_prompt, guidance_scale=3.5).images[0]
18
- return image
19
-
20
- # Interfaz Gradio
21
- demo = gr.Interface(fn=generate_image, inputs="text", outputs="image")
22
- demo.launch()
 
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")