Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,22 +1,13 @@
|
|
| 1 |
import torch
|
| 2 |
-
from diffusers import
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 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")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|