Spaces:
Running
Running
mirabarukaso
commited on
Commit
·
8650fd3
1
Parent(s):
4fe279e
Show CN name
Browse files- .gitignore +2 -0
- app.py +2 -2
- scripts/lib.py +14 -18
.gitignore
CHANGED
|
@@ -1 +1,3 @@
|
|
| 1 |
/scripts/__pycache__
|
|
|
|
|
|
|
|
|
| 1 |
/scripts/__pycache__
|
| 2 |
+
json/wai_character_thumbs.json
|
| 3 |
+
json/wai_characters.csv
|
app.py
CHANGED
|
@@ -5,7 +5,7 @@ from lib import init, refresh_character_thumb_image
|
|
| 5 |
from lib import JAVA_SCRIPT, CSS_SCRIPT, TITLE
|
| 6 |
|
| 7 |
if __name__ == '__main__':
|
| 8 |
-
character_list, LANG = init()
|
| 9 |
|
| 10 |
with gr.Blocks(js=JAVA_SCRIPT, css=CSS_SCRIPT, title=TITLE) as ui:
|
| 11 |
with gr.Row():
|
|
@@ -24,7 +24,7 @@ if __name__ == '__main__':
|
|
| 24 |
)
|
| 25 |
|
| 26 |
character3 = gr.Dropdown(
|
| 27 |
-
choices=
|
| 28 |
label=LANG["character3"],
|
| 29 |
value='none',
|
| 30 |
allow_custom_value=False,
|
|
|
|
| 5 |
from lib import JAVA_SCRIPT, CSS_SCRIPT, TITLE
|
| 6 |
|
| 7 |
if __name__ == '__main__':
|
| 8 |
+
character_list, character_list_cn, LANG = init()
|
| 9 |
|
| 10 |
with gr.Blocks(js=JAVA_SCRIPT, css=CSS_SCRIPT, title=TITLE) as ui:
|
| 11 |
with gr.Row():
|
|
|
|
| 24 |
)
|
| 25 |
|
| 26 |
character3 = gr.Dropdown(
|
| 27 |
+
choices=character_list_cn,
|
| 28 |
label=LANG["character3"],
|
| 29 |
value='none',
|
| 30 |
allow_custom_value=False,
|
scripts/lib.py
CHANGED
|
@@ -18,9 +18,9 @@ import argparse
|
|
| 18 |
|
| 19 |
# Language
|
| 20 |
LANG_EN = {
|
| 21 |
-
"character1": "Character list
|
| 22 |
-
"character2": "Character list
|
| 23 |
-
"character3": "Character list
|
| 24 |
"action": "Action list",
|
| 25 |
"original_character": "Original Character",
|
| 26 |
}
|
|
@@ -59,6 +59,7 @@ json_folder = os.path.join(parent_dir, 'json')
|
|
| 59 |
character_list = ''
|
| 60 |
character_dict = {}
|
| 61 |
wai_image_dict = {}
|
|
|
|
| 62 |
|
| 63 |
wai_illustrious_character_select_files = [
|
| 64 |
{'name': 'wai_character', 'file_path': os.path.join(json_folder, 'wai_characters.csv'), 'url':'https://raw.githubusercontent.com/mirabarukaso/character_select_stand_alone_app/refs/heads/main/json/wai_characters.csv'},
|
|
@@ -86,6 +87,7 @@ def load_jsons():
|
|
| 86 |
global character_list
|
| 87 |
global character_dict
|
| 88 |
global wai_image_dict
|
|
|
|
| 89 |
|
| 90 |
# download file
|
| 91 |
for item in wai_illustrious_character_select_files:
|
|
@@ -108,8 +110,10 @@ def load_jsons():
|
|
| 108 |
# Create list
|
| 109 |
character_list = list(character_dict.values())
|
| 110 |
character_list.insert(0, "none")
|
|
|
|
|
|
|
| 111 |
|
| 112 |
-
def illustrious_character_select_ex(character = 'random', optimise_tags = True, random_action_seed = 1):
|
| 113 |
chara = ''
|
| 114 |
rnd_character = ''
|
| 115 |
|
|
@@ -125,7 +129,7 @@ def illustrious_character_select_ex(character = 'random', optimise_tags = True,
|
|
| 125 |
rnd_character = character_list[index+1]
|
| 126 |
else:
|
| 127 |
rnd_character = character
|
| 128 |
-
if
|
| 129 |
chara = rnd_character
|
| 130 |
else:
|
| 131 |
chara = character_dict[rnd_character]
|
|
@@ -148,27 +152,19 @@ def illustrious_character_select_ex(character = 'random', optimise_tags = True,
|
|
| 148 |
def refresh_character_thumb_image(character1, character2, character3):
|
| 149 |
thumb_image = []
|
| 150 |
if 'none' != character1 and 'random' != character1:
|
| 151 |
-
_, _, thumb_image1 = illustrious_character_select_ex(character = character1
|
| 152 |
thumb_image.append(thumb_image1)
|
| 153 |
|
| 154 |
if 'none' != character2 and 'random' != character2:
|
| 155 |
-
_, _, thumb_image2 = illustrious_character_select_ex(character = character2
|
| 156 |
thumb_image.append(thumb_image2)
|
| 157 |
if 'none' != character3 and 'random' != character3:
|
| 158 |
-
_, _, thumb_image3 = illustrious_character_select_ex(character = character3,
|
| 159 |
thumb_image.append(thumb_image3)
|
| 160 |
return thumb_image
|
| 161 |
|
| 162 |
-
def init():
|
| 163 |
-
global ENGLISH_CHARACTER_NAME
|
| 164 |
-
global LANG
|
| 165 |
-
|
| 166 |
-
ENGLISH_CHARACTER_NAME = True
|
| 167 |
-
if ENGLISH_CHARACTER_NAME:
|
| 168 |
-
print(f'[{CAT}]:Use tags as Character Name')
|
| 169 |
-
LANG = LANG_EN
|
| 170 |
-
|
| 171 |
load_jsons()
|
| 172 |
print(f'[{CAT}]:Starting...')
|
| 173 |
|
| 174 |
-
return character_list, LANG
|
|
|
|
| 18 |
|
| 19 |
# Language
|
| 20 |
LANG_EN = {
|
| 21 |
+
"character1": "Character list EN",
|
| 22 |
+
"character2": "Character list EN",
|
| 23 |
+
"character3": "Character list CN",
|
| 24 |
"action": "Action list",
|
| 25 |
"original_character": "Original Character",
|
| 26 |
}
|
|
|
|
| 59 |
character_list = ''
|
| 60 |
character_dict = {}
|
| 61 |
wai_image_dict = {}
|
| 62 |
+
character_list_cn = ''
|
| 63 |
|
| 64 |
wai_illustrious_character_select_files = [
|
| 65 |
{'name': 'wai_character', 'file_path': os.path.join(json_folder, 'wai_characters.csv'), 'url':'https://raw.githubusercontent.com/mirabarukaso/character_select_stand_alone_app/refs/heads/main/json/wai_characters.csv'},
|
|
|
|
| 87 |
global character_list
|
| 88 |
global character_dict
|
| 89 |
global wai_image_dict
|
| 90 |
+
global character_list_cn
|
| 91 |
|
| 92 |
# download file
|
| 93 |
for item in wai_illustrious_character_select_files:
|
|
|
|
| 110 |
# Create list
|
| 111 |
character_list = list(character_dict.values())
|
| 112 |
character_list.insert(0, "none")
|
| 113 |
+
character_list_cn = list(character_dict.keys())
|
| 114 |
+
character_list_cn.insert(0, "none")
|
| 115 |
|
| 116 |
+
def illustrious_character_select_ex(character = 'random', optimise_tags = True, random_action_seed = 1, use_cn=False):
|
| 117 |
chara = ''
|
| 118 |
rnd_character = ''
|
| 119 |
|
|
|
|
| 129 |
rnd_character = character_list[index+1]
|
| 130 |
else:
|
| 131 |
rnd_character = character
|
| 132 |
+
if not use_cn:
|
| 133 |
chara = rnd_character
|
| 134 |
else:
|
| 135 |
chara = character_dict[rnd_character]
|
|
|
|
| 152 |
def refresh_character_thumb_image(character1, character2, character3):
|
| 153 |
thumb_image = []
|
| 154 |
if 'none' != character1 and 'random' != character1:
|
| 155 |
+
_, _, thumb_image1 = illustrious_character_select_ex(character = character1)
|
| 156 |
thumb_image.append(thumb_image1)
|
| 157 |
|
| 158 |
if 'none' != character2 and 'random' != character2:
|
| 159 |
+
_, _, thumb_image2 = illustrious_character_select_ex(character = character2)
|
| 160 |
thumb_image.append(thumb_image2)
|
| 161 |
if 'none' != character3 and 'random' != character3:
|
| 162 |
+
_, _, thumb_image3 = illustrious_character_select_ex(character = character3, use_cn=True)
|
| 163 |
thumb_image.append(thumb_image3)
|
| 164 |
return thumb_image
|
| 165 |
|
| 166 |
+
def init():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 167 |
load_jsons()
|
| 168 |
print(f'[{CAT}]:Starting...')
|
| 169 |
|
| 170 |
+
return character_list, character_list_cn, LANG
|