display_reconstructed_image_from_simulation.py 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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, p_limit):
  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. # TODO : check if necessary to keep information about zone learned when displaying data
  31. scenes_zones_used_file_path = os.path.join(learned_zones_folder_path, scene_names[id] + '.csv')
  32. # TODO : find estimated threshold for each zone scene using `data_files` and p_limit
  33. # TODO : find images for each zone which are attached to this estimated threshold by the model
  34. # TODO : reconstructed the image using these zones
  35. # TODO : Save the image with generated name based on scene, model and `p_limit`
  36. def main():
  37. parser = argparse.ArgumentParser(description="Display simulations curves from simulation data")
  38. parser.add_argument('--folder', type=str, help='Folder which contains simulations data for scenes')
  39. parser.add_argument('--model', type=str, help='Name of the model used for simulations')
  40. parser.add_argument('--limit', type=int, help='Detection limit to target to stop rendering (number of times model tells image has not more noise)')
  41. args = parser.parse_args()
  42. p_folder = args.folder
  43. p_limit = args.limit
  44. p_output = args.output
  45. if args.model:
  46. p_model = args.model
  47. else:
  48. # find p_model from folder if model arg not given (folder path need to have model name)
  49. if p_folder.split('/')[-1]:
  50. p_model = p_folder.split('/')[-1]
  51. else:
  52. p_model = p_folder.split('/')[-2]
  53. print(p_model)
  54. reconstruct_image(p_folder, p_model, p_limit)
  55. print(p_folder)
  56. if __name__== "__main__":
  57. main()