macgaga commited on
Commit
9b07951
·
verified ·
1 Parent(s): 091c921

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -80
app.py CHANGED
@@ -15,12 +15,6 @@ import requests
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,86 +1024,43 @@ with gr.Blocks(theme='NoCrypt/miku@>=1.2.2', fill_width=True, css=css, delete_ca
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
- for i, l in enumerate(lora_repo):
1069
- deselect_lora_button.click(
1070
- lambda: ("", 1.0),
1071
- None,
1072
- [lora_repo[i], lora_wt[i]],
1073
- queue=False,
1074
- show_api=False
1075
- )
1076
  gr.on(
1077
- triggers=[lora_download[i].click],
1078
- fn=download_my_lora_flux,
1079
- inputs=[lora_download_url, lora_repo[i]],
1080
- outputs=[lora_repo[i]],
 
1081
  scroll_to_output=True,
1082
  queue=True,
1083
  show_api=False,
1084
  )
1085
- gr.on(
1086
- triggers=[lora_repo[i].change, lora_wt[i].change],
1087
- fn=update_loras_flux,
1088
- inputs=[prompt, lora_repo[i], lora_wt[i]],
1089
- outputs=[prompt, lora_repo[i], lora_wt[i], lora_info[i], lora_md[i]],
1090
- queue=False,
1091
- trigger_mode="once",
1092
- show_api=False,
1093
- ).success(
1094
- get_repo_safetensors,
1095
- [lora_repo[i]],
1096
- [lora_weights[i]],
1097
- queue=False,
1098
- show_api=False
1099
- ).success(
1100
- apply_lora_prompt_flux,
1101
- [lora_info[i]],
1102
- [lora_trigger[i]],
1103
- queue=False,
1104
- show_api=False
1105
- ).success(
1106
- compose_lora_json,
1107
- [lora_repo_json, lora_num[i], lora_repo[i], lora_wt[i], lora_weights[i], lora_trigger[i]],
1108
- [lora_repo_json],
1109
- queue=False,
1110
- show_api=False
1111
- )
1112
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1113
  for i, m in enumerate(cn_mode):
1114
  gr.on(
1115
  triggers=[cn_mode[i].change, cn_scale[i].change],
 
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
  )#.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)
1043
+ gr.on(
1044
+ triggers=[lora_download[i].click],
1045
+ fn=download_my_lora_flux,
1046
+ inputs=[lora_download_url, lora_repo[i]],
1047
+ outputs=[lora_repo[i]],
1048
+ scroll_to_output=True,
1049
+ queue=True,
1050
+ show_api=False,
1051
+ )
1052
+ gr.on(
1053
+ triggers=[lora_repo[i].change, lora_wt[i].change],
1054
+ fn=update_loras_flux,
1055
+ inputs=[prompt, lora_repo[i], lora_wt[i]],
1056
+ outputs=[prompt, lora_repo[i], lora_wt[i], lora_info[i], lora_md[i]],
1057
+ queue=False,
1058
+ trigger_mode="once",
1059
+ show_api=False,
1060
+ ).success(get_repo_safetensors, [lora_repo[i]], [lora_weights[i]], queue=False, show_api=False
1061
+ ).success(apply_lora_prompt_flux, [lora_info[i]], [lora_trigger[i]], queue=False, show_api=False
1062
+ ).success(compose_lora_json, [lora_repo_json, lora_num[i], lora_repo[i], lora_wt[i], lora_weights[i], lora_trigger[i]], [lora_repo_json], queue=False, show_api=False)
1063
+
1064
  for i, m in enumerate(cn_mode):
1065
  gr.on(
1066
  triggers=[cn_mode[i].change, cn_scale[i].change],