mirror of
https://github.com/kohya-ss/sd-scripts.git
synced 2026-04-18 01:30:02 +00:00
support metadata json+.npz caching (no prepare)
This commit is contained in:
@@ -1200,19 +1200,27 @@ class FineTuningDataset(BaseDataset):
|
|||||||
tags_list = []
|
tags_list = []
|
||||||
for image_key, img_md in metadata.items():
|
for image_key, img_md in metadata.items():
|
||||||
# path情報を作る
|
# path情報を作る
|
||||||
|
abs_path = None
|
||||||
|
|
||||||
|
# まず画像を優先して探す
|
||||||
if os.path.exists(image_key):
|
if os.path.exists(image_key):
|
||||||
abs_path = image_key
|
abs_path = image_key
|
||||||
elif os.path.exists(os.path.splitext(image_key)[0] + ".npz"):
|
|
||||||
abs_path = os.path.splitext(image_key)[0] + ".npz"
|
|
||||||
else:
|
else:
|
||||||
npz_path = os.path.join(subset.image_dir, image_key + ".npz")
|
# わりといい加減だがいい方法が思いつかん
|
||||||
if os.path.exists(npz_path):
|
paths = glob_images(subset.image_dir, image_key)
|
||||||
abs_path = npz_path
|
if len(paths) > 0:
|
||||||
|
abs_path = paths[0]
|
||||||
|
|
||||||
|
# なければnpzを探す
|
||||||
|
if abs_path is None:
|
||||||
|
if os.path.exists(os.path.splitext(image_key)[0] + ".npz"):
|
||||||
|
abs_path = os.path.splitext(image_key)[0] + ".npz"
|
||||||
else:
|
else:
|
||||||
# わりといい加減だがいい方法が思いつかん
|
npz_path = os.path.join(subset.image_dir, image_key + ".npz")
|
||||||
abs_path = glob_images(subset.image_dir, image_key)
|
if os.path.exists(npz_path):
|
||||||
assert len(abs_path) >= 1, f"no image / 画像がありません: {image_key}"
|
abs_path = npz_path
|
||||||
abs_path = abs_path[0]
|
|
||||||
|
assert abs_path is not None, f"no image / 画像がありません: {image_key}"
|
||||||
|
|
||||||
caption = img_md.get("caption")
|
caption = img_md.get("caption")
|
||||||
tags = img_md.get("tags")
|
tags = img_md.get("tags")
|
||||||
|
|||||||
Reference in New Issue
Block a user