Spaces:
Running
Running
salomonsky
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -12,18 +12,14 @@ from gradio_client import Client, handle_file
|
|
12 |
from huggingface_hub import login
|
13 |
from gradio_imageslider import ImageSlider
|
14 |
|
15 |
-
# Constantes
|
16 |
MAX_SEED = np.iinfo(np.int32).max
|
17 |
HF_TOKEN = os.environ.get("HF_TOKEN")
|
18 |
HF_TOKEN_UPSCALER = os.environ.get("HF_TOKEN_UPSCALER")
|
19 |
|
20 |
-
# Funciones
|
21 |
def enable_lora(lora_add, basemodel):
|
22 |
-
"""Habilita o deshabilita el modelo LORA"""
|
23 |
return basemodel if not lora_add else lora_add
|
24 |
|
25 |
async def generate_image(prompt, model, lora_word, width, height, scales, steps, seed):
|
26 |
-
"""Genera una imagen a partir de un texto"""
|
27 |
try:
|
28 |
if seed == -1:
|
29 |
seed = random.randint(0, MAX_SEED)
|
@@ -63,36 +59,31 @@ def get_upscale_finegrain(prompt, img_path, upscale_factor):
|
|
63 |
print(f"Error upscale image: {e}")
|
64 |
return None
|
65 |
|
66 |
-
# Interfaz gr谩fica
|
67 |
css = """
|
68 |
-
#col-container{
|
69 |
-
margin: 0 auto;
|
70 |
-
max-width: 1024px;
|
71 |
-
}
|
72 |
"""
|
73 |
|
74 |
with gr.Blocks(css=css, theme="Nymbo/Nymbo_Theme") as demo:
|
75 |
with gr.Column(elem_id="col-container"):
|
76 |
-
gr.Markdown("Flux Upscaled +LORA")
|
77 |
with gr.Row():
|
78 |
with gr.Column(scale=3):
|
79 |
output_res = ImageSlider(label="Flux / Upscaled")
|
80 |
with gr.Column(scale=2):
|
81 |
-
prompt = gr.Textbox(label="
|
82 |
-
basemodel_choice = gr.Dropdown(label="
|
83 |
-
lora_model_choice = gr.Dropdown(label="LORA
|
84 |
-
process_lora = gr.Checkbox(label="
|
85 |
-
process_upscale = gr.Checkbox(label="
|
86 |
-
upscale_factor = gr.Radio(label="
|
87 |
|
88 |
-
with gr.Accordion(label="
|
89 |
-
width = gr.Slider(label="
|
90 |
-
height = gr.Slider(label="
|
91 |
-
scales = gr.Slider(label="
|
92 |
-
steps = gr.Slider(label="
|
93 |
-
seed = gr.Slider(label="
|
94 |
|
95 |
-
submit_btn = gr.Button("
|
96 |
submit_btn.click(
|
97 |
fn=lambda: None,
|
98 |
inputs=None,
|
|
|
12 |
from huggingface_hub import login
|
13 |
from gradio_imageslider import ImageSlider
|
14 |
|
|
|
15 |
MAX_SEED = np.iinfo(np.int32).max
|
16 |
HF_TOKEN = os.environ.get("HF_TOKEN")
|
17 |
HF_TOKEN_UPSCALER = os.environ.get("HF_TOKEN_UPSCALER")
|
18 |
|
|
|
19 |
def enable_lora(lora_add, basemodel):
|
|
|
20 |
return basemodel if not lora_add else lora_add
|
21 |
|
22 |
async def generate_image(prompt, model, lora_word, width, height, scales, steps, seed):
|
|
|
23 |
try:
|
24 |
if seed == -1:
|
25 |
seed = random.randint(0, MAX_SEED)
|
|
|
59 |
print(f"Error upscale image: {e}")
|
60 |
return None
|
61 |
|
|
|
62 |
css = """
|
63 |
+
#col-container{ margin: 0 auto; max-width: 1024px;}
|
|
|
|
|
|
|
64 |
"""
|
65 |
|
66 |
with gr.Blocks(css=css, theme="Nymbo/Nymbo_Theme") as demo:
|
67 |
with gr.Column(elem_id="col-container"):
|
|
|
68 |
with gr.Row():
|
69 |
with gr.Column(scale=3):
|
70 |
output_res = ImageSlider(label="Flux / Upscaled")
|
71 |
with gr.Column(scale=2):
|
72 |
+
prompt = gr.Textbox(label="Descripci贸n de im谩gen")
|
73 |
+
basemodel_choice = gr.Dropdown(label="Modelo", choices=["black-forest-labs/FLUX.1-schnell", "black-forest-labs/FLUX.1-DEV"], value="black-forest-labs/FLUX.1-schnell")
|
74 |
+
lora_model_choice = gr.Dropdown(label="LORA Realismo", choices=["Shakker-Labs/FLUX.1-dev-LoRA-add-details", "XLabs-AI/flux-RealismLora"], value="XLabs-AI/flux-RealismLora")
|
75 |
+
process_lora = gr.Checkbox(label="Procesar LORA")
|
76 |
+
process_upscale = gr.Checkbox(label="Procesar Escalador")
|
77 |
+
upscale_factor = gr.Radio(label="Factor de Escala", choices=[2, 4, 8], value=2)
|
78 |
|
79 |
+
with gr.Accordion(label="Opciones Avanzadas", open=False):
|
80 |
+
width = gr.Slider(label="Ancho", minimum=512, maximum=1280, step=8, value=1280)
|
81 |
+
height = gr.Slider(label="Alto", minimum=512, maximum=1280, step=8, value=768)
|
82 |
+
scales = gr.Slider(label="Escalas", minimum=3.5, maximum=7, step=0.1, value=3.5)
|
83 |
+
steps = gr.Slider(label="Pasos", minimum=1, maximum=100, step=1, value=24)
|
84 |
+
seed = gr.Slider(label="Semillas", minimum=-1, maximum=MAX_SEED, step=1, value=-1)
|
85 |
|
86 |
+
submit_btn = gr.Button("Crear", scale=1)
|
87 |
submit_btn.click(
|
88 |
fn=lambda: None,
|
89 |
inputs=None,
|