Skip to content

Instantly share code, notes, and snippets.

@trongan93
Created June 12, 2020 08:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trongan93/908e0ddc1107eca59e39674e3851e710 to your computer and use it in GitHub Desktop.
Save trongan93/908e0ddc1107eca59e39674e3851e710 to your computer and use it in GitHub Desktop.
ship_detection_read_dataset
# download dataset from json object
f = open(r'./ships-in-satellite-imagery/shipsnet.json') #download at http://vipnas.buitrongan.com:5000/sharing/Gd1gOIi9A
dataset = json.load(f)
f.close()
input_data = np.array(dataset['data']).astype('uint8')
output_data = np.array(dataset['labels']).astype('uint8')
input_data.shape
n_spectrum = 3 # color chanel (RGB)
weight = 80
height = 80
X = input_data.reshape([-1, n_spectrum, weight, height])
X[0].shape
# get one chanel
pic = X[0]
rad_spectrum = pic[0]
green_spectrum = pic[1]
blue_spectum = pic[2]
plt.figure(2, figsize = (5*3, 5*1))
plt.set_cmap('jet')
# show each channel
plt.subplot(1, 3, 1)
plt.imshow(rad_spectrum)
plt.subplot(1, 3, 2)
plt.imshow(green_spectrum)
plt.subplot(1, 3, 3)
plt.imshow(blue_spectum)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment