Skip to content

Commit a338cc1

Browse files
committedMay 30, 2021
Bootstrap method working!
1 parent 116835b commit a338cc1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+6511
-1541
lines changed
 

‎.DS_Store

0 Bytes
Binary file not shown.

‎Core_Functions/.ipynb_checkpoints/generate_image_set-checkpoint.py

+97-1
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,100 @@ def get_right_min_image_combinations(number_image_pairs_selected, image_data, im
120120
image_combination_data = np.array(image_combination_data)
121121
image_combination_labels = np.array(image_combination_labels)
122122

123-
return image_combination_data, image_combination_labels
123+
return image_combination_data, image_combination_labels
124+
125+
126+
# Randomly select a defined number of image paires from a given dataset
127+
# Always store the minimum image on the left
128+
def get_left_min_image_combinations_separate(number_image_pairs_selected, image_data, image_labels):
129+
130+
num_images_total = len(image_labels)
131+
132+
image_combination_data_A = []
133+
image_combination_data_B = []
134+
135+
image_combination_labels = []
136+
137+
for i in range(number_image_pairs_selected):
138+
139+
# Draw two image indices from a uniform random distribution
140+
random_index_A = random.randint(0, num_images_total-1)
141+
random_index_B = random.randint(0, num_images_total-1)
142+
143+
# Randomly choose two images from the dataset
144+
image_A = image_data[random_index_A]
145+
image_B = image_data[random_index_B]
146+
147+
# Find the minimum between the two labels
148+
label_A = image_labels[random_index_A]
149+
label_B = image_labels[random_index_B]
150+
minimum_label = min(label_A, label_B)
151+
152+
if label_A < label_B:
153+
# Here we want to exclude the images where they are the same on both sides
154+
image_combination_data_A.append(image_A)
155+
image_combination_data_B.append(image_B)
156+
157+
image_combination_labels.append(minimum_label)
158+
elif label_A > label_B:
159+
# Here we want to exclude the images where they are the same on both sides
160+
image_combination_data_A.append(image_B)
161+
image_combination_data_B.append(image_A)
162+
image_combination_labels.append(minimum_label)
163+
164+
# Convert image data and labels lists to numpy arrays
165+
image_combination_data_A = np.array(image_combination_data_A)
166+
image_combination_data_B = np.array(image_combination_data_B)
167+
168+
image_combination_labels = np.array(image_combination_labels)
169+
170+
return image_combination_data_A, image_combination_data_B, image_combination_labels
171+
172+
173+
# Randomly select a defined number of image paires from a given dataset
174+
# Always store the minimum image on the left
175+
def get_right_min_image_combinations_separate(number_image_pairs_selected, image_data, image_labels):
176+
177+
num_images_total = len(image_labels)
178+
179+
image_combination_data_A = []
180+
image_combination_data_B = []
181+
182+
image_combination_labels = []
183+
184+
for i in range(number_image_pairs_selected):
185+
186+
# Draw two image indices from a uniform random distribution
187+
random_index_A = random.randint(0, num_images_total-1)
188+
random_index_B = random.randint(0, num_images_total-1)
189+
190+
# Randomly choose two images from the dataset
191+
image_A = image_data[random_index_A]
192+
image_B = image_data[random_index_B]
193+
194+
# Find the minimum between the two labels
195+
label_A = image_labels[random_index_A]
196+
label_B = image_labels[random_index_B]
197+
minimum_label = min(label_A, label_B)
198+
199+
if label_A > label_B:
200+
# Here we want to exclude the images where they are the same on both sides
201+
image_combination_data_A.append(image_A)
202+
image_combination_data_B.append(image_B)
203+
204+
image_combination_labels.append(minimum_label)
205+
206+
elif label_A < label_B:
207+
# Here we want to exclude the images where they are the same on both sides
208+
image_combination_data_A.append(image_B)
209+
image_combination_data_B.append(image_A)
210+
211+
image_combination_labels.append(minimum_label)
212+
213+
# Convert image data and labels lists to numpy arrays
214+
image_combination_data_A = np.array(image_combination_data_A)
215+
image_combination_data_B = np.array(image_combination_data_B)
216+
217+
image_combination_labels = np.array(image_combination_labels)
218+
219+
return image_combination_data_A, image_combination_data_B, image_combination_labels

0 commit comments

Comments
 (0)
Please sign in to comment.