marta-marta commited on
Commit
484d52e
·
1 Parent(s): e533a14

Found error in reading of output files. Need to edit how to output the files

Browse files
Data_Generation/Dataset_Generation_Functions.py CHANGED
@@ -7,7 +7,7 @@ import json
7
  from Data_Generation.Piecewise_Box_Functions import basic_box_array, back_slash_array, forward_slash_array, hamburger_array, hot_dog_array
8
  # from Piecewise_Box_Functions import basic_box_array, back_slash_array, forward_slash_array, hamburger_array, hot_dog_array
9
  import matplotlib.pyplot as plt
10
-
11
 
12
 
13
 
@@ -77,8 +77,17 @@ boxes = make_boxes(image_size, densities)
77
 
78
  box_arrays, box_density, basic_box_thickness, forward_slash_box_thickness, back_slash_box_thickness,hot_dog_box_thickness, hamburger_box_thickness\
79
  = list(zip(*boxes))[0], list(zip(*boxes))[1], list(zip(*boxes))[2], list(zip(*boxes))[3], list(zip(*boxes))[4], list(zip(*boxes))[5], list(zip(*boxes))[6]
 
 
 
 
 
 
 
 
80
 
81
 
 
82
 
83
  # Create a dataframe to convert the data to a csv file
84
  dataframe = (pd.DataFrame((box_arrays, box_density, basic_box_thickness, forward_slash_box_thickness, back_slash_box_thickness,hot_dog_box_thickness, hamburger_box_thickness)).T).astype(str)
@@ -86,17 +95,17 @@ dataframe = (pd.DataFrame((box_arrays, box_density, basic_box_thickness, forward
86
  # Rename the columns to the desired outputs
87
  dataframe = dataframe.rename(columns={0: "Array", 1: "Density", 2:"Basic Box Thickness", 3:"Forward Slash Strut Thickness", 4:"Back Slash Strut Thickness", 5:"Vertical Strut Thickness", 6:"Horizontal Strut Thickness"})
88
 
89
- csv = dataframe.to_csv('2D_Lattice')
90
 
91
 
92
-
93
- df = pd.read_csv('2D_Lattice')
94
  # print(df)
95
  row = 0
96
  box = df.iloc[row, 1]
97
  print(box)
98
  array = np.array(json.loads(box))
99
-
 
100
 
101
  # import matplotlib.pyplot as plt
102
  # plt.imshow(np.array(box))
 
7
  from Data_Generation.Piecewise_Box_Functions import basic_box_array, back_slash_array, forward_slash_array, hamburger_array, hot_dog_array
8
  # from Piecewise_Box_Functions import basic_box_array, back_slash_array, forward_slash_array, hamburger_array, hot_dog_array
9
  import matplotlib.pyplot as plt
10
+ from json import JSONEncoder
11
 
12
 
13
 
 
77
 
78
  box_arrays, box_density, basic_box_thickness, forward_slash_box_thickness, back_slash_box_thickness,hot_dog_box_thickness, hamburger_box_thickness\
79
  = list(zip(*boxes))[0], list(zip(*boxes))[1], list(zip(*boxes))[2], list(zip(*boxes))[3], list(zip(*boxes))[4], list(zip(*boxes))[5], list(zip(*boxes))[6]
80
+ print(type(box_arrays[0]))
81
+
82
+
83
+ class NumpyArrayEncoder(JSONEncoder):
84
+ def default(self, obj):
85
+ if isinstance(obj, np.ndarray):
86
+ return obj.tolist()
87
+ return JSONEncoder.default(self, obj)
88
 
89
 
90
+ box_arrays = [json.dumps(x, cls=NumpyArrayEncoder) for x in box_arrays] # find argument for json dumps for numpy
91
 
92
  # Create a dataframe to convert the data to a csv file
93
  dataframe = (pd.DataFrame((box_arrays, box_density, basic_box_thickness, forward_slash_box_thickness, back_slash_box_thickness,hot_dog_box_thickness, hamburger_box_thickness)).T).astype(str)
 
95
  # Rename the columns to the desired outputs
96
  dataframe = dataframe.rename(columns={0: "Array", 1: "Density", 2:"Basic Box Thickness", 3:"Forward Slash Strut Thickness", 4:"Back Slash Strut Thickness", 5:"Vertical Strut Thickness", 6:"Horizontal Strut Thickness"})
97
 
98
+ csv = dataframe.to_csv('2D_Lattice.csv')
99
 
100
 
101
+ df = pd.read_csv('2D_Lattice.csv')
 
102
  # print(df)
103
  row = 0
104
  box = df.iloc[row, 1]
105
  print(box)
106
  array = np.array(json.loads(box))
107
+ plt.imshow(array)
108
+ plt.show()
109
 
110
  # import matplotlib.pyplot as plt
111
  # plt.imshow(np.array(box))
app.py CHANGED
@@ -7,7 +7,7 @@ from Data_Generation.Dataset_Generation_Functions import make_boxes
7
  from Data_Generation.Piecewise_Box_Functions import basic_box_array, forward_slash_array, combine_arrays, add_thickness
8
  ########################################################################################################################
9
  # User Inputs
10
- image_size = st.slider('Select a value for the image size', min_value=9, max_value=28)
11
  # st.write(x, 'squared is', x * x)
12
 
13
  density_selection = st.slider('Select a value for the number of equally spaced density values (0, 1]', min_value=1, max_value=10)
 
7
  from Data_Generation.Piecewise_Box_Functions import basic_box_array, forward_slash_array, combine_arrays, add_thickness
8
  ########################################################################################################################
9
  # User Inputs
10
+ image_size = st.slider('Select a value for the image size', min_value=9, max_value=16)
11
  # st.write(x, 'squared is', x * x)
12
 
13
  density_selection = st.slider('Select a value for the number of equally spaced density values (0, 1]', min_value=1, max_value=10)