This commit is contained in:
Eric Lam 2025-05-18 22:09:13 -07:00
parent d9a36dc901
commit 82895efcec
3 changed files with 55 additions and 8 deletions

View File

@ -891,6 +891,21 @@ def check_model_installed(json_obj):
return True
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',
'diffusers', 'vae_approx', 'controlnet', 'gligen', 'upscale_models', 'hypernetworks',
@ -902,19 +917,34 @@ def check_model_installed(json_obj):
total_models_files.add(y)
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']:
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
if item['filename'] in total_models_files:
item['installed'] = 'True'
item['full_paths'] = full_paths
return
if item['save_path'] == 'default':
item['group'] = 'B'
model_dir_name = model_dir_name_map.get(item['type'].lower())
if model_dir_name is not None:
item['installed'] = str(is_exists(model_dir_name, item['filename'], item['url']))
else:
item['installed'] = 'False'
else:
item['group'] = 'C'
model_dir_name = item['save_path'].split('/')[0]
if model_dir_name in folder_paths.folder_names_and_paths:
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):
item['installed'] = 'True'
item['folder_path_source'] = base_path
add_to_full_paths(fullpath)
with concurrent.futures.ThreadPoolExecutor(8) as executor:
for item in json_obj['models']:

View File

@ -121,6 +121,10 @@
text-decoration: none;
}
.cmm-manager-grid .cmm-node-full-paths li {
overflow-wrap: break-word;
}
.cmm-manager-grid .tg-cell a:hover {
text-decoration: underline;
}

View File

@ -249,14 +249,14 @@ export class ModelManager {
bindContainerResize: true,
cellResizeObserver: (rowItem, columnItem) => {
const autoHeightColumns = ['name', 'description', 'folder_path_source'];
const autoHeightColumns = ['name', 'description', 'full_paths'];
return autoHeightColumns.includes(columnItem.id)
},
// updateGrid handler for filter and keywords
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'];
let shouldShown = grid.highlightKeywordsFilter(rowItem, searchableColumns, this.keywords);
@ -382,11 +382,20 @@ export class ModelManager {
maxWidth: 5000,
classMap: 'cmm-node-desc'
}, {
id: 'folder_path_source',
name: 'Folder Path Source',
width: 400,
maxWidth: 5000,
classMap: 'cmm-node-desc'
id: 'full_paths',
name: 'Full Paths',
width: 200,
maxWidth: 2000,
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",
name: 'Save Path',
@ -395,6 +404,10 @@ export class ModelManager {
id: 'filename',
name: 'Filename',
width: 200
}, {
id: 'group',
name: 'Group',
width: 200
}];
restoreColumnWidth(gridId, columns);