Commit
·
4b69d10
1
Parent(s):
283cfa3
finalize
Browse files
app.py
CHANGED
@@ -69,56 +69,9 @@ if st.button('Generate Samples'): # Generate the samples
|
|
69 |
# plt.colorbar(cax=cax, shrink=0.1)
|
70 |
st.pyplot(plt.figure(2))
|
71 |
|
72 |
-
|
73 |
-
|
74 |
########################################################################################################################
|
75 |
-
# Output
|
76 |
-
|
77 |
-
# plt.figure(2)
|
78 |
-
# for j in range(5): # shows 5 random images to the users to view samples of the dataset
|
79 |
-
# i = np.random.randint(0, len(result))
|
80 |
-
# plt.subplot(550 + 1 + j)
|
81 |
-
# plt.imshow(result[i], cmap='gray', vmin=0, vmax=1)
|
82 |
-
# plt.figure(2)
|
83 |
-
# st.pyplot(plt.figure(2))
|
84 |
-
|
85 |
-
|
86 |
-
'''
|
87 |
-
# Testing
|
88 |
-
image_size = 100
|
89 |
-
densities = [1]
|
90 |
-
|
91 |
-
boxes = make_boxes(image_size, densities)
|
92 |
-
|
93 |
-
desired_density = 1
|
94 |
-
# desired_thickness = 0
|
95 |
-
|
96 |
-
desired_basic_box_thickness = 1
|
97 |
-
desired_forward_slash_box_thickness = 2
|
98 |
-
desired_back_slash_box_thickness = 0
|
99 |
-
desired_hot_dog_box_thickness = 0
|
100 |
-
desired_hamburger_box_thickness = 0
|
101 |
-
|
102 |
-
|
103 |
-
box_arrays, box_density, basic_box_thickness, forward_slash_box_thickness, back_slash_box_thickness,hot_dog_box_thickness, hamburger_box_thickness\
|
104 |
-
= 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]
|
105 |
-
# print(np.shape(box_arrays))
|
106 |
-
# print(np.shape(box_shape))
|
107 |
-
# print(np.shape(box_density))
|
108 |
-
|
109 |
-
indices = [i for i in range(len(box_arrays)) if box_density[i] == desired_density
|
110 |
-
and basic_box_thickness[i] == desired_basic_box_thickness
|
111 |
-
and forward_slash_box_thickness[i] == desired_forward_slash_box_thickness
|
112 |
-
and back_slash_box_thickness[i] == desired_back_slash_box_thickness
|
113 |
-
and hot_dog_box_thickness[i] == desired_hot_dog_box_thickness
|
114 |
-
and hamburger_box_thickness[i] == desired_hamburger_box_thickness]
|
115 |
-
plt.imshow(box_arrays[indices[0]], cmap='gray', vmin=0, vmax=1)
|
116 |
-
plt.show()
|
117 |
-
'''
|
118 |
-
# # Testing
|
119 |
-
# image_size = 8
|
120 |
-
# densities = [1]
|
121 |
-
|
122 |
if st.button('Generate Dataset'): # Generate the samples
|
123 |
boxes = make_boxes(image_size, densities)
|
124 |
box_arrays, box_density, basic_box_thickness, forward_slash_box_thickness, back_slash_box_thickness,hot_dog_box_thickness, hamburger_box_thickness\
|
@@ -130,67 +83,8 @@ if st.button('Generate Dataset'): # Generate the samples
|
|
130 |
# Rename the columns to the desired outputs
|
131 |
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"})
|
132 |
|
133 |
-
csv = dataframe.to_csv(
|
134 |
-
|
|
|
|
|
135 |
st.download_button("Download Dataset", csv, file_name='2D_Lattice.csv')
|
136 |
-
'''
|
137 |
-
|
138 |
-
# food = load_dataset("cmudrc/2d-lattices", split="train[:15]") # Loads the training data samples
|
139 |
-
food = load_dataset("cmudrc/2d-lattices", split="train+test") # Loads all of the data, for use after training
|
140 |
-
|
141 |
-
# checks to see if the dataset has been assigned a class label
|
142 |
-
# if type(food.features["label"]) != 'datasets.features.features.ClassLabel': # Cast to ClassLabel
|
143 |
-
# food = food.class_encode_column('label')
|
144 |
-
print(food)
|
145 |
-
desired_label = 'x_plus_box'
|
146 |
-
desired_thickness = 3
|
147 |
-
desired_density = 1
|
148 |
-
|
149 |
-
data_frame = pd.DataFrame(food)
|
150 |
-
# print(data_frame)
|
151 |
-
|
152 |
-
shape_rows = data_frame['Shape'] == desired_label
|
153 |
-
# print(shape_rows)
|
154 |
-
|
155 |
-
thickness_rows = data_frame['Thickness'] == desired_thickness
|
156 |
-
# print(thickness_rows)
|
157 |
-
|
158 |
-
density_rows = data_frame['Density'] == desired_density
|
159 |
-
# print(density_rows)
|
160 |
-
|
161 |
-
desired_output = data_frame.loc[shape_rows & thickness_rows & density_rows].iloc[0]['Array']
|
162 |
-
print(desired_output)
|
163 |
-
print(type(desired_output))
|
164 |
-
|
165 |
-
|
166 |
-
example_point = numpy.array(json.loads(desired_output))
|
167 |
-
|
168 |
-
plt.imshow(example_point)
|
169 |
-
plt.show()
|
170 |
-
|
171 |
-
|
172 |
-
all_shapes = [basic_box, diagonal_box_split, horizontal_vertical_box_split, back_slash_box, forward_slash_box,
|
173 |
-
back_slash_plus_box, forward_slash_plus_box, hot_dog_box, hamburger_box, x_hamburger_box,
|
174 |
-
x_hot_dog_box, x_plus_box]
|
175 |
-
|
176 |
-
base_shapes = [basic_box, back_slash_box, forward_slash_box, hot_dog_box, hamburger_box]
|
177 |
-
image_size = 256
|
178 |
-
density = [1]
|
179 |
-
|
180 |
-
boxes = make_boxes(image_size, density, all_shapes)
|
181 |
-
|
182 |
-
|
183 |
-
box_arrays, box_shape, box_density, box_thickness, = list(zip(*boxes))[0], list(zip(*boxes))[1], list(zip(*boxes))[2], list(zip(*boxes))[3]
|
184 |
-
|
185 |
-
# indices_1 = [i for i in range(len(boxes)) if boxes[1][i] == str(base_shapes[0]) and boxes[2][i] == density[0] and boxes[3][i] == desired_thickness]
|
186 |
-
indices_1 = [i for i in range(len(box_arrays)) if box_shape[i] == desired_label and box_density[i] == desired_density and box_thickness[i] == desired_thickness]
|
187 |
-
print(indices_1)
|
188 |
-
# indices_1 = random.randint(0, len(box_arrays))
|
189 |
-
|
190 |
-
|
191 |
-
# plt.imshow(box_arrays[indices_1])
|
192 |
-
plt.imshow(box_arrays[indices_1[0]])
|
193 |
-
plt.show()
|
194 |
-
'''
|
195 |
-
|
196 |
-
'''trainer.push_to_hub()''' # Need to figure out how to push the model to the hub
|
|
|
69 |
# plt.colorbar(cax=cax, shrink=0.1)
|
70 |
st.pyplot(plt.figure(2))
|
71 |
|
|
|
|
|
72 |
########################################################################################################################
|
73 |
+
# Output Entire Dataset
|
74 |
+
st.write("Click 'Generate Dataset' to generate the dataset based on the conditions set previously:")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
if st.button('Generate Dataset'): # Generate the samples
|
76 |
boxes = make_boxes(image_size, densities)
|
77 |
box_arrays, box_density, basic_box_thickness, forward_slash_box_thickness, back_slash_box_thickness,hot_dog_box_thickness, hamburger_box_thickness\
|
|
|
83 |
# Rename the columns to the desired outputs
|
84 |
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"})
|
85 |
|
86 |
+
csv = dataframe.to_csv()
|
87 |
+
st.write("Here is what the generated data looks like (double click on the 'Array' cells to view the full array):")
|
88 |
+
st.write(dataframe) # Display the data generated
|
89 |
+
st.write("Click 'Download' to download a CSV file of the dataset:")
|
90 |
st.download_button("Download Dataset", csv, file_name='2D_Lattice.csv')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|