hminle / car-behavioral-cloning-with-pytorch

23 stars 7 forks source link

How to train #2

Closed AnukritiSinghh closed 3 years ago

AnukritiSinghh commented 3 years ago

For the training, I think I need to run model.py? But where do I give my .csv file and images as input?

hminle commented 3 years ago

Hi @AnukritiSinghh , You need to checkout the Udacity course page, they have a guidance to generate driving log file. https://github.com/udacity/CarND-Behavioral-Cloning-P3#the-project

Basically, you open their simulator, and you try to drive a car by your own manually. Then it will generate a dataset in csv format. Then you use it to train your model.

AnukritiSinghh commented 3 years ago

But where exactly do I need to put the csv file in my code? (I generated it using the simulator)

hminle commented 3 years ago

Hi @AnukritiSinghh , sorry about my unclear guidance. You should check out my experiment notebook. https://github.com/hminle/car-behavioral-cloning-with-pytorch/blob/master/experiment.ipynb image

Use this notebook to train your model

AnukritiSinghh commented 3 years ago

Thanks alot!

hminle commented 3 years ago

You're welcome.

AnukritiSinghh commented 3 years ago

Hey, When I run the code, it shows that its not able to connect with the simulator. I am running the code on my ubuntu sub-system provided by windows but the simulator is installed in windows itself. Do you think that's causing a problem here?

On Sat, Feb 6, 2021 at 8:47 PM Hoang Le notifications@github.com wrote:

You're welcome.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/hminle/car-behavioral-cloning-with-pytorch/issues/2#issuecomment-774492444, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGZUXZ4V433RFJP5K5Y7OT3S5VMO5ANCNFSM4XERORVA .

hminle commented 3 years ago

Hey, When I run the code, it shows that its not able to connect with the simulator. I am running the code on my ubuntu sub-system provided by windows but the simulator is installed in windows itself. Do you think that's causing a problem here? On Sat, Feb 6, 2021 at 8:47 PM Hoang Le @.***> wrote: You're welcome. — You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub <#2 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGZUXZ4V433RFJP5K5Y7OT3S5VMO5ANCNFSM4XERORVA .

hm, maybe. In my case, I ran both of them in a native Ubuntu machine. You can see in the code of drive.py https://github.com/hminle/car-behavioral-cloning-with-pytorch/blob/e80d38c94d739b4b565d92b638727139dca55c6d/drive.py#L179 It basically opens a socket io server listening on 4567 port. I believe in the simulator code, they will specify this port too. Look at this: image It's better to run both of them on the same machine, as they are using localhost.

Best

AnukritiSinghh commented 3 years ago

Thank you so much. I have few other questions related to this, do you mind sharing your email id? It would be a great help for me. Mine is anukriti.runjhun@gmail.com

On Sat, Feb 13, 2021 at 9:13 PM Hoang Le notifications@github.com wrote:

Hey, When I run the code, it shows that its not able to connect with the simulator. I am running the code on my ubuntu sub-system provided by windows but the simulator is installed in windows itself. Do you think that's causing a problem here? … <#m-4205589213420361168> On Sat, Feb 6, 2021 at 8:47 PM Hoang Le @.***> wrote: You're welcome. — You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub <#2 (comment) https://github.com/hminle/car-behavioral-cloning-with-pytorch/issues/2#issuecomment-774492444>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGZUXZ4V433RFJP5K5Y7OT3S5VMO5ANCNFSM4XERORVA .

hm, maybe. In my case, I ran both of them in a native Ubuntu machine. You can see in the code of drive.py

https://github.com/hminle/car-behavioral-cloning-with-pytorch/blob/e80d38c94d739b4b565d92b638727139dca55c6d/drive.py#L179 It basically opens a socket io server listening on 4567 port. I believe in the simulator code, they will specify this port too. Look at this: [image: image] https://user-images.githubusercontent.com/16201681/107854173-2bd2af00-6de8-11eb-8621-3a2c6b4f8c84.png It's better to run both of them on the same machine, as they are using localhost.

Best

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/hminle/car-behavioral-cloning-with-pytorch/issues/2#issuecomment-778635767, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGZUXZ3RFRDJO7H5WIWBNQ3S62MZPANCNFSM4XERORVA .

hminle commented 3 years ago

Hi @AnukritiSinghh , here is my email: hminle@yorku.ca

AnukritiSinghh commented 3 years ago

Hey, Thanks. In the utils.py code, I get error in line 187 saying 'TypeError: can only concatenate str (not "float") to str' Can you please how to solve this? and why exactly do we need to concatenate?

hminle commented 3 years ago

Hi @AnukritiSinghh ,

So in the line 187, it is just the way to adjust steering_angle, for example, you can choose to add any number to the left steering angle and subtract any number to the right, but they should be an equal amount. Here I choose 0.1. I am not sure why you caught this error, but you can try some ways to fix like this:

  1. remove 0.1
  2. Another way is to cast steering_angle to float

Best

Hey, Thanks. In the utils.py code, I get error in line 187 saying 'TypeError: can only concatenate str (not "float") to str' Can you please how to solve this? and why exactly do we need to concatenate?

AnukritiSinghh commented 3 years ago

Thanks I have tried both of them. when I do (1) it shows me the same error for different line, like 73 and 83. when I do (2) its says can convert string to float. So I think the cause of these problems are most probably version of different libraries, since, its 4 years old. If you know the exact versions, can you please let me know?

hminle commented 3 years ago

Hi @AnukritiSinghh , I am sorry about that, I forgot to upload requirements.txt But could you try to remove the number 0.1?

And could you print out the type of steering_angle?

AnukritiSinghh commented 3 years ago

When I removed 0.1 I got the TypeError: bad operand type for unary -: 'str' on this line steering_angle = -steering_angle Also the type of steering_angle is coming out to be string

hminle commented 3 years ago

Hi @AnukritiSinghh ,

I think I know the issue. It seems that when you read the steering_angle from csv, it is a string instead of float. So we may to cast it into float before adding 0.1

Could you apply the function in this link to cast it? https://www.journaldev.com/23715/python-convert-string-to-float

AnukritiSinghh commented 3 years ago

Where should I cast it? Because when I do steering_angle=float(steering_angle) inside the class CarDataset3Img it shows the error ValueError: could not convert string to float: 'steering'

hminle commented 3 years ago

Hi @AnukritiSinghh ,

I think of two ways to cast it:

  1. Before the line 187: https://github.com/hminle/car-behavioral-cloning-with-pytorch/blob/e80d38c94d739b4b565d92b638727139dca55c6d/utils.py#L187 You can cast like: steering_angle = float(steering_angle). But you said it show the ValueError, could you print out the value of steering_angle before that error? Do you know how to set trace and go into debug mode in Python? If you could, you can go to that point, then can investigate more about the error.

  2. The second way is to cast it right after we load the csv data:

![Uploading image.png…]() After this line y = data_df['steering'].values, we can use pandas to cast it. Like this website: https://datatofish.com/convert-string-to-float-dataframe/ For me, the second way is more efficient, because it casts whole dataset

AnukritiSinghh commented 3 years ago

Thanks alot for helping me out, I am new into this I added line data_df['steering'] = data_df['steering'].astype(float) after the line y = data_df['steering'].values. Is this the correct way to write?

hminle commented 3 years ago

Hi @AnukritiSinghh , it should be before. You're welcome.

AnukritiSinghh commented 3 years ago

Thanks it works! But my csv file looks like this screenshot so its reading the word 'steering' as string and that is causing a problem. Is this not how my csv file is supposed to be? ValueError: could not convert string to float: 'steering'

hminle commented 3 years ago

Hi @AnukritiSinghh , That's great. I am not really sure why it happens in your case. Maybe the simulator has updated, or you ran on a Window machine (I ran on the Ubuntu). Or the pandas library has updated too

AnukritiSinghh commented 3 years ago

Yeah but I don't think they updated the simulator. Also, I ran the training script on my ubuntu server. I don't understand whats wrong

On Mon, 1 Mar 2021, 11:54 pm Hoang Le, notifications@github.com wrote:

Hi @AnukritiSinghh https://github.com/AnukritiSinghh , That's great. I am not really sure why it happens in your case. Maybe the simulator has updated, or you ran on a Window machine (I ran on the Ubuntu).

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/hminle/car-behavioral-cloning-with-pytorch/issues/2#issuecomment-788166807, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGZUXZZ6IJFNPNREPXJDWETTBPLVPANCNFSM4XERORVA .

hminle commented 3 years ago

@AnukritiSinghh I don't understand why too

AnukritiSinghh commented 3 years ago

Thankyou for helping so far though! I have one last question. Is the simulator necessary for training? I mean when I run the training script do I need the simulator to be switched on?

hminle commented 3 years ago

Hi @AnukritiSinghh , no, when you run the training notebook, you don't need to open the simulator. The simulator generates a csv log file, then you only need that csv file for training.

AnukritiSinghh commented 3 years ago

Perfect! Again, thanks alot for your time!

hminle commented 3 years ago

You're welcome :)

AnukritiSinghh commented 3 years ago

Hey @hminle, does your code require the image dataset to be divided into three different subfolders - left, right and center?

hminle commented 3 years ago

Hi @AnukritiSinghh , My code does not require. You can check the load_data function in the experiment notebook, as long as your center, left, and right columns in the csv file contain the path of images, it still works fine.