Answered step by step
Verified Expert Solution
Question
1 Approved Answer
This is meant to create a classifier among images of cats and dogs, how do I fix this error I got so far, and what
This is meant to create a classifier among images of cats and dogs, how do I fix this error I got so far, and what is the code to fix it
# working with, mainly resizing, images # dealing with arrays In [1]: import cv2 import numpy as np import os from random import shuffle # mixing up or currently ordered data that might lead our network astray in training. from tgdm import tqdm dealing with directories a nice pretty percentage bar for tasks. Thanks to viewer Daniel BA1/4hler for this suggest "X:/Kaggle "X: /Kaggle-Data/dogs-vs-cats/test/test' 50 In [2]: Data/dogs_vs_cats/train/train' TRAIN-DIR TEST-DIR- IMGSIZE = LRle-3 = - MODEL_NAMEdogsvscats-- .model'. format (LR, '2conv-basic' Just so we remember which saved model is which, sizes In [3]: def label_img (img): word-label - ing. split('.') [-3] conversion to one-hot array [cat , dog] if word label cat': return [1,0] elif word label dog: return [0,1] much cat, no dog no cat, very doggo In 41 def createtrain data(): training_data [ for img in tqdm(os.listdir(TRAIN DIR)): label - label_img(img) pathos.path.join (TRAIN_DIR,img) img = cv2.imread (path, cv2.1MREAD GRAYSCALE) img - cv2.resize(img, (IMG_SIZE,IMG_SIZE)) training data.append([np.array(img),np.array(label)]) shuffle(training data) np.save('train_data.npy, training data) return training data In [8]: def processtest_data(): testing_data [ for ing in tqdm(os.listdir(TEST_DIR)): path = os.path.join (TEST-DIR, mg) img-num = img . split ( ' ') [ 0 ] img - cv2.imread (path, cv2.IMREAD_GRAYSCALE) img - cv2.resize(img, (IMG_SIZE, IMG_SIZE)) testing_data.append (np.array(img), img num] ) shuffle(testing_data) np. save ('test_data.npy, testing data) return testing_data In [9]: train_data-createtrain_data() FileNotFoundError kipython-input-9-40719067ea74> inStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started