Update app.py
Browse files
app.py
CHANGED
|
@@ -33,14 +33,14 @@ pipe.to("cuda")
|
|
| 33 |
|
| 34 |
# Definição dos LoRA e Trigger Words
|
| 35 |
lora_models = {
|
| 36 |
-
"
|
| 37 |
"repo": "vcollos/Paula2",
|
| 38 |
"weights": "Paula P.safetensors",
|
| 39 |
"trigger_word": "" # Sem trigger word específica
|
| 40 |
},
|
| 41 |
-
"
|
| 42 |
-
"repo": "vcollos/
|
| 43 |
-
"weights": "
|
| 44 |
"trigger_word": ""
|
| 45 |
}
|
| 46 |
}
|
|
@@ -89,21 +89,21 @@ def run_lora(prompt, cfg_scale, steps, randomize_seed, seed, width, height, lora
|
|
| 89 |
selected_loras = []
|
| 90 |
adapter_weights = []
|
| 91 |
|
| 92 |
-
if lora_option == "
|
| 93 |
-
selected_loras.append("
|
| 94 |
adapter_weights.append(lora_scale_1)
|
| 95 |
-
elif lora_option == "
|
| 96 |
-
selected_loras.append("
|
| 97 |
adapter_weights.append(lora_scale_2)
|
| 98 |
elif lora_option == "Ambos":
|
| 99 |
-
selected_loras = ["
|
| 100 |
adapter_weights = [lora_scale_1, lora_scale_2]
|
| 101 |
|
| 102 |
pipe.set_adapters(selected_loras, adapter_weights)
|
| 103 |
|
| 104 |
-
# Adiciona trigger words apenas se
|
| 105 |
-
if "
|
| 106 |
-
prompt = f"{lora_models['
|
| 107 |
|
| 108 |
# Gera a imagem com precisão de 16 bits para tentar melhorar a nitidez
|
| 109 |
with torch.autocast("cuda"):
|
|
@@ -157,7 +157,7 @@ def run_lora(prompt, cfg_scale, steps, randomize_seed, seed, width, height, lora
|
|
| 157 |
# Interface Gradio
|
| 158 |
gr_theme = os.getenv("THEME")
|
| 159 |
with gr.Blocks(theme=gr_theme) as app:
|
| 160 |
-
gr.Markdown("#
|
| 161 |
|
| 162 |
with gr.Row():
|
| 163 |
with gr.Column(scale=2):
|
|
@@ -169,9 +169,9 @@ with gr.Blocks(theme=gr_theme) as app:
|
|
| 169 |
height = gr.Slider(label="Height", minimum=256, maximum=1024, step=64, value=1024)
|
| 170 |
randomize_seed = gr.Checkbox(False, label="Randomize seed")
|
| 171 |
seed = gr.Slider(label="Seed", minimum=0, maximum=MAX_SEED, step=1, value=556215326)
|
| 172 |
-
lora_option = gr.Radio(["Nenhum", "
|
| 173 |
-
lora_scale_1 = gr.Slider(label="LoRA Scale (
|
| 174 |
-
lora_scale_2 = gr.Slider(label="LoRA Scale (
|
| 175 |
|
| 176 |
with gr.Column(scale=2):
|
| 177 |
result = gr.Image(label="Generated Image")
|
|
|
|
| 33 |
|
| 34 |
# Definição dos LoRA e Trigger Words
|
| 35 |
lora_models = {
|
| 36 |
+
"Paula": {
|
| 37 |
"repo": "vcollos/Paula2",
|
| 38 |
"weights": "Paula P.safetensors",
|
| 39 |
"trigger_word": "" # Sem trigger word específica
|
| 40 |
},
|
| 41 |
+
"Vivi": {
|
| 42 |
+
"repo": "vcollos/Vivi",
|
| 43 |
+
"weights": "Vivi.safetensors",
|
| 44 |
"trigger_word": ""
|
| 45 |
}
|
| 46 |
}
|
|
|
|
| 89 |
selected_loras = []
|
| 90 |
adapter_weights = []
|
| 91 |
|
| 92 |
+
if lora_option == "Paula":
|
| 93 |
+
selected_loras.append("Paula")
|
| 94 |
adapter_weights.append(lora_scale_1)
|
| 95 |
+
elif lora_option == "Vivi":
|
| 96 |
+
selected_loras.append("Vivi")
|
| 97 |
adapter_weights.append(lora_scale_2)
|
| 98 |
elif lora_option == "Ambos":
|
| 99 |
+
selected_loras = ["Paula", "Vivi"]
|
| 100 |
adapter_weights = [lora_scale_1, lora_scale_2]
|
| 101 |
|
| 102 |
pipe.set_adapters(selected_loras, adapter_weights)
|
| 103 |
|
| 104 |
+
# Adiciona trigger words apenas se Vivi estiver ativado
|
| 105 |
+
if "Vivi" in selected_loras:
|
| 106 |
+
prompt = f"{lora_models['Vivi']['trigger_word']} {prompt}"
|
| 107 |
|
| 108 |
# Gera a imagem com precisão de 16 bits para tentar melhorar a nitidez
|
| 109 |
with torch.autocast("cuda"):
|
|
|
|
| 157 |
# Interface Gradio
|
| 158 |
gr_theme = os.getenv("THEME")
|
| 159 |
with gr.Blocks(theme=gr_theme) as app:
|
| 160 |
+
gr.Markdown("# Paula Image Generator")
|
| 161 |
|
| 162 |
with gr.Row():
|
| 163 |
with gr.Column(scale=2):
|
|
|
|
| 169 |
height = gr.Slider(label="Height", minimum=256, maximum=1024, step=64, value=1024)
|
| 170 |
randomize_seed = gr.Checkbox(False, label="Randomize seed")
|
| 171 |
seed = gr.Slider(label="Seed", minimum=0, maximum=MAX_SEED, step=1, value=556215326)
|
| 172 |
+
lora_option = gr.Radio(["Nenhum", "Paula", "Vivi", "Ambos"], label="Escolha o LoRA", value="Ambos")
|
| 173 |
+
lora_scale_1 = gr.Slider(label="LoRA Scale (Paula)", minimum=0, maximum=1, step=0.01, value=1)
|
| 174 |
+
lora_scale_2 = gr.Slider(label="LoRA Scale (Vivi)", minimum=0, maximum=1, step=0.01, value=1)
|
| 175 |
|
| 176 |
with gr.Column(scale=2):
|
| 177 |
result = gr.Image(label="Generated Image")
|