-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathfind_missing_dat_png.py
More file actions
59 lines (46 loc) · 1.73 KB
/
Copy pathfind_missing_dat_png.py
File metadata and controls
59 lines (46 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import os, sys, math
import argparse
from collections import defaultdict
import numpy as np
class FindMissingDatPng():
def __init__(self):
pass
def listFiles(self, dir, ext, ignoreExt=None):
"""
Return array of all files in dir ending in ext but not ignoreExt.
"""
matches = []
for root, dirs, files in os.walk(dir):
for f in files:
if f.endswith(ext):
if not ignoreExt or (ignoreExt and not f.endswith(ignoreExt)):
matches.append(os.path.join(root, f))
return matches
def find_missing_files(self, list_a, list_b):
for file in list_a:
if file.endswith(".png"):
exists = os.path.exists(file.replace(".png", ".dat"))
if not exists:
print("MISSING {}".format(file.replace(".png", ".dat")))
else:
exists = os.path.exists(file.replace(".dat", ".png"))
if not exists:
print("MISSING {}".format(file.replace(".dat", ".png")))
def main():
gen = FindMissingDatPng()
rendering_dats = gen.listFiles(args.dataset, ".dat")
rendering_images = gen.listFiles(args.dataset, ".png")
gen.find_missing_files(rendering_dats, rendering_images)
gen.find_missing_files(rendering_images, rendering_dats)
def get_args():
global args
parser = argparse.ArgumentParser(description='Generates a train and test split.')
parser.add_argument('--dataset', type=str, required=True)
args = parser.parse_args()
def validate():
if not (os.path.exists(args.dataset)):
sys.exit("DataSet path does not exist")
if __name__ == "__main__":
get_args()
validate()
main()