mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 17:24:32 +02:00
In-Memory Directory/File Cache
This commit is contained in:
@@ -11,7 +11,7 @@ from torch import einsum
|
||||
from torch.nn.init import normal_, xavier_normal_, xavier_uniform_, kaiming_normal_, kaiming_uniform_, zeros_
|
||||
from einops import rearrange, repeat
|
||||
from ldm.util import default
|
||||
from modules import devices, processing, sd_models, shared, hashes, sd_hijack_checkpoint, errors
|
||||
from modules import devices, processing, sd_models, shared, hashes, sd_hijack_checkpoint, errors, files_cache
|
||||
import modules.textual_inversion.dataset
|
||||
from modules.textual_inversion import textual_inversion, ti_logging
|
||||
from modules.textual_inversion.learn_schedule import LearnRateScheduler
|
||||
@@ -282,18 +282,15 @@ class Hypernetwork:
|
||||
|
||||
|
||||
def list_hypernetworks(path):
|
||||
res = {}
|
||||
def list_folder(folder):
|
||||
for filename in os.listdir(folder):
|
||||
fn = os.path.join(folder, filename)
|
||||
if os.path.isfile(fn) and fn.lower().endswith(".pt"):
|
||||
name = os.path.splitext(os.path.basename(fn))[0]
|
||||
res[name] = fn
|
||||
elif os.path.isdir(fn) and not fn.startswith('.'):
|
||||
list_folder(fn)
|
||||
|
||||
list_folder(path)
|
||||
return res
|
||||
return {
|
||||
os.path.splitext(os.path.basename(hypernetwork_path))[0]: hypernetwork_path
|
||||
for hypernetwork_path
|
||||
in files_cache.list_files(
|
||||
path,
|
||||
ext_filter=['.pt'],
|
||||
recursive=files_cache.not_hidden
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
def load_hypernetwork(name):
|
||||
|
||||
Reference in New Issue
Block a user