run_all_estimators.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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('--tiles', type=str, help='tiles size: 100,100', default="100,100")
  9. parser.add_argument('--output', type=str, help='output folder', required=True)
  10. args = parser.parse_args()
  11. p_folder = args.folder
  12. p_nfiles = args.nfiles
  13. x_tile, y_tile = list(map(int, args.tiles.split(',')))
  14. p_output = args.output
  15. scenes = sorted(os.listdir(p_folder))
  16. for est in estimators:
  17. for scene in scenes:
  18. scene_path = os.path.join(p_folder, scene)
  19. nelements = len(os.listdir(scene_path))
  20. if nelements == p_nfiles:
  21. print('Extraction of {0} estimator for {1} scene'.format(est, scene))
  22. output_folder = os.path.join(p_output, est, scene)
  23. if not os.path.exists(output_folder):
  24. os.makedirs(output_folder)
  25. outfilename = os.path.join(output_folder, scene + '_10000.rawls')
  26. os.system('./build/main/extract_stats_images --folder {0} --bwidth {1} --bheight {2} --outfile {3} --estimator {4}'.format(scene_path, x_tile, y_tile, est, outfilename))
  27. if __name__ == "__main__":
  28. main()