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

df_train = pd.read_csv('/kaggle/input/global-wheat-detection/train.csv')

df_train.shape

df_train.shape[0] / len(df_train['image_id'].unique())

df_train.dtypes

cols_to_be_selected = ['image_id', 'x0', 'y0', 'w', 'h']
df1_train = df_train[cols_to_be_selected]

val_percentage = 0.2
num_val_images = int(len(df1_train['image_id'].unique()) * val_percentage)
num_train_images = len(df1_train['image_id'].unique()) - num_val_images
list_val_imageid = list(df1_train['image_id'].unique())[-1 * num_val_images:]
list_train_imageid = list(df1_train['image_id'].unique())[:num_train_images]

df2_val = df1_train.loc[df1_train['image_id'].isin(list_val_imageid), :]
df2_train = df1_train.loc[df1_train['image_id'].isin(list_train_imageid), :]

train_dir = '/kaggle/input/global-wheat-detection/train'

test_obj = GlobalWheatDetectionDataset(df2_train, train_dir)