naokishibuya / car-behavioral-cloning

Built and trained a convolutional network for end-to-end driving in a simulator using Tensorflow and Keras
MIT License
230 stars 135 forks source link

TypeError when running model.py #2

Closed 166inter closed 7 years ago

166inter commented 7 years ago

Hello,

I am trying to get the model.py code running -- I already recorded some training data with the simulator and have it saved to desktop (csv file and images folder). I have activated the environment with all the dependencies.

Python couldn't find the log file so I changed the pd.read command as follows: data_df = pd.read_csv('~/Desktop/driving_log.csv') Maybe this causes a problem since I'm not using os.path.join(args.data_dir ?

There was another error and I added a row to the csv file and labeled the respective columns (steering, etc.)

Now I am stuck with this error and haven't figured out how to resolve:

return load_image(data_dir, left), steering_angle + 0.2
TypeError: Can't convert 'float' object to str implicitly

I don't think anything in the return line should be converted to string anyways.

Any tips would be appreciated! My apologies if this is really noob question, I am still in the early stages of learning.

-Nicholas

naokishibuya commented 7 years ago

Hi @166inter I may be shooting a bush but can you check where your images are located? args.data_dir is used in the program to find the training images you recorded (see the train_model method).

The header columns should be center,left,right,steering,throttle,brake,speed and it should be added automatically. For example, it should look like below:

center,left,right,steering,throttle,brake,speed
IMG/center_2016_12_01_13_30_48_287.jpg, IMG/left_2016_12_01_13_30_48_287.jpg, IMG/right_2016_12_01_13_30_48_287.jpg, 0, 0, 0, 22.14829
IMG/center_2016_12_01_13_30_48_404.jpg, IMG/left_2016_12_01_13_30_48_404.jpg, IMG/right_2016_12_01_13_30_48_404.jpg, 0, 0, 0, 21.87963
...

Those are the things I can think of to check. Let me know how it goes (better or worse).

166inter commented 7 years ago

Hi @naokishibuya

I had the images located on my desktop in a folder labeled IMG along with the csv file. I undid changes I made to model.py and the csv file and now have the original error, FileNotFoundError: File b'data/driving_log.csv' does not exist.

I was looking in each of the python files for somewhere where I can specify data_dir but didn't find any such place. Also I tried to specify the path to the desktop in the load_data() function on a separate line data_dir=~/Desktop/ but that didn't help either. I also tried moving the IMG folder and the csv file into the car-behavioral-cloning-master repository but that didn't change anything.

I think there is something fundamental I am overlooking. Thanks for your time!

-Nicholas

naokishibuya commented 7 years ago

Hi @166inter, ok, I think we are getting somewhere.

Can you try the -d option to specify your data directory?

You can see the available command line options in the main() function.

For example,

python model.py -d ~/Desktop

Let me know how that goes.

166inter commented 7 years ago

Hi @naokishibuya,

Ok the program can find the data file now (now I have a better idea how argparse works, thanks) however, I am back at this error:

Traceback (most recent call last): File "model.py", line 111, in <module> main() File "model.py", line 105, in main data = load_data(args) File "model.py", line 23, in load_data X = data_df[['center', 'left', 'right']].values File "/Users/user/anaconda/envs/car-behavioral-cloning/lib/python3.5/site-packages/pandas/core/frame.py", line 2056, in __getitem__ return self._getitem_array(key) File "/Users/user/anaconda/envs/car-behavioral-cloning/lib/python3.5/site-packages/pandas/core/frame.py", line 2100, in _getitem_array indexer = self.loc._convert_to_indexer(key, axis=1) File "/Users/user/anaconda/envs/car-behavioral-cloning/lib/python3.5/site-packages/pandas/core/indexing.py", line 1231, in _convert_to_indexer raise KeyError('%s not in index' % objarr[mask]) KeyError: "['center' 'left' 'right'] not in index"

I think there is some problem automatically adding labels to driving_log.csv but I am not sure!

-Nicholas

naokishibuya commented 7 years ago

Hello @166inter,

I'm glad one issue is gone now.

About the second issue, I'm guessing that might be something to do with the header columns (as you also mentioned).

Let's compare my file with yours. The below is the first 10 lines from my driving_log.csv file.

center,left,right,steering,throttle,brake,speed
IMG/center_2016_12_01_13_30_48_287.jpg, IMG/left_2016_12_01_13_30_48_287.jpg, IMG/right_2016_12_01_13_30_48_287.jpg, 0, 0, 0, 22.14829
IMG/center_2016_12_01_13_30_48_404.jpg, IMG/left_2016_12_01_13_30_48_404.jpg, IMG/right_2016_12_01_13_30_48_404.jpg, 0, 0, 0, 21.87963
IMG/center_2016_12_01_13_31_12_937.jpg, IMG/left_2016_12_01_13_31_12_937.jpg, IMG/right_2016_12_01_13_31_12_937.jpg, 0, 0, 0, 1.453011
IMG/center_2016_12_01_13_31_13_037.jpg, IMG/left_2016_12_01_13_31_13_037.jpg, IMG/right_2016_12_01_13_31_13_037.jpg, 0, 0, 0, 1.438419
IMG/center_2016_12_01_13_31_13_177.jpg, IMG/left_2016_12_01_13_31_13_177.jpg, IMG/right_2016_12_01_13_31_13_177.jpg, 0, 0, 0, 1.418236
IMG/center_2016_12_01_13_31_13_279.jpg, IMG/left_2016_12_01_13_31_13_279.jpg, IMG/right_2016_12_01_13_31_13_279.jpg, 0, 0, 0, 1.403993
IMG/center_2016_12_01_13_31_13_381.jpg, IMG/left_2016_12_01_13_31_13_381.jpg, IMG/right_2016_12_01_13_31_13_381.jpg, 0, 0, 0, 1.389892
IMG/center_2016_12_01_13_31_13_482.jpg, IMG/left_2016_12_01_13_31_13_482.jpg, IMG/right_2016_12_01_13_31_13_482.jpg, 0, 0, 0, 1.375934
IMG/center_2016_12_01_13_31_13_584.jpg, IMG/left_2016_12_01_13_31_13_584.jpg, IMG/right_2016_12_01_13_31_13_584.jpg, 0, 0, 0, 1.362115

Does your file look like mine (in terms of the header and the data format)?

naokishibuya commented 7 years ago

Hi @166inter,

I just remember that the header columns are in the original driving_log.csv file but not in the one that is generated by the simulator (i.e., saved recordings). So, if you are not adding your data to the original file, you won't have the header columns. I was wrong in saying it was automatically generated (it was already there as I was copying the saved data to the original file manually). If you don't have the header columns, you'd need to add it manually.

I hope this should resolve the issue (or rather misunderstanding from my side). Let me know how it goes.

166inter commented 7 years ago

Hi @naokishibuya,

I got the network training! :)

I was comparing my csv file to what you posted and it was in fact different. The problem was, I used LibreOffice spreadsheets to add the headers and at some point the number values were converted to strings. Also because my computer is in German, it LibreOffice added commas in place of decimals. This also affected the small speed values in scientific notation. Now the error I was getting makes sense to me.

I ended up just generating some new training data as that was easier and then added the headers in a simple text editor.

Thanks for your help and patience!

-Nicholas

naokishibuya commented 7 years ago

Great news. Enjoy training!