add multiply.txt to duplicates images in a directory
This commit is contained in:
parent
95f3ad3dc7
commit
c747a7291d
|
@ -116,12 +116,25 @@ class DataLoaderMultiAspect():
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def __recurse_data_root(self, recurse_root):
|
def __recurse_data_root(self, recurse_root):
|
||||||
|
multiply = 1
|
||||||
|
multiply_path = os.path.join(recurse_root, "multiply.txt")
|
||||||
|
if os.path.exists(multiply_path):
|
||||||
|
try:
|
||||||
|
with open(multiply_path, encoding='utf-8', mode='r') as f:
|
||||||
|
multiply = int(float(f.read().strip()))
|
||||||
|
print(f" * DLMA multiply.txt in {recurse_root} set to {multiply}")
|
||||||
|
except:
|
||||||
|
print(f" *** Error reading multiply.txt in {recurse_root}, defaulting to 1")
|
||||||
|
pass
|
||||||
|
|
||||||
for f in os.listdir(recurse_root):
|
for f in os.listdir(recurse_root):
|
||||||
current = os.path.join(recurse_root, f)
|
current = os.path.join(recurse_root, f)
|
||||||
|
|
||||||
if os.path.isfile(current):
|
if os.path.isfile(current):
|
||||||
ext = os.path.splitext(f)[1]
|
ext = os.path.splitext(f)[1]
|
||||||
if ext in ['.jpg', '.jpeg', '.png', '.bmp', '.webp']:
|
if ext in ['.jpg', '.jpeg', '.png', '.bmp', '.webp', '.jfif']:
|
||||||
|
# add image multiplyrepeats number of times
|
||||||
|
for _ in range(multiply):
|
||||||
self.image_paths.append(current)
|
self.image_paths.append(current)
|
||||||
|
|
||||||
sub_dirs = []
|
sub_dirs = []
|
||||||
|
|
Loading…
Reference in New Issue