Update app.py
Browse files
app.py
CHANGED
@@ -99,11 +99,11 @@ def update_selection(evt: gr.SelectData, selected_indices, loras_state, width, h
|
|
99 |
if selected_index in selected_indices:
|
100 |
selected_indices.remove(selected_index)
|
101 |
else:
|
102 |
-
if len(selected_indices) <
|
103 |
selected_indices.append(selected_index)
|
104 |
else:
|
105 |
-
gr.Warning("You can select up to
|
106 |
-
return gr.update(), gr.update(), gr.update(), selected_indices, gr.update(), gr.update(), width, height, gr.update(), gr.update()
|
107 |
|
108 |
selected_info_1 = "Select a LoRA 1"
|
109 |
selected_info_2 = "Select a LoRA 2"
|
@@ -384,9 +384,9 @@ def add_custom_lora(custom_lora, selected_indices, current_loras, gallery):
|
|
384 |
except Exception as e:
|
385 |
print(e)
|
386 |
gr.Warning(str(e))
|
387 |
-
return current_loras, gr.update(), gr.update(), gr.update(), selected_indices, gr.update(), gr.update(), gr.update(), gr.update()
|
388 |
else:
|
389 |
-
return current_loras, gr.update(), gr.update(), gr.update(), selected_indices, gr.update(), gr.update(), gr.update(), gr.update()
|
390 |
|
391 |
def remove_custom_lora(selected_indices, current_loras, gallery):
|
392 |
if current_loras:
|
@@ -551,7 +551,7 @@ run_lora.zerogpu = True
|
|
551 |
|
552 |
def get_huggingface_safetensors(link):
|
553 |
split_link = link.split("/")
|
554 |
-
if len(split_link) ==
|
555 |
model_card = ModelCard.load(link)
|
556 |
base_model = model_card.data.get("base_model")
|
557 |
print(f"Base model: {base_model}")
|
|
|
99 |
if selected_index in selected_indices:
|
100 |
selected_indices.remove(selected_index)
|
101 |
else:
|
102 |
+
if len(selected_indices) < 2:
|
103 |
selected_indices.append(selected_index)
|
104 |
else:
|
105 |
+
gr.Warning("You can select up to 2 LoRAs, remove one to select a new one.")
|
106 |
+
return gr.update(), gr.update(), gr.update(), selected_indices, gr.update(), gr.update(), width, height, gr.update(), gr.update()
|
107 |
|
108 |
selected_info_1 = "Select a LoRA 1"
|
109 |
selected_info_2 = "Select a LoRA 2"
|
|
|
384 |
except Exception as e:
|
385 |
print(e)
|
386 |
gr.Warning(str(e))
|
387 |
+
return current_loras, gr.update(), gr.update(), gr.update(), selected_indices, gr.update(), gr.update(), gr.update(), gr.update()
|
388 |
else:
|
389 |
+
return current_loras, gr.update(), gr.update(), gr.update(), selected_indices, gr.update(), gr.update(), gr.update(), gr.update()
|
390 |
|
391 |
def remove_custom_lora(selected_indices, current_loras, gallery):
|
392 |
if current_loras:
|
|
|
551 |
|
552 |
def get_huggingface_safetensors(link):
|
553 |
split_link = link.split("/")
|
554 |
+
if len(split_link) == 2:
|
555 |
model_card = ModelCard.load(link)
|
556 |
base_model = model_card.data.get("base_model")
|
557 |
print(f"Base model: {base_model}")
|