<jupyter_start><jupyter_text><jupyter_code>from google.colab import drive
drive.mount('/content/gdrive')
from google.colab import drive

drive.mount('/content/gdrive')
root_path = 'gdrive/My Drive/your_project_folder/'
from google.colab import files
files.upload()
!pip install -q kaggle
!mkdir -p ~/.kaggle
!cp kaggle.json ~/.kaggle/
!ls ~/.kaggle
!chmod 600 /root/.kaggle/kaggle.json 
!kaggle competitions download -c Gallivanters -p /content/gdrive/My\ Drive/kaggle/Gallivanters
import os
os.chdir('/content/gdrive/My Drive/kaggle/Gallivanters')  #change dir
# !mkdir train  #create a directory named train/
# !mkdir test  #create a directory named test/
#  !mkdir gallivanters
# !mkdir country
!unzip -q train.zip  #unzip data in train/
!unzip -q test.zip  #unzip data in test/
# !unzip -q gallivanters.zip -d gallivanters/
!unzip -q country.zip 
# !unzip sample_submission.csv.zip
# !unzip train_labels.csv.zip


import keras
from keras.layers import Input, Lambda, Dense, Flatten
from keras.models import Model
import numpy as np
from glob import glob
import matplotlib.pyplot as plt
IMAGE_SIZE = [224, 224]
train_path = '/content/gdrive/My Drive/kaggle/Gallivanters/train'
test_path = '/content/gdrive/My Drive/kaggle/Gallivanters/test'
country_path = '/content/gdrive/My Drive/kaggle/Gallivanters/country'

from keras.preprocessing.image import ImageDataGenerator
train_datagen = ImageDataGenerator(rescale=1./255,shear_range=0.2,zoom_range=0.2,horizontal_flip=True)
test_datagen = ImageDataGenerator(rescale=1./255)
training_set = train_datagen.flow_from_directory('/content/gdrive/My Drive/kaggle/Gallivanters/train',target_size=(244, 244),batch_size=32,class_mode='categorical')
test_set = test_datagen.flow_from_directory('/content/gdrive/My Drive/kaggle/Gallivanters/test',target_size=(244, 244),batch_size=32,class_mode='categorical')
import keras
import pathlib
import imageio
import os
import cv2
from pylab import *
import numpy as np
import matplotlib.pyplot as plt
train_path = '/content/gdrive/My Drive/kaggle/Gallivanters/train'
for category in config:
  path = os.path.join(train_path, category)
  for img in os.listdir(path):
    img_arr=cv2.imread(os.path.join(path,img), cv2.IMREAD_GRAYSCALE)
    # plt_imshow(img_arr, cmap="gray")
    # plt.show()
    break
  break
print(img_arr.shape)
IMG_SIZE = 50
new_arr = cv2.resize(img_arr,(IMG_SIZE,IMG_SIZE))

def create_train_data():
  for category in config:
    path = os.path.join(train_path, category)
    class_num = config.index(category)
    for img in os.listdir(path):
      # try:
      img_arr = cv2.imread(os.path.join(path,img), cv2.IMREAD_GRAYSCALE)
      new_arr = cv2.resize(img_arr,(IMG_SIZE,IMG_SIZE))
      train_data.append([img_arr, class_num])
      # except EXCEPTION as e:
        # pass
      
create_train_data
print(train_data)
import json
config = json.loads(open('/content/gdrive/My Drive/kaggle/Gallivanters/country.json').read())
config<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1169925826028321, 'fraction_numerical': 0.015509103169251517, 'mean_word_length': 5.042769857433808, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '404876', 'license': 'MIT', 'n_tokens_mistral': 1108, 'n_tokens_neox': 1067, 'n_words': 227, 'path': 'first.ipynb', 'repo_name': 'Sweta271097/Gallivanters', 'size': '2966'}