@@ -27,7 +27,8 @@ def __init__(self, extracted_data_file_path, pca_data_file_path, extracted_data=
2727 if extracted_data is None :
2828 extracted_data = loadDataFile (extracted_data_file_path )
2929
30- n_extracted_datapoints = len (list (extracted_data [0 ][0 ].keys ()))
30+ extracted_datapoints = list (extracted_data [0 ][0 ].keys ())
31+ n_extracted_datapoints = len (extracted_datapoints )
3132
3233 print ("Number of extracted light directions: {}" .format (n_extracted_datapoints ))
3334
@@ -51,8 +52,8 @@ def __init__(self, extracted_data_file_path, pca_data_file_path, extracted_data=
5152 constants ["SQAURE_GRID_DIMENSION" ] * constants ["SQAURE_GRID_DIMENSION" ]
5253 )
5354 ):
54- x = i % constants ["SQAURE_GRID_DIMENSION" ]
55- y = math . floor ( i / constants ["SQAURE_GRID_DIMENSION" ])
55+ x = math . floor ( i / constants ["SQAURE_GRID_DIMENSION" ])
56+ y = i % constants ["SQAURE_GRID_DIMENSION" ]
5657 full_pca_data [i ] = list (extracted_data [x ][y ].values ())
5758
5859 print ("Running PCA" )
@@ -71,25 +72,23 @@ def __init__(self, extracted_data_file_path, pca_data_file_path, extracted_data=
7172 writeDataFile (pca_data_file_path , pca_data )
7273
7374 print ("Preparing dataset data" )
74-
75- keys = list (extracted_data [0 ][0 ].keys ())
76- light_directions_x = [i .split ("|" )[0 ] for i in keys ]
77- light_directions_y = [i .split ("|" )[1 ] for i in keys ]
7875 for x in tqdm (range (constants ["SQAURE_GRID_DIMENSION" ])):
7976 for y in range (constants ["SQAURE_GRID_DIMENSION" ]):
80- pixel_intensities = list (extracted_data [x ][y ].values ())
8177 for z in range (n_extracted_datapoints ):
78+ lightDirection = extracted_datapoints [z ]
79+ light_direction_x = float (fromIndexToLightDir (lightDirection .split ("|" )[0 ]))
80+ light_direction_y = float (fromIndexToLightDir (lightDirection .split ("|" )[1 ]))
8281 i = (x * constants ["SQAURE_GRID_DIMENSION" ] * n_extracted_datapoints ) + (y * n_extracted_datapoints ) + z
8382 self .data [i ] = torch .cat (
8483 (
8584 pca_data [x ][y ],
8685 torch .tensor (
8786 [
88- float ( fromIndexToLightDir ( light_directions_x [ z ])) ,
89- float ( fromIndexToLightDir ( light_directions_y [ z ])) ,
87+ light_direction_x ,
88+ light_direction_y ,
9089 ]
9190 ),
92- torch .tensor ([pixel_intensities [ z ]]),
91+ torch .tensor ([extracted_data [ x ][ y ][ lightDirection ]]),
9392 ),
9493 dim = - 1 ,
9594 )
0 commit comments