macgaga commited on
Commit
e9acfdf
·
verified ·
1 Parent(s): da50adf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -13
app.py CHANGED
@@ -15,6 +15,12 @@ import requests
15
  import pandas as pd
16
  from pathlib import Path
17
 
 
 
 
 
 
 
18
  from env import models, num_loras, num_cns, HF_TOKEN, single_file_base_models
19
  from mod import (clear_cache, get_repo_safetensors, is_repo_name, is_repo_exists, get_model_trigger,
20
  description_ui, compose_lora_json, is_valid_lora, fuse_loras, save_image, preprocess_i2i_image,
@@ -1024,19 +1030,41 @@ with gr.Blocks(theme='NoCrypt/miku@>=1.2.2', fill_width=True, css=css, delete_ca
1024
  )#.then(change_base_model, [model_name, cn_on, disable_model_cache, model_type], [result], queue=True, show_api=False)
1025
  prompt_enhance.click(enhance_prompt, [prompt], [prompt], queue=False, show_api=False)
1026
 
1027
- gr.on(
1028
- triggers=[lora_search_civitai_submit.click, lora_search_civitai_query.submit],
1029
- fn=search_civitai_lora,
1030
- inputs=[lora_search_civitai_query, lora_search_civitai_basemodel, lora_search_civitai_sort, lora_search_civitai_period,
1031
- lora_search_civitai_tag, lora_search_civitai_user, lora_search_civitai_gallery],
1032
- outputs=[lora_search_civitai_result, lora_search_civitai_desc, lora_search_civitai_submit, lora_search_civitai_query, lora_search_civitai_gallery],
1033
- scroll_to_output=True,
1034
- queue=True,
1035
- show_api=False,
1036
- )
1037
- lora_search_civitai_json.change(search_civitai_lora_json, [lora_search_civitai_query, lora_search_civitai_basemodel], [lora_search_civitai_json], queue=True, show_api=True) # fn for api
1038
- lora_search_civitai_result.change(select_civitai_lora, [lora_search_civitai_result], [lora_download_url, lora_search_civitai_desc], scroll_to_output=True, queue=False, show_api=False)
1039
- lora_search_civitai_gallery.select(update_civitai_selection, None, [lora_search_civitai_result], queue=False, show_api=False)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1040
 
1041
  for i, l in enumerate(lora_repo):
1042
  deselect_lora_button.click(lambda: ("", 1.0), None, [lora_repo[i], lora_wt[i]], queue=False, show_api=False)
 
15
  import pandas as pd
16
  from pathlib import Path
17
 
18
+ # MOD macgaga:
19
+ import importlib
20
+
21
+ # Dynamischer Import der zusätzlichen Funktionen
22
+ civitai_integration = importlib.import_module('civitai_integration')
23
+
24
  from env import models, num_loras, num_cns, HF_TOKEN, single_file_base_models
25
  from mod import (clear_cache, get_repo_safetensors, is_repo_name, is_repo_exists, get_model_trigger,
26
  description_ui, compose_lora_json, is_valid_lora, fuse_loras, save_image, preprocess_i2i_image,
 
1030
  )#.then(change_base_model, [model_name, cn_on, disable_model_cache, model_type], [result], queue=True, show_api=False)
1031
  prompt_enhance.click(enhance_prompt, [prompt], [prompt], queue=False, show_api=False)
1032
 
1033
+ lora_search_civitai_submit.click(
1034
+ lambda query, tags, sort, period: search_civitai_lora(query, tags, sort, period),
1035
+ inputs=[lora_search_civitai_query, lora_search_civitai_tag, lora_search_civitai_sort, lora_search_civitai_period],
1036
+ outputs=[lora_search_civitai_json],
1037
+ ).success(
1038
+ civitai_integration.update_gallery_with_civitai_loras, # Nutzt die ausgelagerte Funktion
1039
+ inputs=[lora_search_civitai_json, loras_state],
1040
+ outputs=[loras_state, gallery]
1041
+ )
1042
+
1043
+ lora_search_civitai_json.change(
1044
+ search_civitai_lora_json,
1045
+ [lora_search_civitai_query, lora_search_civitai_basemodel],
1046
+ [lora_search_civitai_json],
1047
+ queue=True,
1048
+ show_api=True
1049
+ ) # fn for api
1050
+
1051
+ lora_search_civitai_result.change(
1052
+ select_civitai_lora,
1053
+ [lora_search_civitai_result],
1054
+ [lora_download_url, lora_search_civitai_desc],
1055
+ scroll_to_output=True,
1056
+ queue=False,
1057
+ show_api=False
1058
+ )
1059
+
1060
+ lora_search_civitai_gallery.select(
1061
+ update_civitai_selection,
1062
+ None,
1063
+ [lora_search_civitai_result],
1064
+ queue=False,
1065
+ show_api=False
1066
+ )
1067
+
1068
 
1069
  for i, l in enumerate(lora_repo):
1070
  deselect_lora_button.click(lambda: ("", 1.0), None, [lora_repo[i], lora_wt[i]], queue=False, show_api=False)