Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribedimage text in transcribedimage text in transcribed

# 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> in Traceback (most recent call last) 1 train datacreate train_data() ipython-input-4-a8c56d5d5e00> in create train_data) 1 def createtrain data(): training-data = [] 3 for img in tqdm(os.listdir (TRAIN DIR)): labellabel_img img) path = os.path. join ( TRAIN-DIR, img) 5 FileNotFoundError: [Errno 2] No such file or directory: X:/Kaggle-Data/dogs-vs-cats/train/train

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Antipatterns Avoiding The Pitfalls Of Database Programming

Authors: Bill Karwin

1st Edition

1680508989, 978-1680508987

More Books

Students also viewed these Databases questions