Commit 423e6c2 1 parent 9fc2740 commit 423e6c2 Copy full SHA for 423e6c2
File tree 1 file changed +17
-9
lines changed
1 file changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -1200,19 +1200,27 @@ def __init__(
1200
1200
tags_list = []
1201
1201
for image_key , img_md in metadata .items ():
1202
1202
# path情報を作る
1203
+ abs_path = None
1204
+
1205
+ # まず画像を優先して探す
1203
1206
if os .path .exists (image_key ):
1204
1207
abs_path = image_key
1205
- elif os .path .exists (os .path .splitext (image_key )[0 ] + ".npz" ):
1206
- abs_path = os .path .splitext (image_key )[0 ] + ".npz"
1207
1208
else :
1208
- npz_path = os .path .join (subset .image_dir , image_key + ".npz" )
1209
- if os .path .exists (npz_path ):
1210
- abs_path = npz_path
1209
+ # わりといい加減だがいい方法が思いつかん
1210
+ paths = glob_images (subset .image_dir , image_key )
1211
+ if len (paths ) > 0 :
1212
+ abs_path = paths [0 ]
1213
+
1214
+ # なければnpzを探す
1215
+ if abs_path is None :
1216
+ if os .path .exists (os .path .splitext (image_key )[0 ] + ".npz" ):
1217
+ abs_path = os .path .splitext (image_key )[0 ] + ".npz"
1211
1218
else :
1212
- # わりといい加減だがいい方法が思いつかん
1213
- abs_path = glob_images (subset .image_dir , image_key )
1214
- assert len (abs_path ) >= 1 , f"no image / 画像がありません: { image_key } "
1215
- abs_path = abs_path [0 ]
1219
+ npz_path = os .path .join (subset .image_dir , image_key + ".npz" )
1220
+ if os .path .exists (npz_path ):
1221
+ abs_path = npz_path
1222
+
1223
+ assert abs_path is not None , f"no image / 画像がありません: { image_key } "
1216
1224
1217
1225
caption = img_md .get ("caption" )
1218
1226
tags = img_md .get ("tags" )
You can’t perform that action at this time.
0 commit comments