v1.4a update

pull/22/head
joonsun01 2023-05-13 20:02:23 +09:00
parent 706c0ee7a9
commit 5c70cc8829
18 changed files with 745 additions and 271 deletions

View File

@ -62,6 +62,44 @@ Civitai 사이트의 모델 URL을 저장하여 나중에 참조하고 보관할
* CivitaiShortCutSetting.json: a JSON file that records setting. * CivitaiShortCutSetting.json: a JSON file that records setting.
# Change Log # Change Log
v 1.4a
* 인터페이스 디자인 인이 변경되었습니다.
* 다운 받을 파일에 대한 좀더 자세한 정보를 제공하도록 변경되었습니다.
* 파일을 선택하지 않고 다운로드 시에도 version information 파일과 preview 이미지를 생성 하도록 변경하였습니다.
* 실제 파일을 다운 로드 하지 않고도 Downloaded Model Information을 이용하실수 있습니다.
* 파일을 다운 받지 않았어도 다운 받은걸로 인식되므로 참고 부탁드립니다.
* 인포메이션탭에서 제공하는 open folder 기능은 여러곳에 중복 다운로드했을시 부정확할수 있습니다.
정확한 내용을 알고 싶으시면 Downloaded Model Information tab 을 활용해주세요.
* Downloaded Model Information tab 에서 파일명이 동일한 파일을 다운 받을 경우 모두 다은받은걸로 인식되는 오류가 있습니다.
* Manage -> Classification 디자인 과 기능에 일부 변경이 있습니다.
* Classification 의 생성 수정 삭제 업데이트 기능이 좌측의 Shortcut Item 항목과 통합되었습니다.
- Update 기능은 classification 의 이름과 설명의 Update만 합니다.
- classification에 등록되는 shortcut Item 의 저장은 Save Classification Shortcuts 을 이용하셔야 합니다.
* Manage -> Setting 에 Screen Style 항목이 추가되었습니다.
Shortcut Brower 와 Information Tab 간의 비율을 설정할수있습니다.
자신의 모니터나 작업취향에 따라 적절한 비율을 선택하시고 적용할수 있습니다.
Shortcut Browser and Information Images 항목과 적절히 조합하시길 추천드립니다.
* Download Folder for Extensions 에 LyCORIS의 다운로드 위치를 설정할수 있는 항목이 추가 되었습니다.
기존에 는 LoRA 폴더를 같이 이용했지만 LyCORIS확장을 사용하시면 extra networks 에서도 인식되는것을 알게되어 적절히 수정 하실수 있게 추가 하였습니다.
(알려주시어 감사합니다.)
* Reload UI 버튼이 추가 되었습니다. SDUI 를 리로드 시킵니다.
단 setting을 저장하는 기능은 넣지 않았습니다. 저장은 옆의 Save Setting 버튼을 이용해주세요. :)
* Upload 항목에 업로드 되는 파일의 내부 형식을 조금 변경하였습니다.
- url=civitai model url 의 구성을하면 인식되도록 수정하였습니다.
- e.g.)
sample.txt :
url=https://civitai.com/models/64863/cute-oil-impasto-chibi
url=https://civitai.com/models/64850/koga-tomoe-from-bunny-girl-senpai
url=https://civitai.com/models/64849/blackwhite
* Upload 의 드래그 & 드롭이 리눅스 환경에서 제대로 작동 되지 않습니다.
불편하시겠지만 당분간 윗쪽의 Textbox 를 활용해주세요.
v 1.4 v 1.4
* 인포메이션 탭에 Downloaded Model Information 탭이 추가 되었습니다. * 인포메이션 탭에 Downloaded Model Information 탭이 추가 되었습니다.
현재 다운로드한 파일의 정보를 확인 할 수 있는 탭입니다. 다운로드한 모델의 버전 리스트가 나타나며 선택시 하단에 세부 정보가 나타납니다. 세부표시 항목에서는 실제 다운 로드한 파일의 정보를 확인할수 있으며 다운로드된 폴더에 접근할수 있습니다. 파일 중복등의 사유로 다소 부정확할수 있습니다. 또한 해당버전의 Civitai 제공 정보를 json형태로 확인 하실수 있습니다. 현재 다운로드한 파일의 정보를 확인 할 수 있는 탭입니다. 다운로드한 모델의 버전 리스트가 나타나며 선택시 하단에 세부 정보가 나타납니다. 세부표시 항목에서는 실제 다운 로드한 파일의 정보를 확인할수 있으며 다운로드된 폴더에 접근할수 있습니다. 파일 중복등의 사유로 다소 부정확할수 있습니다. 또한 해당버전의 Civitai 제공 정보를 json형태로 확인 하실수 있습니다.
@ -178,6 +216,14 @@ v 1.1
*전체 모델 정보를 업데이트하는 "Update Shortcut's Model Information" 버튼 외에 개별적으로 모델 정보를 업데이트할 수 있는 "Update Model Information" 버튼이 "Saved Model Information" 탭에 추가됩니다. *전체 모델 정보를 업데이트하는 "Update Shortcut's Model Information" 버튼 외에 개별적으로 모델 정보를 업데이트할 수 있는 "Update Model Information" 버튼이 "Saved Model Information" 탭에 추가됩니다.
# Screenshot # Screenshot
![screenshot 2023-05-13 183202](https://github.com/sunnyark/civitai-shortcut/assets/40237431/52943efb-6e7e-4cc9-bbac-a6717bfcee72)
![screenshot 2023-05-13 183214](https://github.com/sunnyark/civitai-shortcut/assets/40237431/3867dcf2-bc6e-4fd3-85e5-05f4fba0ff8a)
![screenshot 2023-05-13 183245](https://github.com/sunnyark/civitai-shortcut/assets/40237431/a9e9e1a6-6fe9-4beb-b54c-f092d785c9ea)
![screenshot 2023-05-13 183323](https://github.com/sunnyark/civitai-shortcut/assets/40237431/28dc11b9-1b6e-4690-a506-9775eea61647)
![screenshot 2023-05-11 114638](https://github.com/sunnyark/civitai-shortcut/assets/40237431/44bd5e89-b467-4cc5-9dfc-9f759ac9e483) ![screenshot 2023-05-11 114638](https://github.com/sunnyark/civitai-shortcut/assets/40237431/44bd5e89-b467-4cc5-9dfc-9f759ac9e483)
![screenshot 2023-05-11 113805](https://github.com/sunnyark/civitai-shortcut/assets/40237431/f863236e-618f-46cd-952e-afc4bdac3208) ![screenshot 2023-05-11 113805](https://github.com/sunnyark/civitai-shortcut/assets/40237431/f863236e-618f-46cd-952e-afc4bdac3208)

View File

@ -61,6 +61,41 @@ When using Civitai Shortcut, five items will be created:
* CivitaiShortCutSetting.json: a JSON file that records setting. * CivitaiShortCutSetting.json: a JSON file that records setting.
# Change Log # Change Log
v 1.4a
* The interface design has been changed.
* More detailed information about the file to be downloaded is provided.
* A version information file and preview image will be generated even if a file is not selected for download.
You can use the "Downloaded Model Information Tab" without actually downloading the file.
Please note that even if you have not downloaded the file, it will be recognized as downloaded.
* The "open folder" function provided in the information tab may be inaccurate if the same file is downloaded multiple times from different locations.
Please use the "Downloaded Model Information Tab" for accurate information.
* There is an error in the "Downloaded Model Information Tab" where downloading files with the same filename will be recognized as all downloaded.
* There have been some design and functionality changes to the Manage -> Classification section.
* The create, modify, delete, and update functions for classification have been integrated with the "Shortcut Item" section on the left.
- The update function only updates the name and description of the classification.
- Saving shortcut items registered to the classification should be done using "Save Classification Shortcuts".
* The "Screen Style" option has been added to Manage -> Setting.
You can adjust the ratio between Shortcut Browser and Information Tab according to your monitor or work preference, and apply it.
I recommend combining this feature with the Shortcut Browser and Information Images options to find a suitable combination.
* A new option has been added to set the download folder location for LyCORIS in "Download Folder for Extensions" settings.
Previously, LoRA folder was used together, but now it has been added to allow appropriate modifications since LyCORIS extension can also be recognized in extra networks. (Thank you for letting me know.)
* A "Reload UI" button has been added. It reloads the SDUI.
However, please note that it does not include a feature to save settings. Please use the "Save Setting" button next to it for that purpose. :)
* The internal format of the uploaded files in the Upload section has been slightly modified.
The format of "url=civitai model url" has been modified to be recognized.
e.g.)
sample.txt:
url=https://civitai.com/models/64863/cute-oil-impasto-chibi
url=https://civitai.com/models/64850/koga-tomoe-from-bunny-girl-senpai
url=https://civitai.com/models/64849/blackwhite
* Drag & drop feature in Upload does not work properly in Linux environment.
I apologize for the inconvenience, but please use the textbox above for the time being.
v 1.4 v 1.4
@ -152,6 +187,13 @@ v 1.1
* "Update Model Information" button is added to "Saved Model Information" Tab for individual updating of model information, in addition to "Update Shortcut's Model Information" that updates all model information. * "Update Model Information" button is added to "Saved Model Information" Tab for individual updating of model information, in addition to "Update Shortcut's Model Information" that updates all model information.
# Screenshot # Screenshot
![screenshot 2023-05-13 183202](https://github.com/sunnyark/civitai-shortcut/assets/40237431/52943efb-6e7e-4cc9-bbac-a6717bfcee72)
![screenshot 2023-05-13 183214](https://github.com/sunnyark/civitai-shortcut/assets/40237431/3867dcf2-bc6e-4fd3-85e5-05f4fba0ff8a)
![screenshot 2023-05-13 183245](https://github.com/sunnyark/civitai-shortcut/assets/40237431/a9e9e1a6-6fe9-4beb-b54c-f092d785c9ea)
![screenshot 2023-05-13 183323](https://github.com/sunnyark/civitai-shortcut/assets/40237431/28dc11b9-1b6e-4690-a506-9775eea61647)
![screenshot 2023-05-11 114638](https://github.com/sunnyark/civitai-shortcut/assets/40237431/44bd5e89-b467-4cc5-9dfc-9f759ac9e483) ![screenshot 2023-05-11 114638](https://github.com/sunnyark/civitai-shortcut/assets/40237431/44bd5e89-b467-4cc5-9dfc-9f759ac9e483)

View File

@ -57,7 +57,7 @@ def get_model_info(id:str) -> dict:
except Exception as e: except Exception as e:
return None return None
return content return content
def get_model_info_by_version_id(version_id:str) -> dict: def get_model_info_by_version_id(version_id:str) -> dict:
@ -81,13 +81,13 @@ def get_version_info_by_hash(hash) -> dict:
try: try:
with requests.get(f"{Url_Hash()}{hash}") as response: with requests.get(f"{Url_Hash()}{hash}") as response:
content = response.json() content = response.json()
if 'id' not in content.keys(): if 'id' not in content.keys():
return None return None
except Exception as e: except Exception as e:
return None return None
return content return content
def get_version_info_by_version_id(version_id:str) -> dict: def get_version_info_by_version_id(version_id:str) -> dict:

View File

@ -13,47 +13,67 @@ from . import setting
from . import downloader from . import downloader
from . import classification from . import classification
from tqdm import tqdm
from PIL import Image from PIL import Image
def on_ui(refresh_sc_list:gr.Textbox()): def on_ui(refresh_sc_list:gr.Textbox()):
with gr.Column(scale=3):
with gr.Accordion("#", open=True) as model_title_name:
versions_list = gr.Dropdown(label="Model Version", choices=[setting.NORESULT], interactive=True, value=setting.NORESULT)
with gr.Tabs():
with gr.TabItem("Images" , id="Model_Images"):
civitai_gallery = gr.Gallery(show_label=False, elem_id="civitai_gallery").style(grid=[setting.gallery_column], height=setting.information_gallery_height, object_fit=setting.gallery_thumbnail_image_style)
with gr.Row():
download_images = gr.Button(value="Download Images")
open_image_folder = gr.Button(value="Open Download Image Folder")
with gr.TabItem("Description" , id="Model_Description"):
description_html = gr.HTML()
with gr.TabItem("Download" , id="Model_Download"):
gr.Markdown("Downloadable Files")
downloadable_files = gr.DataFrame(
headers=["","ID","Filename","Type","SizeKB","DownloadUrl"],
datatype=["str","str","str","str","str","str"],
col_count=(6,"fixed"),
interactive=False,
type="array",
)
filename_list = gr.CheckboxGroup (show_label=False , label="Model Version File", choices=[], value=[], interactive=True, visible=False)
cs_foldername = gr.Dropdown(label='Download Folder Select', multiselect=None, choices=[setting.CREATE_MODEL_FOLDER] + classification.get_list(), value=setting.CREATE_MODEL_FOLDER, interactive=True)
vs_folder = gr.Checkbox(label="Create individual version folder", value=False, visible=True , interactive=True)
vs_folder_name = gr.Textbox(label="Folder name to create", value="", show_label=False, interactive=True, lines=1, visible=False).style(container=True)
download_model = gr.Button(value="Download", variant="primary")
gr.Markdown("Downloading may take some time. Check console log for detail")
with gr.Column(scale=1): with gr.Column(scale=1):
versions_list = gr.Dropdown(label="Model Version", choices=[setting.NORESULT], interactive=True, value=setting.NORESULT) with gr.Tabs() as info_tabs:
model_type = gr.Textbox(label="Model Type", value="", interactive=False, lines=1) with gr.TabItem("Information" , id="Model_Information"):
trigger_words = gr.Textbox(label="Trigger Words", value="", interactive=False, lines=1).style(container=True, show_copy_button=True) model_type = gr.Textbox(label="Model Type", value="", interactive=False, lines=1)
civitai_model_url_txt = gr.Textbox(label="Model Url", value="", interactive=False , lines=1).style(container=True, show_copy_button=True) trigger_words = gr.Textbox(label="Trigger Words", value="", interactive=False, lines=1).style(container=True, show_copy_button=True)
civitai_model_url_txt = gr.Textbox(label="Model Url", value="", interactive=False , lines=1).style(container=True, show_copy_button=True)
with gr.Accordion("Downloaded Version", open=False) as downloaded_tab: with gr.Row():
downloaded_info = gr.Textbox(interactive=False,show_label=False) with gr.Column():
with gr.Accordion("Classcification", open=True):
with gr.Accordion("Download", open=True): model_classification = gr.Dropdown(label='Classcification', show_label=False ,multiselect=True, interactive=True, choices=classification.get_list())
filename_list = gr.CheckboxGroup (label="Model Version File", info="Select the files you want to download", choices=[], value=[], interactive=True) model_classification_update_btn = gr.Button(value="Update",variant="primary")
cs_foldername = gr.Dropdown(label='Download Folder Select', multiselect=None, choices=[setting.CREATE_MODEL_FOLDER] + classification.get_list(), value=setting.CREATE_MODEL_FOLDER, interactive=True)
vs_folder = gr.Checkbox(label="Create individual version folder", value=False, visible=True , interactive=True) with gr.Accordion("Downloaded Version", open=True, visible=False) as downloaded_tab:
vs_folder_name = gr.Textbox(label="Folder name to create", value="", show_label=False, interactive=True, lines=1, visible=False).style(container=True) downloaded_info = gr.Textbox(interactive=False,show_label=False)
download_model = gr.Button(value="Download", variant="primary") civitai_openfolder = gr.Button(value="Open Download Folder",variant="primary" , visible=False)
civitai_openfolder = gr.Button(value="Open Download Folder",variant="primary" , visible=False) with gr.Row():
gr.Markdown("Downloading may take some time.\nCheck console log for detail") with gr.Column():
with gr.Column(scale=4):
with gr.Accordion("#", open=True) as model_title_name: refresh_btn = gr.Button(value="Refresh")
civitai_gallery = gr.Gallery(show_label=False, elem_id="civitai_gallery").style(grid=[setting.gallery_column],height="auto", object_fit=setting.gallery_thumbnail_image_style) with gr.TabItem("Image Information" , id="Image_Information"):
with gr.Accordion("Model Description", open=True): with gr.Column():
description_html = gr.HTML() img_file_info = gr.Textbox(label="Generate Info", interactive=True, lines=6).style(container=True, show_copy_button=True)
try:
with gr.Column(scale=1): send_to_buttons = modules.generation_parameters_copypaste.create_buttons(["txt2img", "img2img", "inpaint", "extras"])
img_file_info = gr.Textbox(label="Generate Info", interactive=True, lines=6).style(container=True, show_copy_button=True) except:
try: pass
send_to_buttons = modules.generation_parameters_copypaste.create_buttons(["txt2img", "img2img", "inpaint", "extras"])
except:
pass
download_images = gr.Button(value="Download Images")
refresh_btn = gr.Button(value="Refresh")
with gr.Accordion("Model Classcification", open=True):
model_classification = gr.Dropdown(label='Classcification', multiselect=True, interactive=True, choices=classification.get_list())
model_classification_update_btn = gr.Button(value="Update",variant="primary")
with gr.Row(visible=False): with gr.Row(visible=False):
selected_model_id = gr.Textbox() selected_model_id = gr.Textbox()
selected_version_id = gr.Textbox() selected_version_id = gr.Textbox()
@ -75,6 +95,18 @@ def on_ui(refresh_sc_list:gr.Textbox()):
except: except:
pass pass
downloadable_files.select(
fn=on_downloadable_files_select,
inputs=[
downloadable_files,
filename_list
],
outputs=[
downloadable_files,
filename_list,
]
)
gallery = refresh_gallery.change( gallery = refresh_gallery.change(
fn=on_civitai_gallery_loading, fn=on_civitai_gallery_loading,
inputs=[ inputs=[
@ -145,6 +177,7 @@ def on_ui(refresh_sc_list:gr.Textbox()):
description_html, description_html,
trigger_words, trigger_words,
filename_list, filename_list,
downloadable_files,
model_title_name, model_title_name,
refresh_gallery, refresh_gallery,
civitai_images_url, civitai_images_url,
@ -174,6 +207,7 @@ def on_ui(refresh_sc_list:gr.Textbox()):
description_html, description_html,
trigger_words, trigger_words,
filename_list, filename_list,
downloadable_files,
model_title_name, model_title_name,
refresh_gallery, refresh_gallery,
civitai_images_url, civitai_images_url,
@ -203,6 +237,7 @@ def on_ui(refresh_sc_list:gr.Textbox()):
description_html, description_html,
trigger_words, trigger_words,
filename_list, filename_list,
downloadable_files,
model_title_name, model_title_name,
refresh_gallery, refresh_gallery,
civitai_images_url, civitai_images_url,
@ -218,13 +253,50 @@ def on_ui(refresh_sc_list:gr.Textbox()):
) )
refresh_btn.click(lambda :datetime.datetime.now(),None,refresh_information,cancels=gallery) refresh_btn.click(lambda :datetime.datetime.now(),None,refresh_information,cancels=gallery)
civitai_gallery.select(on_gallery_select, civitai_images, [img_index, hidden]) civitai_gallery.select(on_gallery_select, civitai_images, [img_index, hidden, info_tabs])
hidden.change(on_civitai_hidden_change,[hidden,img_index,civitai_images_meta],[img_file_info]) hidden.change(on_civitai_hidden_change,[hidden,img_index,civitai_images_meta],[img_file_info])
civitai_openfolder.click(on_open_folder_click,[selected_model_id,selected_version_id],None) civitai_openfolder.click(on_open_folder_click,[selected_model_id,selected_version_id],None)
vs_folder.change(lambda x:gr.update(visible=x),vs_folder,vs_folder_name) vs_folder.change(lambda x:gr.update(visible=x),vs_folder,vs_folder_name)
open_image_folder.click(on_open_image_folder_click,[selected_model_id],None)
return selected_model_id , refresh_information return selected_model_id , refresh_information
def on_open_image_folder_click(modelid):
if modelid:
model_info = civitai.get_model_info(modelid)
if model_info:
model_name = model_info['name']
image_folder = util.get_download_image_folder(model_name)
if image_folder:
util.open_folder(image_folder)
def on_downloadable_files_select(evt: gr.SelectData, df, filenames):
# util.printD(evt.index)
# index[0] # 행,열
vid = None
vname = None
dn_name = None
if df:
vid = df[evt.index[0]][1]
vname = df[evt.index[0]][2]
dn_name = f"{vid}:{vname}"
if vid:
if filenames:
if dn_name in filenames:
filenames.remove(dn_name)
df[evt.index[0]][0] = '⬜️'
else:
filenames.append(dn_name)
df[evt.index[0]][0] = ''
else:
filenames = [dn_name]
df[evt.index[0]][0] = ''
return df, gr.update(value=filenames)
def on_cs_foldername_select(evt: gr.SelectData): def on_cs_foldername_select(evt: gr.SelectData):
if evt.value == setting.CREATE_MODEL_FOLDER: if evt.value == setting.CREATE_MODEL_FOLDER:
return gr.update(visible=True,value=False),gr.update(visible=False) return gr.update(visible=True,value=False),gr.update(visible=False)
@ -302,7 +374,7 @@ def on_download_images_click(version_id:str, images_url):
current_time = datetime.datetime.now() current_time = datetime.datetime.now()
def on_gallery_select(evt: gr.SelectData, civitai_images): def on_gallery_select(evt: gr.SelectData, civitai_images):
return evt.index, civitai_images[evt.index] return evt.index, civitai_images[evt.index], gr.update(selected="Image_Information")
def on_open_folder_click(mid,vid): def on_open_folder_click(mid,vid):
path = model.get_default_version_folder(vid) path = model.get_default_version_folder(vid)
@ -324,7 +396,7 @@ def on_versions_list_select(evt: gr.SelectData, modelid:str):
def load_model(modelid, ver_index): def load_model(modelid, ver_index):
if modelid: if modelid:
model_info,versionid,version_name,model_url,downloaded_versions_list,model_type,versions_list,dhtml,triger,flist,title_name,images_url,images_meta,vs_foldername = get_model_information(modelid,None,ver_index) model_info,versionid,version_name,model_url,downloaded_versions_list,model_type,versions_list,dhtml,triger,files,title_name,images_url,images_meta,vs_foldername = get_model_information(modelid,None,ver_index)
if model_info: if model_info:
downloaded_info = None downloaded_info = None
is_downloaded = False is_downloaded = False
@ -342,10 +414,17 @@ def load_model(modelid, ver_index):
current_time = datetime.datetime.now() current_time = datetime.datetime.now()
classification_list = classification.get_classification_names_by_modelid(modelid) classification_list = classification.get_classification_names_by_modelid(modelid)
flist = list()
downloadable = list()
for file in files:
flist.append(f"{file['id']}:{file['name']}")
downloadable.append(['',file['id'],file['name'],file['type'],round(file['sizeKB']),file['downloadUrl']])
return gr.update(value=versionid),gr.update(value=model_url),gr.update(visible = is_downloaded),gr.update(value=downloaded_info),\ 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(choices=versions_list,value=version_name),gr.update(value=dhtml),\ gr.update(value=setting.get_ui_typename(model_type)),gr.update(choices=versions_list,value=version_name),gr.update(value=dhtml),\
gr.update(value=triger),gr.update(choices=flist if flist else [], value=flist if flist else []),gr.update(label=title_name),\ gr.update(value=triger),gr.update(choices=flist if flist else [], value=flist if flist else []), downloadable if len(downloadable) > 0 else None,\
gr.update(label=title_name),\
current_time,images_url,images_meta,gr.update(value=None),gr.update(visible=is_visible_openfolder),gr.update(value=False, visible=True),gr.update(value=vs_foldername, visible=False),\ current_time,images_url,images_meta,gr.update(value=None),gr.update(visible=is_visible_openfolder),gr.update(value=False, visible=True),gr.update(value=vs_foldername, visible=False),\
gr.update(choices=classification.get_list(),value=classification_list),\ gr.update(choices=classification.get_list(),value=classification_list),\
gr.update(choices=[setting.CREATE_MODEL_FOLDER] + classification.get_list(), value=setting.CREATE_MODEL_FOLDER) gr.update(choices=[setting.CREATE_MODEL_FOLDER] + classification.get_list(), value=setting.CREATE_MODEL_FOLDER)
@ -354,7 +433,8 @@ def load_model(modelid, ver_index):
# clear model information # clear model information
return gr.update(value=None),gr.update(value=None),gr.update(visible=False),gr.update(value=None),\ return gr.update(value=None),gr.update(value=None),gr.update(visible=False),gr.update(value=None),\
gr.update(value=None),gr.update(choices=[setting.NORESULT], value=setting.NORESULT),gr.update(value=None),\ gr.update(value=None),gr.update(choices=[setting.NORESULT], value=setting.NORESULT),gr.update(value=None),\
gr.update(value=None),gr.update(choices=[], value=None),gr.update(label="#"),\ gr.update(value=None),gr.update(choices=[], value=None),None,\
gr.update(label="#"),\
None,None,None,gr.update(value=None),gr.update(visible=False),gr.update(value=False, visible=True),gr.update(value="",visible=False),\ None,None,None,gr.update(value=None),gr.update(visible=False),gr.update(value=False, visible=True),gr.update(value="",visible=False),\
gr.update(choices=classification.get_list(), value=[]),\ gr.update(choices=classification.get_list(), value=[]),\
gr.update(choices=[setting.CREATE_MODEL_FOLDER] + classification.get_list(), value=setting.CREATE_MODEL_FOLDER) gr.update(choices=[setting.CREATE_MODEL_FOLDER] + classification.get_list(), value=setting.CREATE_MODEL_FOLDER)
@ -397,14 +477,14 @@ def get_model_information(modelid:str=None, versionid:str=None, ver_index:int=No
versions_list.append(ver['name']) versions_list.append(ver['name'])
model_url = civitai.Url_Page() + str(modelid) model_url = civitai.Url_Page() + str(modelid)
dhtml, triger, flist = get_version_description(version_info,model_info) dhtml, triger, files = get_version_description(version_info,model_info)
title_name = f"# {model_info['name']} : {version_info['name']}" title_name = f"# {model_info['name']} : {version_info['name']}"
images_url, images_meta = get_version_description_gallery(version_info) images_url, images_meta = get_version_description_gallery(version_info)
vs_foldername = setting.generate_version_foldername(model_info['name'],version_name,versionid) vs_foldername = setting.generate_version_foldername(model_info['name'],version_name,versionid)
return model_info, versionid,version_name,model_url,downloaded_versions,model_type,versions_list,dhtml,triger,flist,title_name,images_url,images_meta,vs_foldername return model_info, versionid,version_name,model_url,downloaded_versions,model_type,versions_list,dhtml,triger,files,title_name,images_url,images_meta,vs_foldername
return None, None,None,None,None,None,None,None,None,None,None,None,None,None return None, None,None,None,None,None,None,None,None,None,None,None,None,None
def get_version_description_gallery(version_info:dict): def get_version_description_gallery(version_info:dict):
@ -448,7 +528,7 @@ def get_version_description(version_info:dict,model_info:dict=None):
output_html = "" output_html = ""
output_training = "" output_training = ""
files_name = [] files = []
html_typepart = "" html_typepart = ""
html_creatorpart = "" html_creatorpart = ""
@ -506,12 +586,13 @@ def get_version_description(version_info:dict,model_info:dict=None):
if 'files' in version_info: if 'files' in version_info:
for file in version_info['files']: for file in version_info['files']:
files_name.append(f"{file['id']}:{file['name']}") files.append(file)
# files_name.append(f"{file['id']}:{file['name']}")
html_dnurlpart = html_dnurlpart + f"<br><a href={file['downloadUrl']}><b>Download << Here</b></a>" html_dnurlpart = html_dnurlpart + f"<br><a href={file['downloadUrl']}><b>Download << Here</b></a>"
output_html = html_typepart + html_modelpart + html_versionpart + html_creatorpart + html_trainingpart + "<br>" + html_model_tags + "<br>" + html_modelurlpart + html_dnurlpart + "<br>" + html_descpart + "<br>" + html_imgpart output_html = html_typepart + html_modelpart + html_versionpart + html_creatorpart + html_trainingpart + "<br>" + html_model_tags + "<br>" + html_modelurlpart + html_dnurlpart + "<br>" + html_descpart + "<br>" + html_imgpart
return output_html, output_training, files_name return output_html, output_training, files
return "",None,None return "",None,None
@ -543,8 +624,8 @@ def get_save_base_name(version_info):
return base return base
def download_file_thread(file_name, version_id, ms_folder, vs_folder, vs_foldername, cs_foldername): def download_file_thread(file_name, version_id, ms_folder, vs_folder, vs_foldername, cs_foldername):
if not file_name: # if not file_name:
return # return
if not version_id: if not version_id:
return return
@ -565,19 +646,20 @@ def download_file_thread(file_name, version_id, ms_folder, vs_folder, vs_foldern
if not model_folder: if not model_folder:
return return
dup_names = add_number_to_duplicate_files(file_name) if file_name:
dup_names = add_number_to_duplicate_files(file_name)
for fid, file in dup_names.items():
try:
#모델 파일 저장
path_dl_file = os.path.join(model_folder, file)
thread = threading.Thread(target=downloader.download_file,args=(download_files[str(fid)]['downloadUrl'], path_dl_file))
# Start the thread
thread.start()
except Exception as e:
util.printD(e)
pass
for fid, file in dup_names.items():
try:
#모델 파일 저장
path_dl_file = os.path.join(model_folder, file)
thread = threading.Thread(target=downloader.download_file,args=(download_files[str(fid)]['downloadUrl'], path_dl_file))
# Start the thread
thread.start()
except Exception as e:
util.printD(e)
pass
# 저장할 파일명을 생성한다. # 저장할 파일명을 생성한다.
savefile_base = get_save_base_name(version_info) savefile_base = get_save_base_name(version_info)

View File

@ -7,14 +7,16 @@ import modules
import re import re
import threading import threading
from PIL import Image
from . import util from . import util
from . import civitai from . import civitai
from . import setting from . import setting
def on_ui(): def on_ui():
with gr.Column(scale=5): with gr.Column(scale=3):
with gr.Accordion("#", open=True) as model_title_name:
versions_list = gr.Dropdown(label="Model Version", choices=[setting.PLACEHOLDER], interactive=True, value=setting.PLACEHOLDER)
usergal_gallery = gr.Gallery(show_label=False, elem_id="user_gallery").style(grid=[setting.usergallery_images_column], height=setting.information_gallery_height, object_fit=setting.gallery_thumbnail_image_style)
with gr.Row(): with gr.Row():
with gr.Column(scale=1): with gr.Column(scale=1):
with gr.Row(): with gr.Row():
@ -25,20 +27,21 @@ def on_ui():
with gr.Column(scale=1): with gr.Column(scale=1):
with gr.Row(): with gr.Row():
next_btn = gr.Button(value="Next Page") next_btn = gr.Button(value="Next Page")
end_btn = gr.Button(value="End Page") end_btn = gr.Button(value="End Page")
with gr.Row():
with gr.Accordion("#", open=True) as model_title_name: download_images = gr.Button(value="Download Images")
usergal_gallery = gr.Gallery(show_label=False, elem_id="user_gallery").style(grid=[setting.usergallery_images_column],height="auto", object_fit=setting.gallery_thumbnail_image_style) open_image_folder = gr.Button(value="Open Download Image Folder")
versions_list = gr.Dropdown(label="Model Version", choices=[setting.PLACEHOLDER], interactive=True, value=setting.PLACEHOLDER)
with gr.Column(scale=1):
with gr.Column(scale=1): with gr.Tabs() as info_tabs:
img_file_info = gr.Textbox(label="Generate Info", interactive=True, lines=6).style(container=True, show_copy_button=True) with gr.TabItem("Image" , id="Image_Information"):
try: with gr.Column():
send_to_buttons = modules.generation_parameters_copypaste.create_buttons(["txt2img", "img2img", "inpaint", "extras"]) img_file_info = gr.Textbox(label="Generate Info", interactive=True, lines=6).style(container=True, show_copy_button=True)
except: try:
pass send_to_buttons = modules.generation_parameters_copypaste.create_buttons(["txt2img", "img2img", "inpaint", "extras"])
download_images = gr.Button(value="Download Images") except:
pass
with gr.Row(visible=False): with gr.Row(visible=False):
selected_model_id = gr.Textbox() selected_model_id = gr.Textbox()
@ -224,11 +227,22 @@ def on_ui():
] ]
) )
usergal_gallery.select(on_gallery_select, usergal_images, [img_index, hidden]) usergal_gallery.select(on_gallery_select, usergal_images, [img_index, hidden, info_tabs])
hidden.change(on_civitai_hidden_change,[hidden,img_index,usergal_images_meta],[img_file_info]) hidden.change(on_civitai_hidden_change,[hidden,img_index,usergal_images_meta],[img_file_info])
open_image_folder.click(on_open_image_folder_click,[selected_model_id],None)
return selected_model_id return selected_model_id
def on_open_image_folder_click(modelid):
if modelid:
model_info = civitai.get_model_info(modelid)
if model_info:
model_name = model_info['name']
image_folder = util.get_download_image_folder(model_name)
if image_folder:
util.open_folder(image_folder)
def on_download_images_click(page_url,images_url): def on_download_images_click(page_url,images_url):
if page_url: if page_url:
modelid , versionid = extract_model_info(page_url) modelid , versionid = extract_model_info(page_url)
@ -280,7 +294,7 @@ def on_civitai_hidden_change(hidden, index, civitai_images_meta):
return info2 return info2
def on_gallery_select(evt: gr.SelectData, civitai_images): def on_gallery_select(evt: gr.SelectData, civitai_images):
return evt.index, civitai_images[evt.index] return evt.index, civitai_images[evt.index], gr.update(selected="Image_Information")
def on_selected_model_id_change(modelid): def on_selected_model_id_change(modelid):
page_url = None page_url = None

View File

@ -194,13 +194,15 @@ def on_scan_new_version_btn(sc_types, progress=gr.Progress()):
scan_list = list() scan_list = list()
# shortlist = sc_browser.get_thumbnail_list(sc_types,True) # shortlist = sc_browser.get_thumbnail_list(sc_types,True)
shortlist, thumb_totals, thumb_max_page = sc_browser_page.get_thumbnail_list(sc_types,True) shortlist, thumb_totals, thumb_max_page = sc_browser_page.get_thumbnail_list(sc_types,True)
if shortlist: if shortlist:
for short in progress.tqdm(shortlist, desc="Scanning new version model"): for short in progress.tqdm(shortlist, desc="Scanning new version model"):
sc_name = short[1] sc_name = short[1]
mid = setting.get_modelid_from_shortcutname(sc_name) # str(sc_name[0:sc_name.find(':')]) mid = setting.get_modelid_from_shortcutname(sc_name) # str(sc_name[0:sc_name.find(':')])
# util.printD(mid)
if not is_latest(mid): if not is_latest(mid):
scan_list.append(short) scan_list.append(short)
# util.printD(short)
# util.printD("end")
return gr.update(value=scan_list) return gr.update(value=scan_list)
def on_ui(): def on_ui():
@ -209,7 +211,7 @@ def on_ui():
selected_civitai_information_tabs = gr.Number(value=0, show_label=False) selected_civitai_information_tabs = gr.Number(value=0, show_label=False)
refresh_shortcut = gr.Textbox() refresh_shortcut = gr.Textbox()
with gr.Column(scale=1): with gr.Column(scale=setting.shortcut_browser_screen_split_ratio):
with gr.Tabs() as civitai_shortcut_tabs: with gr.Tabs() as civitai_shortcut_tabs:
with gr.TabItem("Upload"): with gr.TabItem("Upload"):
with gr.Row(visible=False): with gr.Row(visible=False):
@ -233,10 +235,10 @@ def on_ui():
with gr.Column(): with gr.Column():
shortcut_new_version_type = gr.Dropdown(label='Filter Model type', multiselect=True, choices=[k for k in setting.ui_typenames], interactive=True) shortcut_new_version_type = gr.Dropdown(label='Filter Model type', multiselect=True, choices=[k for k in setting.ui_typenames], interactive=True)
scan_new_version_btn = gr.Button(value="Scan new version model", variant="primary") scan_new_version_btn = gr.Button(value="Scan new version model", variant="primary")
sc_new_version_gallery = gr.Gallery(label="SC New Version Gallery", elem_id="sc_new_version_gallery", show_label=False).style(grid=[setting.shortcut_column],height="auto") sc_new_version_gallery = gr.Gallery(label="SC New Version Gallery", elem_id="sc_new_version_gallery", show_label=False).style(grid=[setting.shortcut_column], height="fit", object_fit=setting.gallery_thumbnail_image_style)
gr.Markdown(value="The feature is to search for new versions of models on Civitai among the downloaded ones.", visible=True) gr.Markdown(value="The feature is to search for new versions of models on Civitai among the downloaded ones.", visible=True)
with gr.Column(scale=4): with gr.Column(scale=setting.shortcut_browser_screen_split_ratio_max):
with gr.Tabs() as civitai_information_tabs: with gr.Tabs() as civitai_information_tabs:
with gr.TabItem("Civitai Model Information" , id="civitai_info"): with gr.TabItem("Civitai Model Information" , id="civitai_info"):
with gr.Row(): with gr.Row():

View File

@ -48,6 +48,26 @@ def update_classification_shortcut(s_name, shortcuts):
return True return True
def update_classification(s_name, name, info):
if not s_name:
return
if not name:
return
name = name.strip()
CISC = load()
CISC = update(CISC, s_name, name, info)
save(CISC)
if CISC:
if name in CISC:
return True
return False
def get_classification_shortcuts(s_name): def get_classification_shortcuts(s_name):
if not s_name: if not s_name:
return None return None
@ -82,26 +102,6 @@ def delete_classification(s_name):
CISC = delete(CISC,s_name) CISC = delete(CISC,s_name)
save(CISC) save(CISC)
def update_classification(s_name, name, info, shortcuts):
if not s_name:
return
if not name:
return
name = name.strip()
CISC = load()
CISC = update_shortcut(CISC,s_name, shortcuts)
CISC = update(CISC, s_name, name, info)
save(CISC)
if CISC:
if name in CISC:
return True
return False
def get_classification(s_name): def get_classification(s_name):
if not s_name: if not s_name:

View File

@ -9,29 +9,35 @@ from . import util
from . import sc_browser_page from . import sc_browser_page
def on_ui(): def on_ui():
with gr.Column(scale=1): with gr.Column(scale=setting.shortcut_browser_screen_split_ratio):
with gr.Row(visible=False): with gr.Tabs():
classification_shortcuts = gr.State() with gr.TabItem("Classification"):
refresh_gallery = gr.Textbox() classification_list = gr.Dropdown(label='Classification List', multiselect=None, choices=[setting.PLACEHOLDER] + classification.get_list(), value=setting.PLACEHOLDER ,interactive=True)
refresh_classification = gr.Textbox() classification_name = gr.Textbox(label="Name", value="",interactive=True, lines=1)
classification_info = gr.Textbox(label="Description", value="",interactive=True, lines=1)
with gr.Row(): classification_create_btn = gr.Button(value="Create", variant="primary")
with gr.Column(): classification_update_btn = gr.Button(value="Update", variant="primary")
sc_gallery, refresh_sc_list = sc_browser_page.on_ui() classification_reload_btn = gr.Button(value="Reload", variant="primary")
with gr.Accordion("Delete Classification", open=False):
with gr.Column(scale=5): classification_delete_btn = gr.Button(value="Delete")
classification_list = gr.Dropdown(label='Classification List', multiselect=None, choices=[setting.PLACEHOLDER] + classification.get_list(), value=setting.PLACEHOLDER ,interactive=True)
classification_gallery = gr.Gallery(elem_id="classification_gallery", show_label=False).style(grid=[setting.classification_gallery_column], height="auto", object_fit=setting.gallery_thumbnail_image_style)
classification_name = gr.Textbox(label="Name", value="",interactive=True, lines=1)
classification_info = gr.Textbox(label="Description", value="",interactive=True, lines=1)
with gr.Row():
classification_create_btn = gr.Button(value="Create", variant="primary")
classification_update_btn = gr.Button(value="Update", variant="primary")
with gr.Row():
with gr.Accordion("Delete Classification", open=False):
classification_delete_btn = gr.Button(value="Delete")
classification_reload_btn = gr.Button(value="Reload", variant="primary")
with gr.TabItem("Shortcut Items"):
sc_gallery, refresh_sc_list = sc_browser_page.on_ui()
with gr.Column(scale=setting.shortcut_browser_screen_split_ratio_max):
with gr.Accordion(label=setting.PLACEHOLDER, open=True) as classification_title_name:
classification_save_shortcut_btn = gr.Button(value="Save Classification Shortcuts", variant="primary")
with gr.Row():
classification_clear_shortcut_btn = gr.Button(value="Clear")
classification_reload_shortcut_btn = gr.Button(value="Reload")
classification_gallery = gr.Gallery(elem_id="classification_gallery", show_label=False).style(grid=[setting.classification_gallery_column], height="full", object_fit=setting.gallery_thumbnail_image_style)
with gr.Row(visible=False):
classification_shortcuts = gr.State()
refresh_gallery = gr.Textbox()
refresh_classification = gr.Textbox()
refresh_classification.change( refresh_classification.change(
fn=on_refresh_classification_change, fn=on_refresh_classification_change,
inputs=classification_list, inputs=classification_list,
@ -41,6 +47,7 @@ def on_ui():
classification_shortcuts, classification_shortcuts,
refresh_gallery, refresh_gallery,
refresh_sc_list, refresh_sc_list,
classification_title_name
] ]
) )
@ -88,7 +95,8 @@ def on_ui():
classification_list, classification_list,
classification_shortcuts, classification_shortcuts,
refresh_gallery, refresh_gallery,
refresh_sc_list refresh_sc_list,
classification_title_name
] ]
) )
@ -98,14 +106,35 @@ def on_ui():
classification_list, classification_list,
classification_name, classification_name,
classification_info, classification_info,
classification_shortcuts
], ],
outputs=[ outputs=[
classification_list, classification_list,
refresh_sc_list refresh_sc_list,
classification_title_name
] ]
) )
classification_save_shortcut_btn.click(
fn=on_classification_save_shortcut_btn_click,
inputs=[
classification_list,
classification_shortcuts
],
outputs=[
refresh_gallery
]
)
classification_clear_shortcut_btn.click(
fn=on_classification_clear_shortcut_btn_click,
inputs=[],
outputs=[
classification_shortcuts,
refresh_gallery
]
)
classification_reload_shortcut_btn.click(lambda :datetime.datetime.now(),None,refresh_classification)
classification_reload_btn.click(lambda :datetime.datetime.now(),None,refresh_classification) classification_reload_btn.click(lambda :datetime.datetime.now(),None,refresh_classification)
classification_delete_btn.click( classification_delete_btn.click(
@ -117,7 +146,8 @@ def on_ui():
classification_list, classification_list,
classification_shortcuts, classification_shortcuts,
refresh_gallery, refresh_gallery,
refresh_sc_list refresh_sc_list,
classification_title_name
] ]
) )
@ -128,7 +158,8 @@ def on_ui():
classification_name, classification_name,
classification_info, classification_info,
classification_shortcuts, classification_shortcuts,
refresh_gallery refresh_gallery,
classification_title_name
] ]
) )
@ -142,8 +173,8 @@ def on_refresh_classification_change(select_name):
current_time = datetime.datetime.now() current_time = datetime.datetime.now()
return gr.update(value=select_name), gr.update(value=info), shortcuts, current_time, current_time return gr.update(value=select_name), gr.update(value=info), shortcuts, current_time, current_time, gr.update(label=select_name)
return gr.update(value=""), gr.update(value=""), None, gr.update(visible=False), gr.update(visible=False) return gr.update(value=""), gr.update(value=""), None, gr.update(visible=False), gr.update(visible=False), gr.update(label=setting.PLACEHOLDER)
def on_sc_gallery_select(evt: gr.SelectData, Classification_name , shortcuts): def on_sc_gallery_select(evt: gr.SelectData, Classification_name , shortcuts):
@ -215,28 +246,40 @@ def on_classification_gallery_select(evt: gr.SelectData, shortcuts):
return shortcuts, current_time return shortcuts, current_time
return shortcuts, None return shortcuts, None
def on_classification_save_shortcut_btn_click(select_name, new_shortcuts):
if select_name and select_name != setting.PLACEHOLDER:
classification.update_classification_shortcut(select_name,new_shortcuts)
current_time = datetime.datetime.now()
return current_time
def on_classification_clear_shortcut_btn_click():
current_time = datetime.datetime.now()
return None, current_time
def on_classification_create_btn_click(new_name,new_info,classification_shortcuts): def on_classification_create_btn_click(new_name,new_info,classification_shortcuts):
current_time = datetime.datetime.now() current_time = datetime.datetime.now()
if classification.create_classification(new_name,new_info): if classification.create_classification(new_name,new_info):
return gr.update(choices=[setting.PLACEHOLDER] + classification.get_list(), value=new_name), None, current_time, current_time return gr.update(choices=[setting.PLACEHOLDER] + classification.get_list(), value=new_name), None, current_time, current_time,gr.update(label=new_name)
return gr.update(choices=[setting.PLACEHOLDER] + classification.get_list()), classification_shortcuts, current_time, current_time return gr.update(choices=[setting.PLACEHOLDER] + classification.get_list()), classification_shortcuts, current_time, current_time,gr.update(visible=True)
def on_classification_update_btn_click(select_name, new_name, new_info, new_shortcuts): def on_classification_update_btn_click(select_name, new_name, new_info):
chg_name = setting.PLACEHOLDER chg_name = setting.PLACEHOLDER
if select_name and select_name != setting.PLACEHOLDER: if select_name and select_name != setting.PLACEHOLDER:
if classification.update_classification(select_name,new_name,new_info,new_shortcuts): # classification.update_classification_shortcut(select_name,new_shortcuts)
chg_name = new_name if classification.update_classification(select_name,new_name,new_info):
chg_name = new_name
current_time = datetime.datetime.now() current_time = datetime.datetime.now()
return gr.update(choices=[setting.PLACEHOLDER] + classification.get_list(), value=chg_name),current_time return gr.update(choices=[setting.PLACEHOLDER] + classification.get_list(), value=chg_name),current_time, gr.update(label=chg_name)
def on_classification_delete_btn_click(select_name): def on_classification_delete_btn_click(select_name):
if select_name and select_name != setting.PLACEHOLDER: if select_name and select_name != setting.PLACEHOLDER:
classification.delete_classification(select_name) classification.delete_classification(select_name)
current_time = datetime.datetime.now() current_time = datetime.datetime.now()
return gr.update(choices=[setting.PLACEHOLDER] + classification.get_list(), value=setting.PLACEHOLDER), None, current_time, current_time return gr.update(choices=[setting.PLACEHOLDER] + classification.get_list(), value=setting.PLACEHOLDER), None, current_time, current_time,gr.update(label=setting.PLACEHOLDER)
def on_classification_list_select(evt: gr.SelectData): def on_classification_list_select(evt: gr.SelectData):
if evt.value != setting.PLACEHOLDER: if evt.value != setting.PLACEHOLDER:
@ -246,8 +289,8 @@ def on_classification_list_select(evt: gr.SelectData):
current_time = datetime.datetime.now() current_time = datetime.datetime.now()
return gr.update(value=select_name), gr.update(value=info), shortcuts, current_time return gr.update(value=select_name), gr.update(value=info), shortcuts, current_time, gr.update(label=select_name)
return gr.update(value=""), gr.update(value=""), None, None return gr.update(value=""), gr.update(value=""), None, None, gr.update(label=setting.PLACEHOLDER)
# def on_refresh_sc_list_change(sc_types,sc_search,show_only_downloaded_sc): # def on_refresh_sc_list_change(sc_types,sc_search,show_only_downloaded_sc):
# return gr.update(value=sc_browser.get_thumbnail_list(sc_types,show_only_downloaded_sc,sc_search)),gr.update(choices=[setting.PLACEHOLDER] + classification.get_list()) # return gr.update(value=sc_browser.get_thumbnail_list(sc_types,show_only_downloaded_sc,sc_search)),gr.update(choices=[setting.PLACEHOLDER] + classification.get_list())

View File

@ -2,7 +2,6 @@ import os
import json import json
import shutil import shutil
import requests import requests
import gradio as gr
from . import util from . import util
from . import setting from . import setting

View File

@ -11,43 +11,69 @@ from . import ishortcut
from . import setting from . import setting
from . import classification from . import classification
from . import downloader from . import downloader
from . import civitai_action
def on_ui(refresh_sc_list:gr.Textbox()): def on_ui(refresh_sc_list:gr.Textbox()):
with gr.Column(scale=3):
with gr.Accordion("#", open=True) as model_title_name:
versions_list = gr.Dropdown(label="Model Version", choices=[setting.NORESULT], interactive=True, value=setting.NORESULT)
with gr.Tabs():
with gr.TabItem("Images" , id="Model_Images"):
saved_gallery = gr.Gallery(show_label=False, elem_id="saved_gallery").style(grid=[setting.gallery_column],height=setting.information_gallery_height, object_fit=setting.gallery_thumbnail_image_style)
with gr.Row():
download_images = gr.Button(value="Download Images")
open_image_folder = gr.Button(value="Open Download Image Folder")
with gr.TabItem("Description" , id="Model_Description"):
description_html = gr.HTML()
with gr.TabItem("Download" , id="Model_Download"):
gr.Markdown("Downloadable Files")
downloadable_files = gr.DataFrame(
headers=["","ID","Filename","Type","SizeKB","DownloadUrl"],
datatype=["str","str","str","str","str","str"],
col_count=(6,"fixed"),
interactive=False,
type="array",
)
filename_list = gr.CheckboxGroup (show_label=False , label="Model Version File", choices=[], value=[], interactive=True, visible=False)
with gr.Column(scale=1): cs_foldername = gr.Dropdown(label='Download Folder Select', multiselect=None, choices=[setting.CREATE_MODEL_FOLDER] + classification.get_list(), value=setting.CREATE_MODEL_FOLDER, interactive=True)
versions_list = gr.Dropdown(label="Model Version", choices=[setting.NORESULT], interactive=True, value=setting.NORESULT) vs_folder = gr.Checkbox(label="Create individual version folder", value=False, visible=True , interactive=True)
model_type = gr.Textbox(label="Model Type", value="", interactive=False, lines=1) vs_folder_name = gr.Textbox(label="Folder name to create", value="", show_label=False, interactive=True, lines=1, visible=False).style(container=True)
trigger_words = gr.Textbox(label="Trigger Words", value="", interactive=False, lines=1).style(container=True, show_copy_button=True) download_model = gr.Button(value="Download", variant="primary")
civitai_model_url_txt = gr.Textbox(label="Model Url", value="", interactive=False , lines=1).style(container=True, show_copy_button=True) gr.Markdown("Downloading may take some time. Check console log for detail")
with gr.Accordion("Downloaded Version", open=False, visible=False) as downloaded_tab:
downloaded_info = gr.Textbox(interactive=False,show_label=False)
filename_list = gr.Textbox(label="Model Version File", interactive=False)
update_information_btn = gr.Button(value="Update Model Information")
with gr.Accordion("Delete Civitai Shortcut", open=False):
shortcut_del_btn = gr.Button(value="Delete Shortcut")
saved_openfolder = gr.Button(value="Open Download Folder",variant="primary", visible=False)
with gr.Column(scale=4): with gr.Column(scale=1):
with gr.Accordion("#", open=True) as model_title_name: with gr.Tabs() as info_tabs:
saved_gallery = gr.Gallery(show_label=False, elem_id="saved_gallery").style(grid=[setting.gallery_column],height="auto", object_fit=setting.gallery_thumbnail_image_style) with gr.TabItem("Information" , id="Model_Information"):
with gr.Accordion("Model Description", open=True): model_type = gr.Textbox(label="Model Type", value="", interactive=False, lines=1)
description_html = gr.HTML() trigger_words = gr.Textbox(label="Trigger Words", value="", interactive=False, lines=1).style(container=True, show_copy_button=True)
with gr.Column(scale=1): civitai_model_url_txt = gr.Textbox(label="Model Url", value="", interactive=False , lines=1).style(container=True, show_copy_button=True)
img_file_info = gr.Textbox(label="Generate Info", interactive=True, lines=6).style(container=True, show_copy_button=True) with gr.Row():
try: with gr.Column():
send_to_buttons = modules.generation_parameters_copypaste.create_buttons(["txt2img", "img2img", "inpaint", "extras"]) with gr.Accordion("Classcification", open=True):
except: model_classification = gr.Dropdown(label='Classcification', show_label=False ,multiselect=True, interactive=True, choices=classification.get_list())
pass model_classification_update_btn = gr.Button(value="Update",variant="primary")
download_images = gr.Button(value="Download Images")
refresh_btn = gr.Button(value="Refresh") with gr.Accordion("Downloaded Version", open=True, visible=False) as downloaded_tab:
with gr.Accordion("Model Classcification", open=True): downloaded_info = gr.Textbox(interactive=False,show_label=False)
model_classification = gr.Dropdown(label='Classcification', multiselect=True, interactive=True, choices=classification.get_list()) saved_openfolder = gr.Button(value="Open Download Folder",variant="primary", visible=False)
model_classification_update_btn = gr.Button(value="Update",variant="primary") with gr.Row():
with gr.Column():
refresh_btn = gr.Button(value="Refresh")
update_information_btn = gr.Button(value="Update Model Information")
with gr.Accordion("Delete Civitai Shortcut", open=False):
shortcut_del_btn = gr.Button(value="Delete Shortcut")
with gr.TabItem("Image Information" , id="Image_Information"):
with gr.Column():
img_file_info = gr.Textbox(label="Generate Info", interactive=True, lines=6).style(container=True, show_copy_button=True)
try:
send_to_buttons = modules.generation_parameters_copypaste.create_buttons(["txt2img", "img2img", "inpaint", "extras"])
except:
pass
with gr.Row(visible=False): with gr.Row(visible=False):
selected_model_id = gr.Textbox() selected_model_id = gr.Textbox()
selected_version_id = gr.Textbox() selected_version_id = gr.Textbox()
@ -67,7 +93,44 @@ def on_ui(refresh_sc_list:gr.Textbox()):
modules.generation_parameters_copypaste.bind_buttons(send_to_buttons, hidden,img_file_info) modules.generation_parameters_copypaste.bind_buttons(send_to_buttons, hidden,img_file_info)
except: except:
pass pass
downloadable_files.select(
fn=on_downloadable_files_select,
inputs=[
downloadable_files,
filename_list
],
outputs=[
downloadable_files,
filename_list,
]
)
cs_foldername.select(
fn=on_cs_foldername_select,
inputs=None,
outputs=[
vs_folder,
vs_folder_name
]
)
download_model.click(
fn=on_download_model_click,
inputs=[
selected_version_id,
filename_list,
vs_folder,
vs_folder_name,
cs_foldername,
],
outputs=[
refresh_sc_list,
refresh_information
]
)
download_images.click( download_images.click(
fn=on_download_images_click, fn=on_download_images_click,
inputs=[ inputs=[
@ -139,13 +202,17 @@ def on_ui(refresh_sc_list:gr.Textbox()):
description_html, description_html,
trigger_words, trigger_words,
filename_list, filename_list,
downloadable_files,
model_title_name, model_title_name,
refresh_gallery, refresh_gallery,
saved_images_url, saved_images_url,
saved_images_meta, saved_images_meta,
img_file_info, img_file_info,
saved_openfolder, saved_openfolder,
model_classification vs_folder,
vs_folder_name,
model_classification,
cs_foldername
], ],
cancels=gallery cancels=gallery
) )
@ -165,13 +232,17 @@ def on_ui(refresh_sc_list:gr.Textbox()):
description_html, description_html,
trigger_words, trigger_words,
filename_list, filename_list,
downloadable_files,
model_title_name, model_title_name,
refresh_gallery, refresh_gallery,
saved_images_url, saved_images_url,
saved_images_meta, saved_images_meta,
img_file_info, img_file_info,
saved_openfolder, saved_openfolder,
model_classification vs_folder,
vs_folder_name,
model_classification,
cs_foldername
], ],
cancels=gallery cancels=gallery
) )
@ -192,24 +263,66 @@ def on_ui(refresh_sc_list:gr.Textbox()):
description_html, description_html,
trigger_words, trigger_words,
filename_list, filename_list,
downloadable_files,
model_title_name, model_title_name,
refresh_gallery, refresh_gallery,
saved_images_url, saved_images_url,
saved_images_meta, saved_images_meta,
img_file_info, img_file_info,
saved_openfolder, saved_openfolder,
model_classification vs_folder,
vs_folder_name,
model_classification,
cs_foldername
], ],
cancels=gallery cancels=gallery
) )
refresh_btn.click(lambda :datetime.datetime.now(),None,refresh_information,cancels=gallery) refresh_btn.click(lambda :datetime.datetime.now(),None,refresh_information,cancels=gallery)
saved_gallery.select(on_gallery_select, saved_images, [img_index, hidden]) saved_gallery.select(on_gallery_select, saved_images, [img_index, hidden, info_tabs])
hidden.change(on_civitai_hidden_change,[hidden,img_index,saved_images_meta],[img_file_info]) hidden.change(on_civitai_hidden_change,[hidden,img_index,saved_images_meta],[img_file_info])
saved_openfolder.click(on_open_folder_click,[selected_model_id,selected_version_id],None) saved_openfolder.click(on_open_folder_click,[selected_model_id,selected_version_id],None)
vs_folder.change(lambda x:gr.update(visible=x),vs_folder,vs_folder_name)
open_image_folder.click(on_open_image_folder_click,[selected_model_id],None)
return selected_model_id, refresh_information return selected_model_id, refresh_information
def on_open_image_folder_click(modelid):
if modelid:
model_info = ishortcut.get_model_info(modelid)
if model_info:
model_name = model_info['name']
image_folder = util.get_download_image_folder(model_name)
if image_folder:
util.open_folder(image_folder)
def on_downloadable_files_select(evt: gr.SelectData, df, filenames):
# util.printD(evt.index)
# index[0] # 행,열
vid = None
vname = None
dn_name = None
if df:
vid = df[evt.index[0]][1]
vname = df[evt.index[0]][2]
dn_name = f"{vid}:{vname}"
if vid:
if filenames:
if dn_name in filenames:
filenames.remove(dn_name)
df[evt.index[0]][0] = '⬜️'
else:
filenames.append(dn_name)
df[evt.index[0]][0] = ''
else:
filenames = [dn_name]
df[evt.index[0]][0] = ''
return df, gr.update(value=filenames)
def on_download_images_click(model_id:str, images_url): def on_download_images_click(model_id:str, images_url):
msg = None msg = None
if model_id: if model_id:
@ -222,6 +335,27 @@ def on_download_images_click(model_id:str, images_url):
downloader.download_image_file(model_info['name'], images_url) downloader.download_image_file(model_info['name'], images_url)
current_time = datetime.datetime.now() current_time = datetime.datetime.now()
def on_download_model_click(version_id, file_name, vs_folder, vs_foldername, cs_foldername=None):
msg = None
if version_id:
# 프리뷰이미지와 파일 모두를 다운 받는다.
if cs_foldername == setting.CREATE_MODEL_FOLDER:
msg = civitai_action.download_file_thread(file_name, version_id, True, vs_folder, vs_foldername, None)
else:
msg = civitai_action.download_file_thread(file_name, version_id, False, False, None , cs_foldername)
# 다운 받은 모델 정보를 갱신한다.
model.update_downloaded_model()
current_time = datetime.datetime.now()
return gr.update(value=current_time),gr.update(value=current_time)
return gr.update(visible=True),gr.update(visible=True)
def on_cs_foldername_select(evt: gr.SelectData):
if evt.value == setting.CREATE_MODEL_FOLDER:
return gr.update(visible=True,value=False),gr.update(visible=False)
return gr.update(visible=False,value=False),gr.update(visible=False)
def on_model_classification_update_btn_click(model_classification, modelid): def on_model_classification_update_btn_click(model_classification, modelid):
@ -240,7 +374,7 @@ def on_open_folder_click(mid,vid):
util.open_folder(path) util.open_folder(path)
def on_gallery_select(evt: gr.SelectData, civitai_images): def on_gallery_select(evt: gr.SelectData, civitai_images):
return evt.index, civitai_images[evt.index] return evt.index, civitai_images[evt.index], gr.update(selected="Image_Information")
def on_civitai_hidden_change(hidden, index, civitai_images_meta): def on_civitai_hidden_change(hidden, index, civitai_images_meta):
info1,info2,info3 = modules.extras.run_pnginfo(hidden) info1,info2,info3 = modules.extras.run_pnginfo(hidden)
@ -277,7 +411,7 @@ def on_file_gallery_loading(image_url):
def load_saved_model(modelid=None, ver_index=None): def load_saved_model(modelid=None, ver_index=None):
if modelid: if modelid:
model_info,versionid,version_name,model_url,downloaded_versions,model_type,versions_list,dhtml,triger,flist,title_name,images_url,images_meta = get_model_information(modelid,None,ver_index) model_info,versionid,version_name,model_url,downloaded_versions,model_type,versions_list,dhtml,triger,files,title_name,images_url,images_meta,vs_foldername = get_model_information(modelid,None,ver_index)
if model_info: if model_info:
downloaded_info = None downloaded_info = None
is_downloaded = False is_downloaded = False
@ -291,31 +425,36 @@ def load_saved_model(modelid=None, ver_index=None):
if downloaded_info: if downloaded_info:
is_downloaded = True is_downloaded = True
file_text = ""
if flist:
file_text = "\n".join(flist)
current_time = datetime.datetime.now() current_time = datetime.datetime.now()
classification_list = classification.get_classification_names_by_modelid(modelid) classification_list = classification.get_classification_names_by_modelid(modelid)
flist = list()
downloadable = list()
for file in files:
flist.append(f"{file['id']}:{file['name']}")
downloadable.append(['',file['id'],file['name'],file['type'],round(file['sizeKB']),file['downloadUrl']])
return gr.update(value=versionid),gr.update(value=model_url),\ return gr.update(value=versionid),gr.update(value=model_url),\
gr.update(visible = is_downloaded),gr.update(value=downloaded_info),\ gr.update(visible = is_downloaded),gr.update(value=downloaded_info),\
gr.update(value=setting.get_ui_typename(model_type)),gr.update(choices=versions_list,value=version_name),gr.update(value=dhtml),\ gr.update(value=setting.get_ui_typename(model_type)),gr.update(choices=versions_list,value=version_name),gr.update(value=dhtml),\
gr.update(value=triger),gr.update(value=file_text),gr.update(label=title_name),\ gr.update(value=triger),gr.update(choices=flist if flist else [], value=flist if flist else []), downloadable if len(downloadable) > 0 else None,\
current_time,images_url,images_meta,gr.update(value=None),gr.update(visible=is_visible_openfolder),\ gr.update(label=title_name),\
gr.update(choices=classification.get_list(),value=classification_list, interactive=True) current_time,images_url,images_meta,gr.update(value=None),gr.update(visible=is_visible_openfolder),gr.update(value=False, visible=True),gr.update(value=vs_foldername, visible=False),\
gr.update(choices=classification.get_list(),value=classification_list, interactive=True),\
gr.update(choices=[setting.CREATE_MODEL_FOLDER] + classification.get_list(), value=setting.CREATE_MODEL_FOLDER)
# 모델 정보가 없다면 클리어 한다. # 모델 정보가 없다면 클리어 한다.
# clear model information # clear model information
return gr.update(value=None),gr.update(value=None),\ return gr.update(value=None),gr.update(value=None),\
gr.update(visible=False),gr.update(value=None),\ gr.update(visible=False),gr.update(value=None),\
gr.update(value=None),gr.update(choices=[setting.NORESULT], value=setting.NORESULT),gr.update(value=None),\ gr.update(value=None),gr.update(choices=[setting.NORESULT], value=setting.NORESULT),gr.update(value=None),\
gr.update(value=None),gr.update(value=None),gr.update(label="#"),\ gr.update(value=None),gr.update(value=None),None,\
None,None,None,gr.update(value=None),gr.update(visible=False),\ gr.update(label="#"),\
gr.update(choices=classification.get_list(),value=[], interactive=True) None,None,None,gr.update(value=None),gr.update(visible=False),gr.update(value=False, visible=True),gr.update(value="",visible=False),\
gr.update(choices=classification.get_list(),value=[], interactive=True),\
gr.update(choices=[setting.CREATE_MODEL_FOLDER] + classification.get_list(), value=setting.CREATE_MODEL_FOLDER)
def get_model_information(modelid:str=None, versionid:str=None, ver_index:int=None): def get_model_information(modelid:str=None, versionid:str=None, ver_index:int=None):
# 현재 모델의 정보를 가져온다. # 현재 모델의 정보를 가져온다.
@ -353,12 +492,14 @@ def get_model_information(modelid:str=None, versionid:str=None, ver_index:int=No
versions_list.append(ver['name']) versions_list.append(ver['name'])
model_url = civitai.Url_Page() + str(modelid) model_url = civitai.Url_Page() + str(modelid)
dhtml, triger, flist = get_version_description(version_info,model_info) dhtml, triger, files = get_version_description(version_info,model_info)
title_name = f"# {model_info['name']} : {version_info['name']}" title_name = f"# {model_info['name']} : {version_info['name']}"
images_url, images_meta = get_version_description_gallery(version_info) images_url, images_meta = get_version_description_gallery(version_info)
return model_info, versionid,version_name,model_url,downloaded_versions,model_type,versions_list,dhtml,triger,flist,title_name,images_url,images_meta vs_foldername = setting.generate_version_foldername(model_info['name'],version_name,versionid)
return None, None,None,None,None,None,None,None,None,None,None,None,None
return model_info, versionid,version_name,model_url,downloaded_versions,model_type,versions_list,dhtml,triger,files,title_name,images_url,images_meta, vs_foldername
return None, None,None,None,None,None,None,None,None,None,None,None,None,None
def get_version_description_gallery(version_info): def get_version_description_gallery(version_info):
modelid = None modelid = None
@ -367,7 +508,7 @@ def get_version_description_gallery(version_info):
if not version_info: if not version_info:
return None,None return None, None
if "modelId" in version_info.keys(): if "modelId" in version_info.keys():
modelid = str(version_info['modelId']) modelid = str(version_info['modelId'])
@ -390,15 +531,15 @@ def get_version_description_gallery(version_info):
images_url.append(description_img) images_url.append(description_img)
images_meta.append(meta_string) images_meta.append(meta_string)
except: except:
return None,None return None, None
return images_url,images_meta return images_url, images_meta
def get_version_description(version_info:dict,model_info:dict=None): def get_version_description(version_info:dict,model_info:dict=None):
output_html = "" output_html = ""
output_training = "" output_training = ""
files_name = [] files = []
html_typepart = "" html_typepart = ""
html_creatorpart = "" html_creatorpart = ""
@ -456,27 +597,42 @@ def get_version_description(version_info:dict,model_info:dict=None):
if 'files' in version_info: if 'files' in version_info:
for file in version_info['files']: for file in version_info['files']:
files_name.append(file['name']) files.append(file)
html_dnurlpart = html_dnurlpart + f"<br><a href={file['downloadUrl']}><b>Download << Here</b></a>" html_dnurlpart = html_dnurlpart + f"<br><a href={file['downloadUrl']}><b>Download << Here</b></a>"
output_html = html_typepart + html_modelpart + html_versionpart + html_creatorpart + html_trainingpart + "<br>" + html_model_tags + "<br>" + html_modelurlpart + html_dnurlpart + "<br>" + html_descpart + "<br>" + html_imgpart output_html = html_typepart + html_modelpart + html_versionpart + html_creatorpart + html_trainingpart + "<br>" + html_model_tags + "<br>" + html_modelurlpart + html_dnurlpart + "<br>" + html_descpart + "<br>" + html_imgpart
return output_html, output_training, files_name return output_html, output_training, files
return "",None,None return "", None, None
def upload_shortcut_by_files(files, register_information_only, progress): def upload_shortcut_by_files(files, register_information_only, progress):
modelids = list() modelids = list()
if files: if files:
shortcut = None shortcuts = []
add_ISC = dict() add_ISC = dict()
for file in progress.tqdm(files, desc=f"Civitai Shortcut"): ######
shortcut = util.load_InternetShortcut(file.name) for file in files:
if shortcut: shortcuts = util.load_InternetShortcut(file.name)
model_id = util.get_model_id_from_url(shortcut) if shortcuts:
if model_id: for shortcut in shortcuts:
add_ISC = ishortcut.add(add_ISC, model_id, register_information_only, progress) model_id = util.get_model_id_from_url(shortcut)
modelids.append(model_id) if model_id:
modelids.append(model_id)
for model_id in progress.tqdm(modelids, desc=f"Civitai Shortcut"):
if model_id:
add_ISC = ishortcut.add(add_ISC, model_id, register_information_only, progress)
# util.printD(modelids)
# for file in progress.tqdm(files, desc=f"Civitai Shortcut"):
# shortcut = util.load_InternetShortcut(file.name)
# if shortcut:
# model_id = util.get_model_id_from_url(shortcut)
# if model_id:
# add_ISC = ishortcut.add(add_ISC, model_id, register_information_only, progress)
# modelids.append(model_id)
ISC = ishortcut.load() ISC = ishortcut.load()
if ISC: if ISC:

View File

@ -2,15 +2,12 @@ import os
import json import json
import gradio as gr import gradio as gr
import datetime import datetime
import modules
import pandas as pd
from . import util from . import util
from . import model from . import model
from . import civitai
from . import setting from . import setting
from . import ishortcut from . import ishortcut
# from . import civitai
def on_ui(): def on_ui():
@ -145,13 +142,11 @@ def on_downloaded_information_select(evt: gr.SelectData, df):
try: try:
with open(vlocation, 'r') as f: with open(vlocation, 'r') as f:
contents = json.load(f) contents = json.load(f)
if 'id' not in contents.keys(): if 'id' not in contents.keys():
contents = None contents = None
except: except:
pass pass
if contents: if contents:
file_list = list() file_list = list()
if "files" in contents: if "files" in contents:

View File

@ -5,7 +5,7 @@ from . import setting
from . import model from . import model
from . import classification from . import classification
from . import ishortcut from . import ishortcut
from PIL import Image
def get_thumbnail_list(shortcut_types=None, only_downloaded=False, search=None): def get_thumbnail_list(shortcut_types=None, only_downloaded=False, search=None):
@ -63,7 +63,7 @@ def on_ui():
sc_search = gr.Textbox(label="Search", value="", placeholder="Search name, #tags, @classification, ....",interactive=True, lines=1) sc_search = gr.Textbox(label="Search", value="", placeholder="Search name, #tags, @classification, ....",interactive=True, lines=1)
sc_classification_list = gr.Dropdown(label='Classification', multiselect=None, value=setting.PLACEHOLDER, choices=[setting.PLACEHOLDER] + classification.get_list(), interactive=True) sc_classification_list = gr.Dropdown(label='Classification', multiselect=None, value=setting.PLACEHOLDER, choices=[setting.PLACEHOLDER] + classification.get_list(), interactive=True)
show_only_downloaded_sc = gr.Checkbox(label="Show downloaded model's shortcut only", value=False) show_only_downloaded_sc = gr.Checkbox(label="Show downloaded model's shortcut only", value=False)
sc_gallery = gr.Gallery(show_label=False,value=get_thumbnail_list()).style(grid=[setting.shortcut_column], height="auto", object_fit=setting.gallery_thumbnail_image_style) sc_gallery = gr.Gallery(show_label=False,value=get_thumbnail_list()).style(grid=[setting.shortcut_column], height=["full" if setting.shortcut_count_per_page != 0 else "auto"], object_fit=setting.gallery_thumbnail_image_style)
# for v in get_thumbnail_list(): # for v in get_thumbnail_list():
# util.printD(v) # util.printD(v)
# im = gr.Image(visible=False) # im = gr.Image(visible=False)

View File

@ -6,7 +6,7 @@ from . import setting
from . import model from . import model
from . import classification from . import classification
from . import ishortcut from . import ishortcut
from PIL import Image
def get_thumbnail_list(shortcut_types=None, only_downloaded=False, search=None, page = 0): def get_thumbnail_list(shortcut_types=None, only_downloaded=False, search=None, page = 0):
@ -102,7 +102,7 @@ def on_ui():
sc_classification_list = gr.Dropdown(label='Classification', multiselect=None, value=setting.PLACEHOLDER, choices=[setting.PLACEHOLDER] + classification.get_list(), interactive=True) sc_classification_list = gr.Dropdown(label='Classification', multiselect=None, value=setting.PLACEHOLDER, choices=[setting.PLACEHOLDER] + classification.get_list(), interactive=True)
show_only_downloaded_sc = gr.Checkbox(label="Show downloaded model's shortcut only", value=False) show_only_downloaded_sc = gr.Checkbox(label="Show downloaded model's shortcut only", value=False)
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) 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)
sc_gallery = gr.Gallery(show_label=False, value=thumb_list).style(grid=[setting.shortcut_column], height="auto", object_fit=setting.gallery_thumbnail_image_style) 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)
with gr.Row(visible=False): with gr.Row(visible=False):
refresh_sc_list = gr.Textbox() refresh_sc_list = gr.Textbox()

View File

@ -1,8 +1,11 @@
import os import os
import json import json
import shutil import shutil
from modules import shared
import modules.scripts as scripts from modules import scripts, script_callbacks, shared
# from modules import shared
# import modules.scripts as scripts
from . import util from . import util
@ -24,7 +27,7 @@ model_exts = (".bin", ".pt", ".safetensors", ".ckpt")
model_folders = { model_folders = {
'Checkpoint': os.path.join("models","Stable-diffusion"), 'Checkpoint': os.path.join("models","Stable-diffusion"),
'LORA': os.path.join("models","Lora"), 'LORA': os.path.join("models","Lora"),
'LoCon': os.path.join("models","Lora"), 'LoCon': os.path.join("models","LyCORIS"),
'TextualInversion': os.path.join("embeddings"), 'TextualInversion': os.path.join("embeddings"),
'Hypernetwork': os.path.join("models","hypernetworks"), 'Hypernetwork': os.path.join("models","hypernetworks"),
'AestheticGradient': os.path.join("extensions","stable-diffusion-webui-aesthetic-gradients","aesthetic_embeddings"), 'AestheticGradient': os.path.join("extensions","stable-diffusion-webui-aesthetic-gradients","aesthetic_embeddings"),
@ -40,6 +43,23 @@ model_folders = {
# UI 쪽에서 변환할때 쓰인다. # UI 쪽에서 변환할때 쓰인다.
# UI model type -> civitai model type # UI model type -> civitai model type
# UI type 하나에 다중의 civitai type을 대입할때 대상이 되는것은 get_ui_typename 함수와 ishortcut->get_image_list 와 get_list 뿐이다.
# 나머지는 key로만 쓰이기 때문에 value 값이 배열이라 해도문제가 안될듯한다.
# ishortcut 부분은 여기를
# tmp_types.append(setting.ui_typenames[sc_type])
# ->
# for type_name in setting.ui_typenames[sc_type]:
# tmp_types.append(type_name)
# 이리 하면 될듯
# get_ui_typename는 이렇게 수정해도 문제 없을것 같다. 대신 모두 "" : ["",""] 형식으로 바꿔야 할듯(안해도 되나?)
# def get_ui_typename(model_type):
# for k,v in ui_typenames.items():
# if model_type in v:
# return k
# return model_type
ui_typenames = { ui_typenames = {
"Checkpoint" : 'Checkpoint', "Checkpoint" : 'Checkpoint',
"LoRA" : 'LORA', "LoRA" : 'LORA',
@ -70,18 +90,23 @@ preview_image_ext = ".png"
preview_image_suffix = ".preview" preview_image_suffix = ".preview"
# 갤러리 height 설정
information_gallery_height = "auto" # auto , fit
# 화면 분할 비율
shortcut_browser_screen_split_ratio = 4
shortcut_browser_screen_split_ratio_max = 10
# 갤러리 ui설정 # 갤러리 ui설정
gallery_column = 4 gallery_column = 7
shortcut_column = 3 shortcut_column = 5
shortcut_count_per_page = 15 shortcut_count_per_page = 20
classification_gallery_column = 8 classification_gallery_column = 8
# 유저 갤러리 설정 # 유저 갤러리 설정
usergallery_images_column = 5 usergallery_images_column = 6
usergallery_images_page_limit = 10 usergallery_images_page_limit = 12
# usergallery_preload_page_count = 1 shortcut_max_download_image_per_version = 0 # 버전당 최대 다운로드 이미지 수 , 0이면 전체다운 받는다
# 버전당 최대 다운로드 이미지 수 , 0이면 전체다운 받는다
shortcut_max_download_image_per_version = 0
gallery_thumbnail_image_style = "scale-down" gallery_thumbnail_image_style = "scale-down"
# 다운로드 설정 # 다운로드 설정
@ -124,9 +149,14 @@ def init():
global gallery_thumbnail_image_style global gallery_thumbnail_image_style
global download_images_folder global download_images_folder
global shortcut_browser_screen_split_ratio
global information_gallery_height
root_path = os.getcwd() root_path = os.getcwd()
# util.printD(os.path.abspath(__file__))
# util.printD(os.path.abspath(root_path))
shortcut = os.path.join(extension_base,shortcut) shortcut = os.path.join(extension_base,shortcut)
shortcut_setting = os.path.join(extension_base,shortcut_setting) shortcut_setting = os.path.join(extension_base,shortcut_setting)
shortcut_classification = os.path.join(extension_base,shortcut_classification) shortcut_classification = os.path.join(extension_base,shortcut_classification)
@ -145,11 +175,16 @@ def init():
model_folders['Checkpoint'] = shared.cmd_opts.ckpt_dir model_folders['Checkpoint'] = shared.cmd_opts.ckpt_dir
if shared.cmd_opts.lora_dir: if shared.cmd_opts.lora_dir:
model_folders['LORA'] = shared.cmd_opts.lora_dir model_folders['LORA'] = shared.cmd_opts.lora_dir
model_folders['LoCon'] = shared.cmd_opts.lora_dir
environment = load() environment = load()
if environment: if environment:
if "shortcut_browser_screen_split_ratio" in environment.keys():
shortcut_browser_screen_split_ratio = int(environment['shortcut_browser_screen_split_ratio'])
if "information_gallery_height" in environment.keys():
if environment['information_gallery_height'].strip():
information_gallery_height = environment['information_gallery_height']
if "shortcut_column" in environment.keys(): if "shortcut_column" in environment.keys():
shortcut_column = int(environment['shortcut_column']) shortcut_column = int(environment['shortcut_column'])
if "shortcut_count_per_page" in environment.keys(): if "shortcut_count_per_page" in environment.keys():
@ -171,6 +206,9 @@ def init():
user_folders = environment['model_folders'] user_folders = environment['model_folders']
if 'LoCon' in user_folders.keys():
model_folders['LoCon'] = user_folders['LoCon']
if 'Wildcards' in user_folders.keys(): if 'Wildcards' in user_folders.keys():
model_folders['Wildcards'] = user_folders['Wildcards'] model_folders['Wildcards'] = user_folders['Wildcards']

View File

@ -11,7 +11,9 @@ from . import setting
from . import civitai from . import civitai
from . import ishortcut_action from . import ishortcut_action
import modules.scripts as scripts
# import modules.scripts as scripts
from modules import scripts, script_callbacks, shared
def create_models_information(files, mfolder, vs_folder, register_shortcut, progress=gr.Progress()): def create_models_information(files, mfolder, vs_folder, register_shortcut, progress=gr.Progress()):
@ -282,12 +284,15 @@ def on_scan_ui():
outputs=[scan_progress] outputs=[scan_progress]
) )
def on_save_btn_click(shortcut_column, shortcut_count_per_page, def on_save_btn_click(scbrowser_screen_split_ratio, info_gallery_height,
shortcut_column, shortcut_count_per_page,
gallery_column, classification_gallery_column, usergallery_images_column, usergallery_images_page_limit, gallery_column, classification_gallery_column, usergallery_images_column, usergallery_images_page_limit,
shortcut_max_download_image_per_version, shortcut_max_download_image_per_version,
gallery_thumbnail_image_style, gallery_thumbnail_image_style,
wildcards,controlnet,aestheticgradient,poses,other,download_images_folder): locon,wildcards,controlnet,aestheticgradient,poses,other,download_images_folder):
environment = dict() environment = dict()
environment['shortcut_browser_screen_split_ratio'] = scbrowser_screen_split_ratio
environment['information_gallery_height'] = info_gallery_height
environment['shortcut_column'] = shortcut_column environment['shortcut_column'] = shortcut_column
environment['shortcut_count_per_page'] = shortcut_count_per_page environment['shortcut_count_per_page'] = shortcut_count_per_page
environment['gallery_column'] = gallery_column environment['gallery_column'] = gallery_column
@ -298,6 +303,8 @@ def on_save_btn_click(shortcut_column, shortcut_count_per_page,
environment['gallery_thumbnail_image_style'] = gallery_thumbnail_image_style environment['gallery_thumbnail_image_style'] = gallery_thumbnail_image_style
model_folders = dict() model_folders = dict()
if locon:
model_folders['LoCon'] = locon
if wildcards: if wildcards:
model_folders['Wildcards'] = wildcards model_folders['Wildcards'] = wildcards
if controlnet: if controlnet:
@ -328,10 +335,34 @@ def on_usergallery_openfolder_btn_click():
def on_usergallery_cleangallery_btn_click(): def on_usergallery_cleangallery_btn_click():
if os.path.exists(setting.shortcut_gallery_folder): if os.path.exists(setting.shortcut_gallery_folder):
shutil.rmtree(setting.shortcut_gallery_folder) shutil.rmtree(setting.shortcut_gallery_folder)
def on_reload_btn_click():
request_restart()
def request_restart():
shared.state.interrupt()
shared.state.need_restart = True
# def on_update_btn_click():
# git = os.environ.get('GIT', "git")
# subdir = os.path.dirname(os.path.abspath(__file__))
# # perform git pull in the extension folder
# output = subprocess.check_output([git, '-C', subdir, 'pull', '--autostash'])
# print(output.decode('utf-8'))
def on_setting_ui(): def on_setting_ui():
with gr.Column(): with gr.Column():
with gr.Row():
with gr.Accordion("Screen Style", open=True):
with gr.Row():
scbrowser_screen_split_ratio = gr.Slider(minimum=0, maximum=setting.shortcut_browser_screen_split_ratio_max, value=setting.shortcut_browser_screen_split_ratio, step=1, info="You can specify the size ratio between the shortcut browser and the information screen.", label='Shortcut Browser screen ratio', interactive=True)
with gr.Row():
info_gallery_height = gr.Dropdown(choices=["auto","fit"], value=setting.information_gallery_height, allow_custom_value=True, interactive=True, info="You can also specify a specific size other than 'auto' or 'fit'" , label="Information Gallery Height")
gallery_thumbnail_image_style = gr.Dropdown(choices=["scale-down","cover","contain","fill","none"], value=setting.gallery_thumbnail_image_style, interactive=True, info="This specifies the shape of the displayed thumbnail." , label="Gallery Thumbnail Image Style")
with gr.Row(): with gr.Row():
with gr.Accordion("Shortcut Browser and Information Images", open=True): with gr.Accordion("Shortcut Browser and Information Images", open=True):
with gr.Row(): with gr.Row():
@ -341,10 +372,8 @@ def on_setting_ui():
gallery_column = gr.Slider(minimum=1, maximum=12, value=setting.gallery_column, step=1, label='Model Information Column Count', interactive=True) gallery_column = gr.Slider(minimum=1, maximum=12, value=setting.gallery_column, step=1, label='Model Information Column Count', interactive=True)
classification_gallery_column = gr.Slider(minimum=1, maximum=12, value=setting.classification_gallery_column, step=1, label='Classification Model Column Count', interactive=True) classification_gallery_column = gr.Slider(minimum=1, maximum=12, value=setting.classification_gallery_column, step=1, label='Classification Model Column Count', interactive=True)
with gr.Row(): with gr.Row():
shortcut_max_download_image_per_version = gr.Slider(minimum=0, maximum=30, value=setting.shortcut_max_download_image_per_version, step=1, label='Maximum number of download images per version', interactive=True) shortcut_max_download_image_per_version = gr.Slider(minimum=0, maximum=30, value=setting.shortcut_max_download_image_per_version, step=1,info="When registering a shortcut of a model, you can specify the maximum number of images to download. \n This is the maximum per version, and setting it to 0 means unlimited downloads.", label='Maximum number of download images per version', interactive=True)
gr.Markdown(value="When registering a shortcut of a model, you can specify the maximum number of images to download. \n This is the maximum per version, and setting it to 0 means unlimited downloads.", visible=True) gr.Markdown(value="When registering a shortcut of a model, you can specify the maximum number of images to download. \n This is the maximum per version, and setting it to 0 means unlimited downloads.", visible=True)
with gr.Row():
gallery_thumbnail_image_style = gr.Dropdown(choices=["scale-down","cover","contain","fill","none"], value=setting.gallery_thumbnail_image_style, label="Gallery Thumbnail Image Style")
with gr.Row(): with gr.Row():
with gr.Accordion("User Gallery Images", open=True): with gr.Accordion("User Gallery Images", open=True):
@ -359,6 +388,7 @@ def on_setting_ui():
with gr.Row(): with gr.Row():
with gr.Accordion("Download Folder for Extensions", open=True): with gr.Accordion("Download Folder for Extensions", open=True):
with gr.Column(): with gr.Column():
extension_locon_folder = gr.Textbox(value=setting.model_folders['LoCon'], label="LyCORIS", interactive=True)
extension_wildcards_folder = gr.Textbox(value=setting.model_folders['Wildcards'], label="Wildcards", interactive=True) extension_wildcards_folder = gr.Textbox(value=setting.model_folders['Wildcards'], label="Wildcards", interactive=True)
extension_controlnet_folder = gr.Textbox(value=setting.model_folders['Controlnet'], label="Controlnet", interactive=True) extension_controlnet_folder = gr.Textbox(value=setting.model_folders['Controlnet'], label="Controlnet", interactive=True)
extension_aestheticgradient_folder = gr.Textbox(value=setting.model_folders['AestheticGradient'], label="Aesthetic Gradient", interactive=True) extension_aestheticgradient_folder = gr.Textbox(value=setting.model_folders['AestheticGradient'], label="Aesthetic Gradient", interactive=True)
@ -368,7 +398,15 @@ def on_setting_ui():
with gr.Row(): with gr.Row():
save_btn = gr.Button(value="Save Setting", variant="primary") save_btn = gr.Button(value="Save Setting", variant="primary")
reload_btn = gr.Button(value="Reload UI")
# update_btn = gr.Button(value="Update", visible=False)
# update_btn.click(fn=on_update_btn_click,inputs=None,outputs=None)
# reload the page
reload_btn.click(fn=on_reload_btn_click, _js='restart_reload', inputs=None, outputs=None)
usergallery_openfolder_btn.click( usergallery_openfolder_btn.click(
fn=on_usergallery_openfolder_btn_click, fn=on_usergallery_openfolder_btn_click,
inputs=None, inputs=None,
@ -384,6 +422,8 @@ def on_setting_ui():
save_btn.click( save_btn.click(
fn=on_save_btn_click, fn=on_save_btn_click,
inputs=[ inputs=[
scbrowser_screen_split_ratio,
info_gallery_height,
shortcut_column, shortcut_column,
shortcut_count_per_page, shortcut_count_per_page,
gallery_column, gallery_column,
@ -392,6 +432,7 @@ def on_setting_ui():
usergallery_images_page_limit, usergallery_images_page_limit,
shortcut_max_download_image_per_version, shortcut_max_download_image_per_version,
gallery_thumbnail_image_style, gallery_thumbnail_image_style,
extension_locon_folder,
extension_wildcards_folder, extension_wildcards_folder,
extension_controlnet_folder, extension_controlnet_folder,
extension_aestheticgradient_folder, extension_aestheticgradient_folder,

View File

@ -2,17 +2,17 @@ import re
import os import os
import json import json
import hashlib import hashlib
import io import io
import platform import platform
import subprocess import subprocess
# from modules import shared
# import modules.scripts as scripts
from modules import scripts, script_callbacks, shared
from . import setting from . import setting
from modules import shared
import modules.scripts as scripts
from tqdm import tqdm from tqdm import tqdm
def printD(msg): def printD(msg):
@ -313,20 +313,32 @@ def write_InternetShortcut(path, url):
return False return False
return True return True
# def load_InternetShortcut(path)->str:
# urls = ""
# try:
# with open(path, 'r') as f:
# #with open(path, 'r', encoding='utf8') as f:
# content = f.readlines()
# for line in content:
# if line.startswith('URL='):
# urls = line[4:]
# except Exception as e:
# printD(e)
# return
# return urls.strip()
def load_InternetShortcut(path)->str: def load_InternetShortcut(path)->str:
urls = "" urls = list()
try: try:
with open(path, 'r') as f: with open(path, 'r') as f:
#with open(path, 'r', encoding='utf8') as f: content = f.read()
content = f.readlines() urls = re.findall("(?P<url>https?://[^\s]+)", content)
for line in content:
if line.startswith('URL='):
urls = line[4:]
except Exception as e: except Exception as e:
printD(e) printD(e)
return return
# printD(urls)
return urls.strip() return urls
# get image with full size # get image with full size
# width is in number, not string # width is in number, not string

View File

@ -1,9 +1,10 @@
import os import os
import datetime import datetime
import gradio as gr import gradio as gr
import modules.scripts as scripts # import modules.scripts as scripts
# from modules import shared
# from modules import script_callbacks
from modules import shared
from modules import script_callbacks from modules import script_callbacks
from scripts.civitai_manager_libs import model from scripts.civitai_manager_libs import model
@ -81,6 +82,9 @@ def civitai_shortcut_ui():
def init_civitai_shortcut(): def init_civitai_shortcut():
setting.init() setting.init()
model.update_downloaded_model() model.update_downloaded_model()
# util.printD(os.path.abspath(__file__))
# util.printD(os.path.abspath(root_path))
# init # init
init_civitai_shortcut() init_civitai_shortcut()

View File

@ -3,5 +3,5 @@
} }
.block.padded.cs_vpadding { .block.padded.cs_vpadding {
padding: 10px 0 !important; padding: 10px 10px !important;
} }