Visualization approach 1
This commit is contained in:
30
viz/utils.py
Normal file
30
viz/utils.py
Normal file
@ -0,0 +1,30 @@
|
||||
import os
|
||||
|
||||
|
||||
def search_for_weights(func, folder):
|
||||
while not os.path.exists(folder):
|
||||
if len(os.path.split(folder)) >= 50:
|
||||
raise FileNotFoundError(f'The folder "{folder}" could not be found')
|
||||
folder = os.path.join(os.pardir, folder)
|
||||
|
||||
if any([x.name.endswith('.png') for x in os.scandir(folder)]):
|
||||
return
|
||||
|
||||
if any(['.ckpt' in element.name and element.is_dir() for element in os.scandir(folder)]):
|
||||
_, _, filenames = next(os.walk(os.path.join(folder, 'weights.ckpt')))
|
||||
filenames.sort(key=lambda f: int(''.join(filter(str.isdigit, f))))
|
||||
func(os.path.join(folder, 'weights.ckpt', filenames[-1]))
|
||||
return
|
||||
|
||||
for element in os.scandir(folder):
|
||||
if os.path.exists(element):
|
||||
if element.is_dir():
|
||||
search_for_weights(func, element.path)
|
||||
elif element.is_file() and element.name.endswith('.ckpt'):
|
||||
func(element)
|
||||
else:
|
||||
continue
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
raise PermissionError('This file should not be called.')
|
Reference in New Issue
Block a user