text_plain_output_2.png text_plain_output_1.png
import numpy as np # linear algebra

import os

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

base_dir = '/kaggle/input/coast-data'
coasts = pd.read_csv(os.path.join(base_dir, 'CoastTrain_imagery_details.csv'))
coasts.shape

coasts.name.value_counts()

coasts.iloc[0]

class_set = set()
class_index = []
coasts_df = coasts
for i in range(coasts.shape[0]):
    if coasts.loc[i, 'name'].startswith('Ortho'):
        class_index.append(i)
    '\n    if (coasts.loc[i, "name"].startswith("Ortho") or coasts.loc[i, "name"].startswith("NAIP")) and not coasts.loc[i, "name"].startswith("Orthophoto_8_001"):# or coasts.loc[i, "name"].startswith("Quad"):\n        class_index.append(i)\n    '
coasts_df = coasts.iloc[class_index]
coasts = coasts_df
'\ncoasts.set_index(range(coasts.shape[0]))\nprint(coasts_df.shape)\ncoasts_df["classes_array"].value_counts()\n'

coasts.shape

first_coast = coasts.iloc[3]
directory = first_coast['name'].split('.')[0]
filename = first_coast['images'].split('/')[-1].split('.')[-2]
data = np.load(os.path.join(base_dir, directory, filename + '.npz'))

lst = data.files

print(data['label'].shape)