mirror of
https://github.com/Comfy-Org/ComfyUI-Manager.git
synced 2025-12-22 12:50:50 +08:00
WIP
This commit is contained in:
parent
d9a36dc901
commit
82895efcec
@ -891,6 +891,21 @@ def check_model_installed(json_obj):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def get_base_folder_path(model_dir_name, filename, url):
|
||||||
|
if filename == '<huggingface>':
|
||||||
|
filename = os.path.basename(url)
|
||||||
|
|
||||||
|
dirs = folder_paths.get_folder_paths(model_dir_name)
|
||||||
|
|
||||||
|
results = []
|
||||||
|
for x in dirs:
|
||||||
|
full_path = os.path.join(x, filename)
|
||||||
|
if os.path.exists(full_path):
|
||||||
|
results.append(full_path)
|
||||||
|
|
||||||
|
return results
|
||||||
|
|
||||||
|
|
||||||
model_dir_names = ['checkpoints', 'loras', 'vae', 'text_encoders', 'diffusion_models', 'clip_vision', 'embeddings',
|
model_dir_names = ['checkpoints', 'loras', 'vae', 'text_encoders', 'diffusion_models', 'clip_vision', 'embeddings',
|
||||||
'diffusers', 'vae_approx', 'controlnet', 'gligen', 'upscale_models', 'hypernetworks',
|
'diffusers', 'vae_approx', 'controlnet', 'gligen', 'upscale_models', 'hypernetworks',
|
||||||
@ -902,19 +917,34 @@ def check_model_installed(json_obj):
|
|||||||
total_models_files.add(y)
|
total_models_files.add(y)
|
||||||
|
|
||||||
def process_model_phase(item):
|
def process_model_phase(item):
|
||||||
|
def add_to_full_paths(path):
|
||||||
|
if 'full_paths' in item:
|
||||||
|
item['full_paths'].append(path)
|
||||||
|
else:
|
||||||
|
item['full_paths'] = [ path ]
|
||||||
|
|
||||||
if 'diffusion' not in item['filename'] and 'pytorch' not in item['filename'] and 'model' not in item['filename']:
|
if 'diffusion' not in item['filename'] and 'pytorch' not in item['filename'] and 'model' not in item['filename']:
|
||||||
|
model_dir_name = model_dir_name_map.get(item['type'].lower())
|
||||||
|
full_paths = get_base_folder_path(model_dir_name, item['filename'], item['url'])
|
||||||
|
|
||||||
|
item['group'] = f"A"
|
||||||
|
|
||||||
# non-general name case
|
# non-general name case
|
||||||
if item['filename'] in total_models_files:
|
if item['filename'] in total_models_files:
|
||||||
item['installed'] = 'True'
|
item['installed'] = 'True'
|
||||||
|
item['full_paths'] = full_paths
|
||||||
return
|
return
|
||||||
|
|
||||||
if item['save_path'] == 'default':
|
if item['save_path'] == 'default':
|
||||||
|
item['group'] = 'B'
|
||||||
model_dir_name = model_dir_name_map.get(item['type'].lower())
|
model_dir_name = model_dir_name_map.get(item['type'].lower())
|
||||||
if model_dir_name is not None:
|
if model_dir_name is not None:
|
||||||
item['installed'] = str(is_exists(model_dir_name, item['filename'], item['url']))
|
item['installed'] = str(is_exists(model_dir_name, item['filename'], item['url']))
|
||||||
else:
|
else:
|
||||||
item['installed'] = 'False'
|
item['installed'] = 'False'
|
||||||
else:
|
else:
|
||||||
|
item['group'] = 'C'
|
||||||
|
|
||||||
model_dir_name = item['save_path'].split('/')[0]
|
model_dir_name = item['save_path'].split('/')[0]
|
||||||
if model_dir_name in folder_paths.folder_names_and_paths:
|
if model_dir_name in folder_paths.folder_names_and_paths:
|
||||||
if is_exists(model_dir_name, item['filename'], item['url']):
|
if is_exists(model_dir_name, item['filename'], item['url']):
|
||||||
@ -937,7 +967,7 @@ def check_model_installed(json_obj):
|
|||||||
|
|
||||||
if os.path.exists(fullpath):
|
if os.path.exists(fullpath):
|
||||||
item['installed'] = 'True'
|
item['installed'] = 'True'
|
||||||
item['folder_path_source'] = base_path
|
add_to_full_paths(fullpath)
|
||||||
|
|
||||||
with concurrent.futures.ThreadPoolExecutor(8) as executor:
|
with concurrent.futures.ThreadPoolExecutor(8) as executor:
|
||||||
for item in json_obj['models']:
|
for item in json_obj['models']:
|
||||||
|
|||||||
@ -121,6 +121,10 @@
|
|||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.cmm-manager-grid .cmm-node-full-paths li {
|
||||||
|
overflow-wrap: break-word;
|
||||||
|
}
|
||||||
|
|
||||||
.cmm-manager-grid .tg-cell a:hover {
|
.cmm-manager-grid .tg-cell a:hover {
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -249,14 +249,14 @@ export class ModelManager {
|
|||||||
bindContainerResize: true,
|
bindContainerResize: true,
|
||||||
|
|
||||||
cellResizeObserver: (rowItem, columnItem) => {
|
cellResizeObserver: (rowItem, columnItem) => {
|
||||||
const autoHeightColumns = ['name', 'description', 'folder_path_source'];
|
const autoHeightColumns = ['name', 'description', 'full_paths'];
|
||||||
return autoHeightColumns.includes(columnItem.id)
|
return autoHeightColumns.includes(columnItem.id)
|
||||||
},
|
},
|
||||||
|
|
||||||
// updateGrid handler for filter and keywords
|
// updateGrid handler for filter and keywords
|
||||||
rowFilter: (rowItem) => {
|
rowFilter: (rowItem) => {
|
||||||
|
|
||||||
const searchableColumns = ["name", "type", "base", "description", "filename", "save_path", "folder_path_source"];
|
const searchableColumns = ["name", "type", "base", "description", "filename", "save_path", "full_paths", "group"];
|
||||||
const models_extensions = ['.ckpt', '.pt', '.pt2', '.bin', '.pth', '.safetensors', '.pkl', '.sft'];
|
const models_extensions = ['.ckpt', '.pt', '.pt2', '.bin', '.pth', '.safetensors', '.pkl', '.sft'];
|
||||||
|
|
||||||
let shouldShown = grid.highlightKeywordsFilter(rowItem, searchableColumns, this.keywords);
|
let shouldShown = grid.highlightKeywordsFilter(rowItem, searchableColumns, this.keywords);
|
||||||
@ -382,11 +382,20 @@ export class ModelManager {
|
|||||||
maxWidth: 5000,
|
maxWidth: 5000,
|
||||||
classMap: 'cmm-node-desc'
|
classMap: 'cmm-node-desc'
|
||||||
}, {
|
}, {
|
||||||
id: 'folder_path_source',
|
id: 'full_paths',
|
||||||
name: 'Folder Path Source',
|
name: 'Full Paths',
|
||||||
width: 400,
|
width: 200,
|
||||||
maxWidth: 5000,
|
maxWidth: 2000,
|
||||||
classMap: 'cmm-node-desc'
|
classMap: 'cmm-node-full-paths',
|
||||||
|
formatter: (full_paths) => {
|
||||||
|
if (typeof full_paths === "object" && Array.isArray(full_paths)) {
|
||||||
|
const styled_full_paths = full_paths.map(path => '<li>' + path + '</li>').join("");
|
||||||
|
|
||||||
|
return `<ul>${styled_full_paths}</ul>`;
|
||||||
|
} else {
|
||||||
|
return full_paths;
|
||||||
|
}
|
||||||
|
}
|
||||||
}, {
|
}, {
|
||||||
id: "save_path",
|
id: "save_path",
|
||||||
name: 'Save Path',
|
name: 'Save Path',
|
||||||
@ -395,6 +404,10 @@ export class ModelManager {
|
|||||||
id: 'filename',
|
id: 'filename',
|
||||||
name: 'Filename',
|
name: 'Filename',
|
||||||
width: 200
|
width: 200
|
||||||
|
}, {
|
||||||
|
id: 'group',
|
||||||
|
name: 'Group',
|
||||||
|
width: 200
|
||||||
}];
|
}];
|
||||||
|
|
||||||
restoreColumnWidth(gridId, columns);
|
restoreColumnWidth(gridId, columns);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user