This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hueradians = np.deg2rad(hue_16bit) | |
cos_hueradians = np.cos(hueradians) | |
sin_hueradians = np.sin(hueradians) | |
# BEMD in sin value of hue channel | |
bemd2 = BEMD() | |
imfs_sin_hue = bemd2.bemd(sin_hueradians, max_imf=2) | |
# BEMD in cos value of hue channel | |
bemd = BEMD() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bgrInputImage = cv2.imread(img_path) | |
bgrInputImage = cv2.resize(bgrInputImage,(224,224)) | |
rgb_resized_img = cv2.cvtColor(bgrInputImage,cv2.COLOR_BGR2RGB) | |
hsvInputImage_Full = cv2.cvtColor(rgb_resized_img.astype(np.float32), cv2.COLOR_RGB2HSV_FULL) | |
hue_full, sat_full, val_full = cv2.split(hsvInputImage_Full) | |
hue_16bit = np.array(hue_full,dtype=np.uint16) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for e in coordinates: | |
show_ship(e[0][0], e[0][1], e[1][0][1]) | |
picture_tensor = picture_tensor.transpose(1,2,0) | |
picture_tensor.shape | |
plt.figure(1, figsize = (15, 30)) | |
plt.subplot(3,1,1) | |
plt.imshow(picture_tensor) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
step = 10; coordinates = [] | |
for y in range(int((height-(80-step))/step)): | |
for x in range(int((width-(80-step))/step) ): | |
area = cutting(x*step, y*step) | |
result = model.predict(area) | |
if result[0][1] > 0.90 and not_near(x*step,y*step, 88, coordinates): | |
coordinates.append([[x*step, y*step], result]) | |
print(result) | |
plt.imshow(area[0]) | |
plt.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def cutting(x, y): | |
area_study = np.arange(3*80*80).reshape(3, 80, 80) | |
for i in range(80): | |
for j in range(80): | |
area_study[0][i][j] = picture_tensor[0][y+i][x+j] | |
area_study[1][i][j] = picture_tensor[1][y+i][x+j] | |
area_study[2][i][j] = picture_tensor[2][y+i][x+j] | |
area_study = area_study.reshape([-1, 3, 80, 80]) | |
area_study = area_study.transpose([0,2,3,1]) | |
area_study = area_study / 255 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
image = Image.open('./ships-in-satellite-imagery/scenes/scenes/sfbay_1.png') | |
pix = image.load() | |
n_spectrum = 3 | |
width = image.size[0] | |
height = image.size[1] | |
# creat vector | |
picture_vector = [] | |
for chanel in range(n_spectrum): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# optimization setup | |
sgd = SGD(lr=0.01, momentum=0.9, nesterov=True) | |
model.compile( | |
loss='categorical_crossentropy', | |
optimizer=sgd, | |
metrics=['accuracy']) | |
# training | |
model.fit( | |
X_train, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
model = Sequential() | |
model.add(Conv2D(32, (3, 3), padding='same', input_shape=(80, 80, 3), activation='relu')) | |
model.add(MaxPooling2D(pool_size=(2, 2))) #40x40 | |
model.add(Dropout(0.25)) | |
model.add(Conv2D(32, (3, 3), padding='same', activation='relu')) | |
model.add(MaxPooling2D(pool_size=(2, 2))) #20x20 | |
model.add(Dropout(0.25)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
physical_devices = tf.config.experimental.list_physical_devices('GPU') | |
for physical_device in physical_devices: | |
tf.config.experimental.set_memory_growth(physical_device, True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# output encoding | |
y = tensorflow.keras.utils.to_categorical(output_data, 2) | |
# shuffle all indexes | |
indexes = np.arange(2800) | |
np.random.shuffle(indexes) | |
X_train = X[indexes].transpose([0,2,3,1]) | |
y_train = y[indexes] |