commit
eee622d4f2
|
|
@ -70,6 +70,9 @@ Civitai 사이트의 모델 URL을 저장하여 나중에 참조하고 보관할
|
|||
* CivitaiShortCutBackupUrl.json : Shortcut 등록시의 URL을 백업하는 파일
|
||||
|
||||
# Change Log
|
||||
v 1.5.8
|
||||
* 모델 인포메이션에 personal note 항목을 추가, 검색에서 "@" 를 이용해서 검색가능
|
||||
|
||||
v 1.5.7
|
||||
* Civitai에서 제공하는 기본 모델을 사용하여 필터링하는 기능이 추가되었습니다.
|
||||
* 분류 항목을 검색 섹션에서 검색하는 대신 드롭다운 목록에서 선택할 수 있도록 변경합니다. 선택된 분류 항목은 'AND' 연산으로 작동하여 교집합처럼 동작합니다. 이렇게 하면 다중 카테고리에 속하는 바로 가기들을 더 자세하게 관리할 수 있습니다.
|
||||
|
|
|
|||
|
|
@ -67,6 +67,9 @@ Four folders and five JSON files will be created, each serving the following rol
|
|||
* CivitaiShortCutBackupUrl.json : JSON file for backing up the URL during shortcut registration.
|
||||
|
||||
# Change Log
|
||||
v 1.5.8
|
||||
* Add a 'Personal Note' section to the model information, and make it searchable using '@' in the search.
|
||||
|
||||
v 1.5.7
|
||||
* The functionality to filter using the base model provided by Civitai has been added.
|
||||
* I changed the classification categories to be selected from a dropdown list instead of searching in the search section. The selected classification categories will work as an 'AND' operation, meaning they will function as an intersection. This way, we can manage shortcuts that are classified under multiple categories in a more detailed manner
|
||||
|
|
|
|||
|
|
@ -154,6 +154,36 @@ def get_images_meta(images:dict, imageid):
|
|||
|
||||
return None
|
||||
|
||||
# 모델에 해당하는 shortcut에서 note를 변경한다.
|
||||
def update_shortcut_model_note(modelid, note):
|
||||
if modelid:
|
||||
ISC = load()
|
||||
try:
|
||||
ISC[str(modelid)]["note"] = note
|
||||
save(ISC)
|
||||
except:
|
||||
pass
|
||||
|
||||
# 모델에 해당하는 shortcut에서 note를 가져온다
|
||||
def get_shortcut_model_note(modelid):
|
||||
if modelid:
|
||||
ISC = load()
|
||||
try:
|
||||
return ISC[str(modelid)]["note"]
|
||||
except:
|
||||
pass
|
||||
return None
|
||||
|
||||
# 모델에 해당하는 shortcut 을 가져온다
|
||||
def get_shortcut_model(modelid):
|
||||
if modelid:
|
||||
ISC = load()
|
||||
try:
|
||||
return ISC[str(modelid)]
|
||||
except:
|
||||
pass
|
||||
return None
|
||||
|
||||
# 모델에 해당하는 shortcut 을 지운다
|
||||
def delete_shortcut_model(modelid):
|
||||
if modelid:
|
||||
|
|
@ -165,9 +195,19 @@ def delete_shortcut_model(modelid):
|
|||
# 솟컷을 업데이트하며 없으면 해당 아이디의 모델을 새로 생성한다.
|
||||
def update_shortcut(modelid, progress = None):
|
||||
if modelid:
|
||||
note = None
|
||||
|
||||
add_ISC = add(None, str(modelid), False, progress)
|
||||
ISC = load()
|
||||
if ISC:
|
||||
if str(modelid) in ISC:
|
||||
# 개별적으로 저장한 정보를 가져온다.
|
||||
if "note" in ISC[str(modelid)]:
|
||||
note = ISC[str(modelid)]["note"]
|
||||
|
||||
if add_ISC:
|
||||
add_ISC[str(modelid)]["note"] = note
|
||||
|
||||
ISC.update(add_ISC)
|
||||
else:
|
||||
ISC = add_ISC
|
||||
|
|
@ -189,17 +229,27 @@ def update_shortcut_informations(modelid_list:list, progress):
|
|||
# write_model_information(modelid, False, progress)
|
||||
|
||||
for modelid in progress.tqdm(modelid_list,desc="Updating Models Information"):
|
||||
note = None
|
||||
|
||||
if modelid:
|
||||
add_ISC = add(None,str(modelid),False,progress)
|
||||
|
||||
ISC = load()
|
||||
# hot fix and delete model
|
||||
# civitiai 에서 제거된 모델때문임
|
||||
# tags 를 변경해줘야함
|
||||
# 이슈가 해결되면 제거할코드
|
||||
if str(modelid) in ISC:
|
||||
ISC[str(modelid)]["tags"]=[]
|
||||
|
||||
if str(modelid) in ISC:
|
||||
# 개별적으로 저장한 정보를 가져온다.
|
||||
if "note" in ISC[str(modelid)]:
|
||||
note = ISC[str(modelid)]["note"]
|
||||
|
||||
if add_ISC:
|
||||
add_ISC[str(modelid)]["note"] = note
|
||||
|
||||
# hot fix and delete model
|
||||
# civitiai 에서 제거된 모델때문임
|
||||
# tags 를 변경해줘야함
|
||||
# 이슈가 해결되면 제거할코드
|
||||
# ISC[str(modelid)]["tags"]=[]
|
||||
|
||||
if ISC:
|
||||
ISC.update(add_ISC)
|
||||
else:
|
||||
|
|
@ -388,9 +438,8 @@ def get_image_list(shortcut_types=None, search=None, shortcut_basemodels=None, s
|
|||
|
||||
result_list = list()
|
||||
|
||||
keys, tags = util.get_search_keyword(search)
|
||||
# keys, tags, clfs, filenames = util.get_search_keyword(search)
|
||||
# util.printD(f"keys:{keys} ,tags:{tags},clfs:{clfs}")
|
||||
keys, tags, notes = util.get_search_keyword(search)
|
||||
# util.printD(f"keys:{keys} ,tags:{tags},notes:{notes}")
|
||||
|
||||
# classification # and 연산으로 변경한다.
|
||||
if shortcut_classification:
|
||||
|
|
@ -418,7 +467,7 @@ def get_image_list(shortcut_types=None, search=None, shortcut_basemodels=None, s
|
|||
else:
|
||||
result_list = ISC.values()
|
||||
|
||||
# type 을 걸러내자
|
||||
# filtering type
|
||||
tmp_types = list()
|
||||
if shortcut_types:
|
||||
for sc_type in shortcut_types:
|
||||
|
|
@ -430,7 +479,7 @@ def get_image_list(shortcut_types=None, search=None, shortcut_basemodels=None, s
|
|||
if tmp_types:
|
||||
result_list = [v for v in result_list if v['type'] in tmp_types]
|
||||
|
||||
# key를 걸러내자
|
||||
# filtering key
|
||||
if keys:
|
||||
key_list = list()
|
||||
for v in result_list:
|
||||
|
|
@ -441,7 +490,7 @@ def get_image_list(shortcut_types=None, search=None, shortcut_basemodels=None, s
|
|||
break
|
||||
result_list = key_list
|
||||
|
||||
# tags를 걸러내자
|
||||
# filtering tags
|
||||
if tags:
|
||||
tags_list = list()
|
||||
for v in result_list:
|
||||
|
|
@ -455,6 +504,23 @@ def get_image_list(shortcut_types=None, search=None, shortcut_basemodels=None, s
|
|||
tags_list.append(v)
|
||||
result_list = tags_list
|
||||
|
||||
# filtering personal note key
|
||||
if notes:
|
||||
note_list = list()
|
||||
for v in result_list:
|
||||
if v:
|
||||
if "note" not in v.keys():
|
||||
continue
|
||||
|
||||
if not v['note']:
|
||||
continue
|
||||
|
||||
for note in notes:
|
||||
if note in v['note'].lower():
|
||||
note_list.append(v)
|
||||
break
|
||||
result_list = note_list
|
||||
|
||||
# basemodel 검색
|
||||
tmp_basemodels = list()
|
||||
if shortcut_basemodels:
|
||||
|
|
@ -487,111 +553,7 @@ def get_image_list(shortcut_types=None, search=None, shortcut_basemodels=None, s
|
|||
else:
|
||||
shotcutlist.append((setting.no_card_preview_image,setting.set_shortcutname(v['name'],v['id'])))
|
||||
|
||||
return shotcutlist
|
||||
|
||||
# def get_image_list_prev(shortcut_types=None, search=None, shortcut_basemodels=None)->str:
|
||||
|
||||
# ISC = load()
|
||||
# if not ISC:
|
||||
# return
|
||||
|
||||
# result_list = list()
|
||||
|
||||
# keys, tags, clfs = util.get_search_keyword(search)
|
||||
# # keys, tags, clfs, filenames = util.get_search_keyword(search)
|
||||
# # util.printD(f"keys:{keys} ,tags:{tags},clfs:{clfs}")
|
||||
|
||||
# # classification
|
||||
# if clfs:
|
||||
# clfs_list = list()
|
||||
# CISC = classification.load()
|
||||
# if CISC:
|
||||
# for name in clfs:
|
||||
# name_list = classification.get_shortcut_list(CISC,name)
|
||||
# if name_list:
|
||||
# clfs_list.extend(name_list)
|
||||
# clfs_list = list(set(clfs_list))
|
||||
|
||||
# if len(clfs_list) > 0:
|
||||
# for mid in clfs_list:
|
||||
# if str(mid) in ISC.keys():
|
||||
# result_list.append(ISC[str(mid)])
|
||||
# else:
|
||||
# result_list = ISC.values()
|
||||
|
||||
# # keys, tags = util.get_search_keyword(search)
|
||||
# # result_list = ISC.values()
|
||||
|
||||
# # type 을 걸러내자
|
||||
# tmp_types = list()
|
||||
# if shortcut_types:
|
||||
# for sc_type in shortcut_types:
|
||||
# try:
|
||||
# tmp_types.append(setting.ui_typenames[sc_type])
|
||||
# except:
|
||||
# pass
|
||||
|
||||
# if tmp_types:
|
||||
# result_list = [v for v in result_list if v['type'] in tmp_types]
|
||||
|
||||
# # key를 걸러내자
|
||||
# if keys:
|
||||
# key_list = list()
|
||||
# for v in result_list:
|
||||
# if v:
|
||||
# for key in keys:
|
||||
# if key in v['name'].lower():
|
||||
# key_list.append(v)
|
||||
# break
|
||||
# result_list = key_list
|
||||
|
||||
# # tags를 걸러내자
|
||||
# if tags:
|
||||
# tags_list = list()
|
||||
# for v in result_list:
|
||||
# if v:
|
||||
# if "tags" not in v.keys():
|
||||
# continue
|
||||
# # v_tags = [tag["name"].lower() for tag in v["tags"]]
|
||||
# v_tags = [tag.lower() for tag in v["tags"]]
|
||||
# common_tags = set(v_tags) & set(tags)
|
||||
# if common_tags:
|
||||
# tags_list.append(v)
|
||||
# result_list = tags_list
|
||||
|
||||
# # basemodel 검색
|
||||
# tmp_basemodels = list()
|
||||
# if shortcut_basemodels:
|
||||
# tmp_basemodels.extend(shortcut_basemodels)
|
||||
# result_list = [v for v in result_list if is_baseModel(str(v['id']), tmp_basemodels)]
|
||||
|
||||
# # filename검색
|
||||
# # if filenames:
|
||||
# # filenames_list = list()
|
||||
# # for v in result_list:
|
||||
# # if v:
|
||||
# # if "id" not in v.keys():
|
||||
# # continue
|
||||
|
||||
# # v_filenames = get_model_filenames(v["id"])
|
||||
# # common_filenames = set(v_filenames) & set(filenames)
|
||||
# # if common_filenames:
|
||||
# # filenames_list.append(v)
|
||||
# # result_list = filenames_list
|
||||
|
||||
# # name을 기준으로 정렬
|
||||
# result_list = sorted(result_list, key=lambda x: x["name"].lower().strip(), reverse=False)
|
||||
|
||||
# # 썸네일이 있는지 판단해서 대체 이미지 작업
|
||||
# shotcutlist = list()
|
||||
# for v in result_list:
|
||||
# if v:
|
||||
# if is_sc_image(v['id']):
|
||||
# shotcutlist.append((os.path.join(setting.shortcut_thumbnail_folder,f"{v['id']}{setting.preview_image_ext}"),setting.set_shortcutname(v['name'],v['id'])))
|
||||
# else:
|
||||
# shotcutlist.append((setting.no_card_preview_image,setting.set_shortcutname(v['name'],v['id'])))
|
||||
|
||||
# return shotcutlist
|
||||
return shotcutlist
|
||||
|
||||
def create_thumbnail(model_id, input_image_path):
|
||||
global thumbnail_max_size
|
||||
|
|
@ -722,7 +684,8 @@ def add(ISC:dict, model_id, register_information_only=False, progress=None)->dic
|
|||
"nsfw" : model_info['nsfw'],
|
||||
"url": f"{civitai.Url_ModelId()}{model_id}",
|
||||
"versionid" : def_id,
|
||||
"imageurl" : def_image
|
||||
"imageurl" : def_image,
|
||||
"note" : ""
|
||||
}
|
||||
|
||||
# ISC[str(model_id)] = cis
|
||||
|
|
|
|||
|
|
@ -91,7 +91,12 @@ def on_ui(refresh_sc_browser:gr.Textbox(), recipe_input):
|
|||
except:
|
||||
pass
|
||||
send_to_recipe = gr.Button(value="Send To Recipe", variant="primary", visible=True)
|
||||
|
||||
|
||||
with gr.TabItem("Personal Note" , id="PersonalNote_Information"):
|
||||
with gr.Column():
|
||||
personal_note = gr.Textbox(label="Personal Note", interactive=True, lines=6).style(container=True, show_copy_button=True)
|
||||
personal_note_save = gr.Button(value="Save", variant="primary", visible=True)
|
||||
|
||||
# with gr.Row():
|
||||
# with gr.Column():
|
||||
# refresh_btn = gr.Button(value="Refresh")
|
||||
|
|
@ -123,6 +128,14 @@ def on_ui(refresh_sc_browser:gr.Textbox(), recipe_input):
|
|||
except:
|
||||
pass
|
||||
|
||||
personal_note_save.click(
|
||||
fn=on_personal_note_save_click,
|
||||
inputs=[
|
||||
selected_model_id,
|
||||
personal_note
|
||||
]
|
||||
)
|
||||
|
||||
send_to_recipe.click(
|
||||
fn=on_send_to_recipe_click,
|
||||
inputs=[
|
||||
|
|
@ -268,7 +281,8 @@ def on_ui(refresh_sc_browser:gr.Textbox(), recipe_input):
|
|||
cs_foldername,
|
||||
ms_foldername,
|
||||
change_filename,
|
||||
ms_suggestedname
|
||||
ms_suggestedname,
|
||||
personal_note
|
||||
],
|
||||
cancels=gallery
|
||||
)
|
||||
|
|
@ -303,7 +317,8 @@ def on_ui(refresh_sc_browser:gr.Textbox(), recipe_input):
|
|||
cs_foldername,
|
||||
ms_foldername,
|
||||
change_filename,
|
||||
ms_suggestedname
|
||||
ms_suggestedname,
|
||||
personal_note
|
||||
],
|
||||
cancels=gallery
|
||||
)
|
||||
|
|
@ -339,7 +354,8 @@ def on_ui(refresh_sc_browser:gr.Textbox(), recipe_input):
|
|||
cs_foldername,
|
||||
ms_foldername,
|
||||
change_filename,
|
||||
ms_suggestedname
|
||||
ms_suggestedname,
|
||||
personal_note
|
||||
],
|
||||
cancels=gallery
|
||||
)
|
||||
|
|
@ -393,6 +409,9 @@ def on_ui(refresh_sc_browser:gr.Textbox(), recipe_input):
|
|||
|
||||
return selected_model_id, refresh_information
|
||||
|
||||
def on_personal_note_save_click(modelid, note):
|
||||
ishortcut.update_shortcut_model_note(modelid,note)
|
||||
|
||||
def on_send_to_recipe_click(img_file_info, img_index, civitai_images):
|
||||
# return img_file_info
|
||||
try:
|
||||
|
|
@ -751,7 +770,9 @@ def load_saved_model(modelid=None, ver_index=None):
|
|||
primary = file['primary']
|
||||
|
||||
downloadable.append(['✅',file['id'],file['name'],file['type'],round(file['sizeKB']),primary,file['downloadUrl']])
|
||||
|
||||
|
||||
note = ishortcut.get_shortcut_model_note(modelid)
|
||||
|
||||
return gr.update(value=versionid),gr.update(value=model_url),\
|
||||
gr.update(visible = is_downloaded),gr.update(value=downloaded_info),\
|
||||
gr.update(value=setting.get_ui_typename(model_type)),gr.update(value=model_basemodels),\
|
||||
|
|
@ -764,7 +785,8 @@ def load_saved_model(modelid=None, ver_index=None):
|
|||
gr.update(choices=[setting.CREATE_MODEL_FOLDER] + classification.get_list(), value=cs_foldername),\
|
||||
gr.update(value=ms_foldername, visible=True if cs_foldername == setting.CREATE_MODEL_FOLDER else False),\
|
||||
gr.update(visible=False),\
|
||||
gr.update(choices=suggested_names, value=ms_foldername, visible=True if cs_foldername == setting.CREATE_MODEL_FOLDER else False)
|
||||
gr.update(choices=suggested_names, value=ms_foldername, visible=True if cs_foldername == setting.CREATE_MODEL_FOLDER else False),\
|
||||
gr.update(value=note)
|
||||
|
||||
# 모델 정보가 없다면 클리어 한다.
|
||||
# clear model information
|
||||
|
|
@ -780,7 +802,8 @@ def load_saved_model(modelid=None, ver_index=None):
|
|||
gr.update(choices=[setting.CREATE_MODEL_FOLDER] + classification.get_list(), value=setting.CREATE_MODEL_FOLDER),\
|
||||
gr.update(value=None),\
|
||||
gr.update(visible=False),\
|
||||
gr.update(choices=None, value=None)
|
||||
gr.update(choices=None, value=None),\
|
||||
gr.update(value=None)
|
||||
|
||||
def get_model_information(modelid:str=None, versionid:str=None, ver_index:int=None):
|
||||
# 현재 모델의 정보를 가져온다.
|
||||
|
|
|
|||
|
|
@ -34,6 +34,20 @@ def is_classifications(classification):
|
|||
|
||||
return False
|
||||
|
||||
def update_recipe_shortcuts(recipe, shortcuts:list):
|
||||
if not recipe:
|
||||
return
|
||||
|
||||
RecipeCollection = load()
|
||||
RecipeCollection = update_shortcuts(RecipeCollection, recipe, shortcuts)
|
||||
save(RecipeCollection)
|
||||
|
||||
if RecipeCollection:
|
||||
if recipe in RecipeCollection:
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
def update_recipe_image(recipe, image):
|
||||
if not recipe:
|
||||
return
|
||||
|
|
@ -131,6 +145,24 @@ def get_list(key=None):
|
|||
return result
|
||||
|
||||
#================= raw ===================================
|
||||
def update_shortcuts(RecipeCollection:dict, recipe, shortcuts:list):
|
||||
|
||||
if not RecipeCollection:
|
||||
return RecipeCollection
|
||||
|
||||
if not recipe:
|
||||
return RecipeCollection
|
||||
|
||||
if recipe not in RecipeCollection:
|
||||
return RecipeCollection
|
||||
|
||||
if not shortcuts:
|
||||
return RecipeCollection
|
||||
|
||||
RecipeCollection[recipe]['shortcuts'] = shortcuts
|
||||
|
||||
return RecipeCollection
|
||||
|
||||
def update_image(RecipeCollection:dict, recipe, image):
|
||||
|
||||
if not RecipeCollection:
|
||||
|
|
@ -227,8 +259,9 @@ def create(RecipeCollection:dict, recipe, desc, prompt=None, classification=None
|
|||
RecipeCollection[recipe] = {
|
||||
"description": desc,
|
||||
"generate": prompt,
|
||||
"classification":classification,
|
||||
"image": None
|
||||
"classification": classification,
|
||||
"image": None,
|
||||
"shortcuts":[]
|
||||
}
|
||||
|
||||
return RecipeCollection
|
||||
|
|
@ -262,9 +295,9 @@ def update(RecipeCollection:dict, recipe, name, desc, prompt=None, classificatio
|
|||
sc = {
|
||||
"description": desc,
|
||||
"generate": prompt,
|
||||
"classification":classification,
|
||||
"image": None
|
||||
}
|
||||
"classification": classification
|
||||
# "image": None
|
||||
}
|
||||
RecipeCollection[name] = sc
|
||||
|
||||
return RecipeCollection
|
||||
|
|
|
|||
|
|
@ -384,8 +384,10 @@ def on_recipe_list_select(evt: gr.SelectData):
|
|||
select_name = evt.value
|
||||
|
||||
description, Prompt, negativePrompt, options, gen_string, classification, imagefile = get_recipe_information(select_name)
|
||||
if not os.path.isfile(imagefile):
|
||||
imagefile = None
|
||||
|
||||
if imagefile:
|
||||
if not os.path.isfile(imagefile):
|
||||
imagefile = None
|
||||
|
||||
return gr.update(value=select_name),gr.update(value=description), gr.update(value=Prompt), gr.update(value=negativePrompt), gr.update(value=options), gr.update(value=gen_string), gr.update(choices=[setting.PLACEHOLDER] + recipe.get_classifications(), value=classification), gr.update(label=select_name),imagefile,None,\
|
||||
gr.update(visible=False), gr.update(visible=True)
|
||||
|
|
|
|||
|
|
@ -7,8 +7,12 @@ from . import model
|
|||
from . import classification
|
||||
from . import ishortcut
|
||||
|
||||
DOWNLOADED_MODEL = "Downloaded"
|
||||
NOT_DOWNLOADED_MODEL = "Not Downloaded"
|
||||
ALL_DOWNLOADED_MODEL = "All"
|
||||
|
||||
def get_thumbnail_list(shortcut_types=None, only_downloaded=False, search=None, shortcut_basemodels=None, sc_classifications=None, page = 0):
|
||||
# def get_thumbnail_list(shortcut_types=None, downloaded_sc=ALL_DOWNLOADED_MODEL, search=None, shortcut_basemodels=None, sc_classifications=None, page = 0):
|
||||
def get_thumbnail_list(shortcut_types=None, downloaded_sc=False, search=None, shortcut_basemodels=None, sc_classifications=None, page = 0):
|
||||
|
||||
total = 0
|
||||
max_page = 1
|
||||
|
|
@ -17,8 +21,29 @@ def get_thumbnail_list(shortcut_types=None, only_downloaded=False, search=None,
|
|||
|
||||
if not shortlist:
|
||||
return None, total, max_page
|
||||
|
||||
# if downloaded_sc == DOWNLOADED_MODEL:
|
||||
# if model.Downloaded_Models:
|
||||
# downloaded_list = list()
|
||||
# for short in shortlist:
|
||||
# sc_name = short[1]
|
||||
# mid = setting.get_modelid_from_shortcutname(sc_name)
|
||||
# if mid in model.Downloaded_Models.keys():
|
||||
# downloaded_list.append(short)
|
||||
# shortlist = downloaded_list
|
||||
# else:
|
||||
# shortlist = None
|
||||
# elif downloaded_sc == NOT_DOWNLOADED_MODEL:
|
||||
# if model.Downloaded_Models:
|
||||
# downloaded_list = list()
|
||||
# for short in shortlist:
|
||||
# sc_name = short[1]
|
||||
# mid = setting.get_modelid_from_shortcutname(sc_name)
|
||||
# if mid not in model.Downloaded_Models.keys():
|
||||
# downloaded_list.append(short)
|
||||
# shortlist = downloaded_list
|
||||
|
||||
if only_downloaded:
|
||||
if downloaded_sc:
|
||||
if model.Downloaded_Models:
|
||||
downloaded_list = list()
|
||||
for short in shortlist:
|
||||
|
|
@ -49,47 +74,23 @@ def get_thumbnail_list(shortcut_types=None, only_downloaded=False, search=None,
|
|||
|
||||
return result, total, max_page
|
||||
|
||||
def on_refresh_sc_list_change(sc_types, sc_search, sc_basemodels, sc_classifications, show_only_downloaded_sc,sc_page):
|
||||
def on_refresh_sc_list_change(sc_types, sc_search, sc_basemodels, sc_classifications, show_downloaded_sc,sc_page):
|
||||
|
||||
thumb_list , thumb_totals, thumb_max_page = get_thumbnail_list(sc_types,show_only_downloaded_sc,sc_search,sc_basemodels,sc_classifications,sc_page)
|
||||
thumb_list , thumb_totals, thumb_max_page = get_thumbnail_list(sc_types,show_downloaded_sc,sc_search,sc_basemodels,sc_classifications,sc_page)
|
||||
|
||||
# 현재 페이지가 최대 페이지보다 크면 (최대 페이지를 현재 페이지로 넣고)다시한번 리스트를 구한다.
|
||||
if thumb_max_page < sc_page:
|
||||
sc_page = thumb_max_page
|
||||
thumb_list , thumb_totals, thumb_max_page = get_thumbnail_list(sc_types,show_only_downloaded_sc,sc_search,sc_basemodels,sc_classifications,sc_page)
|
||||
thumb_list , thumb_totals, thumb_max_page = get_thumbnail_list(sc_types,show_downloaded_sc,sc_search,sc_basemodels,sc_classifications,sc_page)
|
||||
|
||||
return gr.update(value=thumb_list),gr.update(choices=classification.get_list()),gr.update(minimum=1, maximum=thumb_max_page, value=sc_page, step=1, label=f"Total {thumb_max_page} Pages"),thumb_list
|
||||
|
||||
def on_shortcut_gallery_refresh(sc_types, sc_search, sc_basemodels, sc_classifications, show_only_downloaded_sc):
|
||||
thumb_list , thumb_totals, thumb_max_page = get_thumbnail_list(sc_types,show_only_downloaded_sc,sc_search,sc_basemodels,sc_classifications,1)
|
||||
def on_shortcut_gallery_refresh(sc_types, sc_search, sc_basemodels, sc_classifications, show_downloaded_sc):
|
||||
thumb_list , thumb_totals, thumb_max_page = get_thumbnail_list(sc_types,show_downloaded_sc,sc_search,sc_basemodels,sc_classifications,1)
|
||||
return gr.update(value=thumb_list),gr.update(minimum=1, maximum=thumb_max_page, value=1, step=1, label=f"Total {thumb_max_page} Pages"),thumb_list
|
||||
|
||||
# def on_sc_classification_list_select(evt: gr.SelectData,sc_types, sc_search, sc_basemodels, show_only_downloaded_sc):
|
||||
# keys, tags, clfs = util.get_search_keyword(sc_search)
|
||||
# search = ""
|
||||
# new_search = list()
|
||||
|
||||
# if keys:
|
||||
# new_search.extend(keys)
|
||||
|
||||
# if tags:
|
||||
# new_tags = [f"#{tag}" for tag in tags]
|
||||
# new_search.extend(new_tags)
|
||||
|
||||
# if evt.value != setting.PLACEHOLDER:
|
||||
# select_name = evt.value
|
||||
|
||||
# if select_name and len(select_name.strip()) > 0:
|
||||
# new_search.append(f"@{select_name.strip()}")
|
||||
|
||||
# if new_search:
|
||||
# search = ", ".join(new_search)
|
||||
|
||||
# thumb_list , thumb_totals, thumb_max_page = get_thumbnail_list(sc_types,show_only_downloaded_sc,search,sc_basemodels,1)
|
||||
# return gr.update(value=search),gr.update(value=thumb_list),gr.update(minimum=1, maximum=thumb_max_page, value=1, step=1, label=f"Total {thumb_max_page} Pages"),thumb_list
|
||||
|
||||
def on_sc_gallery_page(sc_types, sc_search, sc_basemodels, sc_classifications, show_only_downloaded_sc,sc_page):
|
||||
thumb_list , thumb_totals, thumb_max_page = get_thumbnail_list(sc_types,show_only_downloaded_sc,sc_search,sc_basemodels,sc_classifications,sc_page)
|
||||
def on_sc_gallery_page(sc_types, sc_search, sc_basemodels, sc_classifications, show_downloaded_sc,sc_page):
|
||||
thumb_list , thumb_totals, thumb_max_page = get_thumbnail_list(sc_types,show_downloaded_sc,sc_search,sc_basemodels,sc_classifications,sc_page)
|
||||
return gr.update(value=thumb_list),thumb_list
|
||||
|
||||
def on_ui():
|
||||
|
|
@ -98,10 +99,12 @@ def on_ui():
|
|||
|
||||
with gr.Accordion("Search", open=True):
|
||||
shortcut_type = gr.Dropdown(label='Filter Model Type', multiselect=True, choices=[k for k in setting.ui_typenames], interactive=True)
|
||||
sc_search = gr.Textbox(label="Search", value="", placeholder="Search name, #tags, ....",interactive=True, lines=1)
|
||||
sc_search = gr.Textbox(label="Search", value="", placeholder="Search name, #tags, @personal note ....",interactive=True, lines=1)
|
||||
sc_classification_list = gr.Dropdown(label='Classification',info="The selection options of classification are subject to the AND operation.", multiselect=True, choices=classification.get_list(), interactive=True)
|
||||
shortcut_basemodel = gr.Dropdown(label='Filter Model BaseModel', multiselect=True, choices=[k for k in setting.model_basemodels], interactive=True)
|
||||
show_only_downloaded_sc = gr.Checkbox(label="Show downloaded model's shortcut only", value=False)
|
||||
show_downloaded_sc = gr.Checkbox(label="Show downloaded model's shortcut only", value=False)
|
||||
# show_downloaded_sc = gr.Dropdown(label='Filter Downloaded Model View', multiselect=False, choices=[ALL_DOWNLOADED_MODEL,DOWNLOADED_MODEL,NOT_DOWNLOADED_MODEL], value=ALL_DOWNLOADED_MODEL, interactive=True)
|
||||
|
||||
sc_gallery_page = gr.Slider(minimum=1, maximum=thumb_max_page, value=1, step=1, label=f"Total {thumb_max_page} Pages", interactive=True, visible=True if setting.shortcut_count_per_page > 0 else False)
|
||||
# elem_id 를 안써줘야 옆의 인포와 연동이 안된다. 인포쪽에는 써줘야 할것....
|
||||
sc_gallery = gr.Gallery(show_label=False, value=thumb_list).style(grid=[setting.shortcut_column], height=["fit" if setting.shortcut_count_per_page != 0 else "auto"], object_fit=setting.gallery_thumbnail_image_style)
|
||||
|
|
@ -120,7 +123,7 @@ def on_ui():
|
|||
sc_search,
|
||||
shortcut_basemodel,
|
||||
sc_classification_list,
|
||||
show_only_downloaded_sc,
|
||||
show_downloaded_sc,
|
||||
sc_gallery_page
|
||||
],
|
||||
outputs=[
|
||||
|
|
@ -136,7 +139,7 @@ def on_ui():
|
|||
sc_search,
|
||||
shortcut_basemodel,
|
||||
sc_classification_list,
|
||||
show_only_downloaded_sc,
|
||||
show_downloaded_sc,
|
||||
sc_gallery_page
|
||||
],
|
||||
outputs=[
|
||||
|
|
@ -155,7 +158,7 @@ def on_ui():
|
|||
sc_search,
|
||||
shortcut_basemodel,
|
||||
sc_classification_list,
|
||||
show_only_downloaded_sc,
|
||||
show_downloaded_sc,
|
||||
],
|
||||
outputs=[
|
||||
sc_gallery,
|
||||
|
|
@ -171,7 +174,7 @@ def on_ui():
|
|||
sc_search,
|
||||
shortcut_basemodel,
|
||||
sc_classification_list,
|
||||
show_only_downloaded_sc,
|
||||
show_downloaded_sc,
|
||||
],
|
||||
outputs=[
|
||||
sc_gallery,
|
||||
|
|
@ -187,7 +190,7 @@ def on_ui():
|
|||
sc_search,
|
||||
shortcut_basemodel,
|
||||
sc_classification_list,
|
||||
show_only_downloaded_sc,
|
||||
show_downloaded_sc,
|
||||
],
|
||||
outputs=[
|
||||
sc_gallery,
|
||||
|
|
@ -196,14 +199,14 @@ def on_ui():
|
|||
]
|
||||
)
|
||||
|
||||
show_only_downloaded_sc.change(
|
||||
show_downloaded_sc.change(
|
||||
fn=on_shortcut_gallery_refresh,
|
||||
inputs=[
|
||||
shortcut_type,
|
||||
sc_search,
|
||||
shortcut_basemodel,
|
||||
sc_classification_list,
|
||||
show_only_downloaded_sc,
|
||||
show_downloaded_sc,
|
||||
],
|
||||
outputs=[
|
||||
sc_gallery,
|
||||
|
|
@ -219,7 +222,7 @@ def on_ui():
|
|||
sc_search,
|
||||
shortcut_basemodel,
|
||||
sc_classification_list,
|
||||
show_only_downloaded_sc,
|
||||
show_downloaded_sc,
|
||||
],
|
||||
outputs=[
|
||||
sc_gallery,
|
||||
|
|
@ -227,21 +230,5 @@ def on_ui():
|
|||
sc_gallery_result
|
||||
]
|
||||
)
|
||||
|
||||
# sc_classification_list.select(
|
||||
# fn=on_sc_classification_list_select,
|
||||
# inputs=[
|
||||
# shortcut_type,
|
||||
# sc_search,
|
||||
# shortcut_basemodel,
|
||||
# show_only_downloaded_sc,
|
||||
# ],
|
||||
# outputs=[
|
||||
# sc_search,
|
||||
# sc_gallery,
|
||||
# sc_gallery_page,
|
||||
# sc_gallery_result
|
||||
# ]
|
||||
# )
|
||||
|
||||
return sc_gallery, refresh_sc_browser, refresh_sc_gallery
|
||||
|
|
@ -12,7 +12,7 @@ extension_base = scripts.basedir()
|
|||
headers={'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36 Edg/112.0.1722.68'}
|
||||
|
||||
Extensions_Name = "Civitai Shortcut"
|
||||
Extensions_Version = "v 1.5.7"
|
||||
Extensions_Version = "v 1.5.8"
|
||||
|
||||
PLACEHOLDER = "[No Select]"
|
||||
NORESULT = "[No Result]"
|
||||
|
|
|
|||
|
|
@ -165,9 +165,10 @@ def open_folder(path):
|
|||
def get_search_keyword(search:str):
|
||||
tags = []
|
||||
keys = []
|
||||
notes = []
|
||||
|
||||
if not search:
|
||||
return None, None
|
||||
return None, None, None
|
||||
|
||||
for word in search.split(","):
|
||||
word = word.strip()
|
||||
|
|
@ -176,12 +177,17 @@ def get_search_keyword(search:str):
|
|||
tag = word[1:].lower()
|
||||
if tag not in tags:
|
||||
tags.append(tag)
|
||||
elif word.startswith("@"):
|
||||
if len(word) > 1:
|
||||
note = word[1:]
|
||||
if note not in notes:
|
||||
notes.append(note)
|
||||
else:
|
||||
word = word.lower()
|
||||
if word not in keys:
|
||||
keys.append(word)
|
||||
|
||||
return keys if len(keys) > 0 else None, tags if len(tags) > 0 else None
|
||||
return keys if len(keys) > 0 else None, tags if len(tags) > 0 else None, notes if len(notes) > 0 else None
|
||||
|
||||
# def get_search_keyword(search:str):
|
||||
# tags = []
|
||||
|
|
|
|||
Loading…
Reference in New Issue