Commit
·
cf60c45
1
Parent(s):
07b21c4
Start testing streamlit implementation
Browse files
Data_Generation/Dataset_Generation_Functions.py
CHANGED
@@ -16,29 +16,10 @@ def make_boxes(image_size, densities):
|
|
16 |
"""
|
17 |
:param image_size: [int] - the pixel height and width of the generated arrays
|
18 |
:param densities: [list] - of the values of each of the active pixels in each shape
|
19 |
-
:
|
20 |
-
:return: [list[tuple]] - [Array, Density, Thickness, Shape]
|
21 |
"""
|
22 |
|
23 |
matrix = []
|
24 |
-
#
|
25 |
-
# for function in shapes: # Adds different types of shapes
|
26 |
-
#
|
27 |
-
# # Adds different density values
|
28 |
-
# for i in range(len(densities)):
|
29 |
-
# # Loops through the possible thickness values
|
30 |
-
# for j in range(image_size): # Adds additional Pixels
|
31 |
-
# thickness = j
|
32 |
-
# Array = (function(thickness, densities[i], image_size))
|
33 |
-
#
|
34 |
-
# # Checks if there are any 0's left in the array to append
|
35 |
-
# if (np.where((Array == float(0)))[0] > 0).any():
|
36 |
-
# the_tuple = (Array, str(function.__name__), densities[i], thickness)
|
37 |
-
# matrix.append(the_tuple)
|
38 |
-
#
|
39 |
-
# # Prevents solids shapes from being appended to the array
|
40 |
-
# else:
|
41 |
-
# break
|
42 |
|
43 |
# Establish the maximum thickness for each type of strut
|
44 |
max_vert = int(np.ceil(1 / 2 * image_size) - 2)
|
@@ -56,7 +37,7 @@ def make_boxes(image_size, densities):
|
|
56 |
for k in range(0, max_vert):
|
57 |
hamburger_box_thickness = k
|
58 |
array_2 = hamburger_array(image_size, hamburger_box_thickness) + array_1
|
59 |
-
array_2 =np.array(array_2 > 0, dtype=int) # Keep all values 0/1
|
60 |
if np.unique([array_2]).all() > 0:
|
61 |
break
|
62 |
|
@@ -85,119 +66,8 @@ def make_boxes(image_size, densities):
|
|
85 |
hot_dog_box_thickness, hamburger_box_thickness)
|
86 |
matrix.append(the_tuple)
|
87 |
|
88 |
-
# matrix = []
|
89 |
-
# base_shapes = []
|
90 |
-
#
|
91 |
-
#
|
92 |
-
#
|
93 |
-
#
|
94 |
-
#
|
95 |
-
# density_1 = []
|
96 |
-
# for function in shapes: # Create an array of the base shapes
|
97 |
-
# thickness = 0
|
98 |
-
# Array = function(thickness, 1, image_size)
|
99 |
-
# # density_1_tuple = np.array([Array, str(function.__name__), 1, thickness]) # Array, Shape, Density, Thickness
|
100 |
-
# # base_shapes.append(density_1_tuple)
|
101 |
-
#
|
102 |
-
# density_1 = np.append(density_1,(np.array([Array, str(function.__name__), 1, thickness])), axis=1) # Array, Shape, Density, Thickness
|
103 |
-
# # Add one to the thickness of the previous array
|
104 |
-
# # for j in range(image_size):
|
105 |
-
# while (np.where((Array == float(0)))[0] > 0).any():
|
106 |
-
# # Checks if there are any 0's left in the array to append
|
107 |
-
# # if (np.where((Array == float(0)))[0] > 0).any():
|
108 |
-
# # density_1.append(density_1_tuple, axis=0)
|
109 |
-
# thickness += 1
|
110 |
-
# if np.shape(density_1) == (4,):
|
111 |
-
# Array = add_pixels(density_1[0], 1) # will add 1 pixel to each previous array, rather than adding multiple and having to loop
|
112 |
-
#
|
113 |
-
# else:
|
114 |
-
# print(np.shape(density_1))
|
115 |
-
# print(density_1[-1][0])
|
116 |
-
# Array = add_pixels(density_1[-1][0], 1)
|
117 |
-
# # print(np.shape(Array))
|
118 |
-
# density_1_tuple = np.array([Array, str(function.__name__), 1, thickness])
|
119 |
-
# # else: # Prevents solids shapes from being appended to the array
|
120 |
-
# # break
|
121 |
-
# density_1 = np.vstack((density_1, density_1_tuple))
|
122 |
-
#
|
123 |
-
# matrix = []
|
124 |
-
# # print(np.shape(density_1[0]))
|
125 |
-
# # print(density_1[:][0])
|
126 |
-
# for i in range(len(densities)):
|
127 |
-
# some = np.multiply(density_1[:][0],densities[i]) #,density_1[:1])
|
128 |
-
# # print(np.shape(some))
|
129 |
-
# matrix.append(tuple(some))
|
130 |
-
#
|
131 |
-
#
|
132 |
-
# # # Adds different density values
|
133 |
-
# # for i in range(len(densities)):
|
134 |
-
# # # Loops through the possible thickness values
|
135 |
-
# # for j in range(image_size): # Adds additional Pixels
|
136 |
-
# # thickness = j
|
137 |
-
# # Array = (function(thickness, densities[i], image_size))
|
138 |
-
# #
|
139 |
-
# # # Checks if there are any 0's left in the array to append
|
140 |
-
# # if (np.where((Array == float(0)))[0] > 0).any():
|
141 |
-
# # the_tuple = (Array, str(function.__name__), densities[i], thickness)
|
142 |
-
# # matrix.append(the_tuple)
|
143 |
-
# #
|
144 |
-
# # # Prevents solids shapes from being appended to the array
|
145 |
-
# # else:
|
146 |
-
# # break
|
147 |
return matrix
|
148 |
|
149 |
|
150 |
########################################################################################################################
|
151 |
-
|
152 |
-
# image_size = 9
|
153 |
-
# densities = [1]
|
154 |
-
# shapes = [basic_box, diagonal_box_split, horizontal_vertical_box_split, back_slash_box, forward_slash_box,
|
155 |
-
# back_slash_plus_box, forward_slash_plus_box, hot_dog_box, hamburger_box, x_hamburger_box,
|
156 |
-
# x_hot_dog_box, x_plus_box]
|
157 |
-
#
|
158 |
-
# boxes = make_boxes(image_size, densities, shapes)
|
159 |
-
#
|
160 |
-
# # print(np.shape(boxes))
|
161 |
-
# desired_label = 'basic_box'
|
162 |
-
# desired_density = 1
|
163 |
-
# desired_thickness = 0
|
164 |
-
#
|
165 |
-
# box_arrays, box_shape, box_density, box_thickness, = list(zip(*boxes))[0], list(zip(*boxes))[1], list(zip(*boxes))[2], list(zip(*boxes))[3]
|
166 |
-
# # print(np.shape(box_arrays))
|
167 |
-
# # print(np.shape(box_shape))
|
168 |
-
# # print(np.shape(box_density))
|
169 |
-
#
|
170 |
-
# indices = [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]
|
171 |
-
# plt.imshow(box_arrays[indices[0]])
|
172 |
-
# plt.show()
|
173 |
-
########################################################################################################################
|
174 |
-
# Testing
|
175 |
-
image_size = 9
|
176 |
-
densities = [1]
|
177 |
-
|
178 |
-
boxes = make_boxes(image_size, densities)
|
179 |
-
|
180 |
-
desired_density = 1
|
181 |
-
# desired_thickness = 0
|
182 |
-
|
183 |
-
desired_basic_box_thickness =1
|
184 |
-
desired_forward_slash_box_thickness=2
|
185 |
-
desired_back_slash_box_thickness=0
|
186 |
-
desired_hot_dog_box_thickness=0
|
187 |
-
desired_hamburger_box_thickness=0
|
188 |
-
|
189 |
-
|
190 |
-
box_arrays, box_density, basic_box_thickness, forward_slash_box_thickness, back_slash_box_thickness,hot_dog_box_thickness, hamburger_box_thickness\
|
191 |
-
= 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]
|
192 |
-
# print(np.shape(box_arrays))
|
193 |
-
# print(np.shape(box_shape))
|
194 |
-
# print(np.shape(box_density))
|
195 |
-
|
196 |
-
indices = [i for i in range(len(box_arrays)) if box_density[i] == desired_density
|
197 |
-
and basic_box_thickness[i] == desired_basic_box_thickness
|
198 |
-
and forward_slash_box_thickness[i] == desired_forward_slash_box_thickness
|
199 |
-
and back_slash_box_thickness[i] == desired_back_slash_box_thickness
|
200 |
-
and hot_dog_box_thickness[i] == desired_hot_dog_box_thickness
|
201 |
-
and hamburger_box_thickness[i] == desired_hamburger_box_thickness]
|
202 |
-
plt.imshow(box_arrays[indices[0]])
|
203 |
-
plt.show()
|
|
|
16 |
"""
|
17 |
:param image_size: [int] - the pixel height and width of the generated arrays
|
18 |
:param densities: [list] - of the values of each of the active pixels in each shape
|
19 |
+
:return: [list[tuple]] - [Array, Density, Thickness of each strut type]
|
|
|
20 |
"""
|
21 |
|
22 |
matrix = []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
# Establish the maximum thickness for each type of strut
|
25 |
max_vert = int(np.ceil(1 / 2 * image_size) - 2)
|
|
|
37 |
for k in range(0, max_vert):
|
38 |
hamburger_box_thickness = k
|
39 |
array_2 = hamburger_array(image_size, hamburger_box_thickness) + array_1
|
40 |
+
array_2 = np.array(array_2 > 0, dtype=int) # Keep all values 0/1
|
41 |
if np.unique([array_2]).all() > 0:
|
42 |
break
|
43 |
|
|
|
66 |
hot_dog_box_thickness, hamburger_box_thickness)
|
67 |
matrix.append(the_tuple)
|
68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
return matrix
|
70 |
|
71 |
|
72 |
########################################################################################################################
|
73 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Data_Generation/Shape_Generation_Functions.py
DELETED
@@ -1,143 +0,0 @@
|
|
1 |
-
from Data_Generation.Piecewise_Box_Functions import back_slash_array, basic_box_array, forward_slash_array, \
|
2 |
-
hot_dog_array, hamburger_array, update_array, add_pixels
|
3 |
-
|
4 |
-
|
5 |
-
########################################################################################################################
|
6 |
-
# Series of Basic Box Shapes
|
7 |
-
|
8 |
-
def basic_box(additional_pixels, density, image_size):
|
9 |
-
A = basic_box_array(image_size) # Creates the outside edges of the box
|
10 |
-
# Increase the thickness of each part of the box
|
11 |
-
A = add_pixels(A, additional_pixels)
|
12 |
-
return A*density
|
13 |
-
|
14 |
-
|
15 |
-
def horizontal_vertical_box_split(additional_pixels, density, image_size):
|
16 |
-
A = basic_box_array(image_size) # Creates the outside edges of the box
|
17 |
-
# Place pixels across the horizontal and vertical axes to split the box
|
18 |
-
A = update_array(A, hot_dog_array(image_size), image_size)
|
19 |
-
A = update_array(A, hamburger_array(image_size), image_size)
|
20 |
-
# Increase the thickness of each part of the box
|
21 |
-
A = add_pixels(A, additional_pixels)
|
22 |
-
return A*density
|
23 |
-
|
24 |
-
|
25 |
-
def diagonal_box_split(additional_pixels, density, image_size):
|
26 |
-
A = basic_box_array(image_size) # Creates the outside edges of the box
|
27 |
-
|
28 |
-
# Add pixels along the diagonals of the box
|
29 |
-
A = update_array(A, back_slash_array(image_size), image_size)
|
30 |
-
A = update_array(A, forward_slash_array(image_size), image_size)
|
31 |
-
|
32 |
-
# Adds pixels to the thickness of each component of the box
|
33 |
-
# Increase the thickness of each part of the box
|
34 |
-
A = add_pixels(A, additional_pixels)
|
35 |
-
return A*density
|
36 |
-
|
37 |
-
|
38 |
-
def back_slash_box(additional_pixels, density, image_size):
|
39 |
-
A = basic_box_array(image_size) # Initializes A matrix with 0 values
|
40 |
-
A = update_array(A, back_slash_array(image_size), image_size)
|
41 |
-
A = add_pixels(A, additional_pixels)
|
42 |
-
return A * density
|
43 |
-
|
44 |
-
|
45 |
-
def forward_slash_box(additional_pixels, density, image_size):
|
46 |
-
A = basic_box_array(image_size) # Initializes A matrix with 0 values
|
47 |
-
A = update_array(A, forward_slash_array(image_size), image_size)
|
48 |
-
A = add_pixels(A, additional_pixels)
|
49 |
-
return A * density
|
50 |
-
|
51 |
-
|
52 |
-
def hot_dog_box(additional_pixels, density, image_size):
|
53 |
-
A = basic_box_array(image_size) # Initializes A matrix with 0 values
|
54 |
-
A = update_array(A, hot_dog_array(image_size), image_size)
|
55 |
-
A = add_pixels(A, additional_pixels)
|
56 |
-
return A * density
|
57 |
-
|
58 |
-
|
59 |
-
def hamburger_box(additional_pixels, density, image_size):
|
60 |
-
A = basic_box_array(image_size) # Initializes A matrix with 0 values
|
61 |
-
A = update_array(A, hamburger_array(image_size), image_size)
|
62 |
-
A = add_pixels(A, additional_pixels)
|
63 |
-
return A * density
|
64 |
-
|
65 |
-
|
66 |
-
def x_plus_box(additional_pixels, density, image_size):
|
67 |
-
A = basic_box_array(image_size) # Initializes A matrix with 0 values
|
68 |
-
A = update_array(A, hot_dog_array(image_size), image_size)
|
69 |
-
A = update_array(A, hamburger_array(image_size), image_size)
|
70 |
-
A = update_array(A, forward_slash_array(image_size), image_size)
|
71 |
-
A = update_array(A, back_slash_array(image_size), image_size)
|
72 |
-
A = add_pixels(A, additional_pixels)
|
73 |
-
return A * density
|
74 |
-
|
75 |
-
|
76 |
-
def forward_slash_plus_box(additional_pixels, density, image_size):
|
77 |
-
A = basic_box_array(image_size) # Initializes A matrix with 0 values
|
78 |
-
A = update_array(A, hot_dog_array(image_size), image_size)
|
79 |
-
A = update_array(A, hamburger_array(image_size), image_size)
|
80 |
-
A = update_array(A, forward_slash_array(image_size), image_size)
|
81 |
-
# A = update_array(A, back_slash_array(image_size), image_size)
|
82 |
-
A = add_pixels(A, additional_pixels)
|
83 |
-
return A * density
|
84 |
-
|
85 |
-
|
86 |
-
def back_slash_plus_box(additional_pixels, density, image_size):
|
87 |
-
A = basic_box_array(image_size) # Initializes A matrix with 0 values
|
88 |
-
A = update_array(A, hot_dog_array(image_size), image_size)
|
89 |
-
A = update_array(A, hamburger_array(image_size), image_size)
|
90 |
-
A = update_array(A, back_slash_array(image_size), image_size)
|
91 |
-
A = add_pixels(A, additional_pixels)
|
92 |
-
return A * density
|
93 |
-
|
94 |
-
|
95 |
-
def x_hot_dog_box(additional_pixels, density, image_size):
|
96 |
-
A = basic_box_array(image_size) # Initializes A matrix with 0 values
|
97 |
-
A = update_array(A, hot_dog_array(image_size), image_size)
|
98 |
-
A = update_array(A, forward_slash_array(image_size), image_size)
|
99 |
-
A = update_array(A, back_slash_array(image_size), image_size)
|
100 |
-
A = add_pixels(A, additional_pixels)
|
101 |
-
return A * density
|
102 |
-
|
103 |
-
|
104 |
-
def x_hamburger_box(additional_pixels, density, image_size):
|
105 |
-
A = basic_box_array(image_size) # Initializes A matrix with 0 values
|
106 |
-
A = update_array(A, hamburger_array(image_size), image_size)
|
107 |
-
A = update_array(A, forward_slash_array(image_size), image_size)
|
108 |
-
A = update_array(A, back_slash_array(image_size), image_size)
|
109 |
-
A = add_pixels(A, additional_pixels)
|
110 |
-
return A * density
|
111 |
-
|
112 |
-
|
113 |
-
# New Unit Cells
|
114 |
-
def forward_slash_hot_dog_box(additional_pixels, density, image_size):
|
115 |
-
A = basic_box_array(image_size) # Initializes A matrix with 0 values
|
116 |
-
A = update_array(A, hot_dog_array(image_size), image_size)
|
117 |
-
A = update_array(A, forward_slash_array(image_size), image_size)
|
118 |
-
A = add_pixels(A, additional_pixels)
|
119 |
-
return A * density
|
120 |
-
|
121 |
-
|
122 |
-
def forward_slash_hamburger_box(additional_pixels, density, image_size):
|
123 |
-
A = basic_box_array(image_size) # Initializes A matrix with 0 values
|
124 |
-
A = update_array(A, hamburger_array(image_size), image_size)
|
125 |
-
A = update_array(A, forward_slash_array(image_size), image_size)
|
126 |
-
A = add_pixels(A, additional_pixels)
|
127 |
-
return A * density
|
128 |
-
|
129 |
-
|
130 |
-
def back_slash_hamburger_box(additional_pixels, density, image_size):
|
131 |
-
A = basic_box_array(image_size) # Initializes A matrix with 0 values
|
132 |
-
A = update_array(A, hamburger_array(image_size), image_size)
|
133 |
-
A = update_array(A, back_slash_array(image_size), image_size)
|
134 |
-
A = add_pixels(A, additional_pixels)
|
135 |
-
return A * density
|
136 |
-
|
137 |
-
|
138 |
-
def back_slash_hot_dog_box(additional_pixels, density, image_size):
|
139 |
-
A = basic_box_array(image_size) # Initializes A matrix with 0 values
|
140 |
-
A = update_array(A, hot_dog_array(image_size), image_size)
|
141 |
-
A = update_array(A, back_slash_array(image_size), image_size)
|
142 |
-
A = add_pixels(A, additional_pixels)
|
143 |
-
return A * density
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2D_Data_Generator_Model.py → app.py
RENAMED
@@ -5,23 +5,60 @@ import pandas as pd
|
|
5 |
from datasets import load_dataset, ClassLabel, Sequence
|
6 |
import json
|
7 |
import numpy
|
8 |
-
from transformers import AutoImageProcessor
|
9 |
-
from torchvision.transforms import RandomResizedCrop, Compose, Normalize, ToTensor
|
10 |
-
from transformers import DefaultDataCollator
|
11 |
-
# import evaluate
|
12 |
-
import numpy as np
|
13 |
-
from transformers import AutoModelForImageClassification, TrainingArguments, Trainer
|
14 |
-
from PIL import Image
|
15 |
-
from matplotlib import cm
|
16 |
-
from Data_Generation.Shape_Generation_Functions import basic_box, diagonal_box_split, horizontal_vertical_box_split, \
|
17 |
-
back_slash_box, forward_slash_box, back_slash_plus_box, forward_slash_plus_box, hot_dog_box, hamburger_box, \
|
18 |
-
x_hamburger_box, x_hot_dog_box, x_plus_box
|
19 |
-
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
|
|
22 |
from Data_Generation.Dataset_Generation_Functions import make_boxes
|
23 |
|
24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
# food = load_dataset("cmudrc/2d-lattices", split="train[:15]") # Loads the training data samples
|
27 |
food = load_dataset("cmudrc/2d-lattices", split="train+test") # Loads all of the data, for use after training
|
@@ -79,6 +116,6 @@ print(indices_1)
|
|
79 |
# plt.imshow(box_arrays[indices_1])
|
80 |
plt.imshow(box_arrays[indices_1[0]])
|
81 |
plt.show()
|
82 |
-
|
83 |
|
84 |
'''trainer.push_to_hub()''' # Need to figure out how to push the model to the hub
|
|
|
5 |
from datasets import load_dataset, ClassLabel, Sequence
|
6 |
import json
|
7 |
import numpy
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
+
# from transformers import AutoImageProcessor
|
10 |
+
# from torchvision.transforms import RandomResizedCrop, Compose, Normalize, ToTensor
|
11 |
+
# from transformers import DefaultDataCollator
|
12 |
+
# # import evaluate
|
13 |
+
# import numpy as np
|
14 |
+
# from transformers import AutoModelForImageClassification, TrainingArguments, Trainer
|
15 |
+
# from PIL import Image
|
16 |
+
# from matplotlib import cm
|
17 |
|
18 |
+
import streamlit as st
|
19 |
from Data_Generation.Dataset_Generation_Functions import make_boxes
|
20 |
|
21 |
|
22 |
+
x = st.slider('Select a value')
|
23 |
+
st.write(x, 'squared is', x * x)
|
24 |
+
|
25 |
+
|
26 |
+
'''
|
27 |
+
# Testing
|
28 |
+
image_size = 100
|
29 |
+
densities = [1]
|
30 |
+
|
31 |
+
boxes = make_boxes(image_size, densities)
|
32 |
+
|
33 |
+
desired_density = 1
|
34 |
+
# desired_thickness = 0
|
35 |
+
|
36 |
+
desired_basic_box_thickness = 1
|
37 |
+
desired_forward_slash_box_thickness = 2
|
38 |
+
desired_back_slash_box_thickness = 0
|
39 |
+
desired_hot_dog_box_thickness = 0
|
40 |
+
desired_hamburger_box_thickness = 0
|
41 |
+
|
42 |
+
|
43 |
+
box_arrays, box_density, basic_box_thickness, forward_slash_box_thickness, back_slash_box_thickness,hot_dog_box_thickness, hamburger_box_thickness\
|
44 |
+
= 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]
|
45 |
+
# print(np.shape(box_arrays))
|
46 |
+
# print(np.shape(box_shape))
|
47 |
+
# print(np.shape(box_density))
|
48 |
+
|
49 |
+
indices = [i for i in range(len(box_arrays)) if box_density[i] == desired_density
|
50 |
+
and basic_box_thickness[i] == desired_basic_box_thickness
|
51 |
+
and forward_slash_box_thickness[i] == desired_forward_slash_box_thickness
|
52 |
+
and back_slash_box_thickness[i] == desired_back_slash_box_thickness
|
53 |
+
and hot_dog_box_thickness[i] == desired_hot_dog_box_thickness
|
54 |
+
and hamburger_box_thickness[i] == desired_hamburger_box_thickness]
|
55 |
+
plt.imshow(box_arrays[indices[0]], cmap='gray', vmin=0, vmax=1)
|
56 |
+
plt.show()
|
57 |
+
'''
|
58 |
+
|
59 |
+
|
60 |
+
|
61 |
+
'''
|
62 |
|
63 |
# food = load_dataset("cmudrc/2d-lattices", split="train[:15]") # Loads the training data samples
|
64 |
food = load_dataset("cmudrc/2d-lattices", split="train+test") # Loads all of the data, for use after training
|
|
|
116 |
# plt.imshow(box_arrays[indices_1])
|
117 |
plt.imshow(box_arrays[indices_1[0]])
|
118 |
plt.show()
|
119 |
+
'''
|
120 |
|
121 |
'''trainer.push_to_hub()''' # Need to figure out how to push the model to the hub
|