display_reconstructed_image_from_simulation.py 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. # main imports
  2. import numpy as np
  3. import pandas as pd
  4. import os, sys, argparse
  5. # image processing imports
  6. import matplotlib.pyplot as plt
  7. # modules imports
  8. sys.path.insert(0, '') # trick to enable import of main folder module
  9. import custom_config as cfg
  10. from data_attributes import get_image_features
  11. # other variables
  12. learned_zones_folder = cfg.learned_zones_folder
  13. models_name = cfg.models_names_list
  14. def reconstruct_image(folder_path, model_name):
  15. """
  16. @brief Method used to display simulation given .csv files
  17. @param folder_path, folder which contains all .csv files obtained during simulation
  18. @param model_name, current name of model
  19. @return nothing
  20. """
  21. for name in models_name:
  22. if name in model_name:
  23. data_filename = model_name
  24. learned_zones_folder_path = os.path.join(learned_zones_folder, data_filename)
  25. data_files = [x for x in os.listdir(folder_path) if '.png' not in x]
  26. scene_names = [f.split('_')[3] for f in data_files]
  27. for id, f in enumerate(data_files):
  28. print(scene_names[id])
  29. path_file = os.path.join(folder_path, f)
  30. scenes_zones_used_file_path = os.path.join(learned_zones_folder_path, scene_names[id] + '.csv')
  31. def main():
  32. parser = argparse.ArgumentParser(description="Display simulations curves from simulation data")
  33. parser.add_argument('--folder', type=str, help='Folder which contains simulations data for scenes')
  34. parser.add_argument('--scene', type=str, help='Scene name index')
  35. parser.add_argument('--model', type=str, help='Name of the model used for simulations')
  36. args = parser.parse_args()
  37. p_folder = args.folder
  38. if args.model:
  39. p_model = args.model
  40. else:
  41. # find p_model from folder if model arg not given (folder path need to have model name)
  42. if p_folder.split('/')[-1]:
  43. p_model = p_folder.split('/')[-1]
  44. else:
  45. p_model = p_folder.split('/')[-2]
  46. print(p_model)
  47. display_curves(p_folder, p_model)
  48. print(p_folder)
  49. if __name__== "__main__":
  50. main()