data.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. from ipfml import processing, metrics, utils
  2. from modules.utils.config import *
  3. from preprocessing_functions import svd_reconstruction
  4. from PIL import Image
  5. from skimage import color
  6. from sklearn.decomposition import FastICA
  7. from sklearn.decomposition import IncrementalPCA
  8. from sklearn.decomposition import TruncatedSVD
  9. from numpy.linalg import svd as lin_svd
  10. from scipy.signal import medfilt2d, wiener, cwt
  11. import pywt
  12. import numpy as np
  13. _scenes_names_prefix = '_scenes_names'
  14. _scenes_indices_prefix = '_scenes_indices'
  15. # store all variables from current module context
  16. context_vars = vars()
  17. def get_data(data_type, block, interval=(100, 200)):
  18. """
  19. Method which returns the data type expected
  20. """
  21. if data_type == 'svd_reconstruct':
  22. begin, end = interval
  23. data = svd_reconstruction(block, [begin, end])
  24. return data
  25. def get_renderer_scenes_indices(renderer_name):
  26. if renderer_name not in renderer_choices:
  27. raise ValueError("Unknown renderer name")
  28. if renderer_name == 'all':
  29. return scenes_indices
  30. else:
  31. return context_vars[renderer_name + _scenes_indices_prefix]
  32. def get_renderer_scenes_names(renderer_name):
  33. if renderer_name not in renderer_choices:
  34. raise ValueError("Unknown renderer name")
  35. if renderer_name == 'all':
  36. return scenes_names
  37. else:
  38. return context_vars[renderer_name + _scenes_names_prefix]