Open MLenthousiast opened 7 years ago
Are you sure you made only this change? Because this change should not cause this error. Did you make any changes in utils.py
?
Yes I'm certain, i haven't touched any other file. I double checked it on another pc and got the same problem. But maybe it has something to do with the generated data?
I have the data placed in a dir called data
which contains a csv file driving_log.csv
and another dir called IMG
containing all the *.jpg files. I pass the absolute address of this dir along with the command using the -d
option.
Another way of naming the data columns is by manually adding them as the first column of the driving_log.csv
(Like this). Give this a try and revert model.py
back to original.
Re-cloned and added the headers but still the same error persists..
Copy the data
folder in the project's directory and try again without adding the data argument.
Yeah that is what I did first, but it yields the same error..
Open python console in the project's directory and try reading the images from there. See if the images can be read. Maybe the error is because the images cannot be read.
Hey any luck with this MLenthousiast? I am having the same issue..
Maybe it's because you generated data and shifted the data to another directory. If you do this then you also have to change the image directories in driving_log.csv
.
Ah. Makes sense, thanks! Is there a simple way to do this in the .csv?
Use find and replace all in a text editor like sublime text.
Like this:
We are passing data directory so we have path till data right ,then in the path of images we need only IMG folder...? or do we need the whole path till IMG
def load_image(data_dir, image_file): """ Load RGB images from a file """ return mpimg.imread(os.path.join(data_dir, image_file.strip()))
I had the same trouble as the Original Poster on the 2nd computer I tried this experiment on. (It worked on the first). I found there is something in the random_shadow function of the utils.py file that the 2nd computer didn't like. I was able to comment out line 131 inside the augument function of utils.py to avoid the error. However, this means the training images don't get the random shadow treatment and lose out on that variable when learning.
This is because random_shadow() uses IMAGE_WIDTH and IMAGE_HEIGHT but we haven't cropped the image yet. Add height, width = image.shape[:2] and use those variables instead, just like in random_translate(). Doing this fixed this issue for me.
I was also having this issue. It was due to the below line of code in the random_shadow function in utils.py.
mask[(ym - y1) (x2 - x1) - (y2 - y1) (xm - x1) > 0] = 1
I added the numpy "where" function to this line and everything worked.
mask[np.where((ym - y1) (x2 - x1) - (y2 - y1) (xm - x1) > 0)] = 1
I believe it's due to an update in numpy. Hope this helped.
@IsaacCorley Got the same error, and tried the "where" trick, and it worked. Thank you.
the "where" trick works. Thank you
The random_shadow()
function creates a random shadow for an image of the size (66, 200). The problem is, that we are feeding a non-cropped image (160, 320) into the function at this point.
The "where" trick mentioned above may prevent the error, but the logic when creating the shadow is wrong! When using the "where" trick, a shadow in only the top left part of the image (66, 200) will be created.
The first few lines in random_shadow()
should be changed to:
height, width = image.shape[:2] # (x1, y1) and (x2, y2) forms a line # xm, ym gives all the locations of the image x1, y1 = int(width * np.random.rand()), 0 x2, y2 = int(width * np.random.rand()), height xm, ym = np.mgrid[0:height, 0:width]
This way there will be a random shadow over the whole image (160, 320). The image can be cropped and resized at a later point.
Guys , follow all the steps above till eng-tsmith and if you still happen to have a problem ,then ignore it and proceed to the next step i.e , python drive.py model.h5 . This worked for us. Thank you everyone.
It's true the where trick prevents the error but as explained by eng-tsmith it has unintended consequence. Thank you for pointing it out.
Can't get it to run. Getting errorsTraceback (most recent call last):
File "model.py", line 163, in
File "D:\Docs\Anaconda3\envs\car-behavioral-cloning\lib\site-packages\keras\engine\training.py", line 1481, in fit_generator str(generator_output)) ValueError: output of generator should be a tuple (x, y, sample_weight) or (x, y). Found: None
I am getting the same error after doing all necessary changes.
When I execute the command
python model.py
while thecar-behavioral-cloning
environment (for CPU version) is activated I get the following error:The only thing I changed about the source code is line 29:
data_df = pd.read_csv(os.path.join(args.data_dir, 'driving_log.csv'))
into:data_df = pd.read_csv(os.path.join(args.data_dir, 'driving_log.csv'), names=['center', 'left', 'right', 'steering', 'throttle', 'reverse', 'speed'])
because I had also an issue with loading the data because the columns weren't named.Does anyone know how to fix this issue?