run_all_estimators.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import os
  2. import argparse
  3. def main():
  4. estimators = ["median", "variance", "std", "skewness", "kurtosis", "mode"]
  5. parser = argparse.ArgumentParser("Run estimators reconstruction")
  6. parser.add_argument('--folder', type=str, help='folder with rawls scene data', required=True)
  7. parser.add_argument('--nfiles', type=int, help='expected number of rawls files', required=True)
  8. parser.add_argument('--est', type=str, help='estimator to use', choices=estimators, required=True)
  9. parser.add_argument('--tiles', type=str, help='tiles size: 100,100', default="100,100")
  10. parser.add_argument('--output', type=str, help='output folder', required=True)
  11. args = parser.parse_args()
  12. p_folder = args.folder
  13. p_nfiles = args.nfiles
  14. p_est = args.est
  15. x_tile, y_tile = list(map(int, args.tiles.split(',')))
  16. p_output = args.output
  17. scenes = sorted(os.listdir(p_folder))
  18. for scene in scenes:
  19. scene_path = os.path.join(p_folder, scene)
  20. nelements = len(os.listdir(scene_path))
  21. if nelements == p_nfiles:
  22. print('Extraction of {0} estimator for {1} scene'.format(p_est, scene))
  23. output_folder = os.path.join(p_output, p_est, scene)
  24. if not os.path.exists(output_folder):
  25. os.makedirs(output_folder)
  26. outfilename = os.path.join(output_folder, scene + '_10000.rawls')
  27. if not os.path.exists(outfilename):
  28. os.system('./build/main/extract_stats_images --folder {0} --bwidth {1} --bheight {2} --outfile {3} --estimator {4}'.format(scene_path, x_tile, y_tile, p_est, outfilename))
  29. else:
  30. print('Already generated')
  31. if __name__ == "__main__":
  32. main()