AutonomousDrivingCookbook icon indicating copy to clipboard operation
AutonomousDrivingCookbook copied to clipboard

Error in train.ipynb

Open hrishikeshtawade04 opened this issue 6 years ago • 14 comments

On running the Train model code in Autonomous Driving cookbook I am getting following error in the third code cell. It seems there is an error in the Generators.py code. Kindly help.


ValueError Traceback (most recent call last) in () ----> 1 data_generator = DriveDataGenerator(rescale=1./255., horizontal_flip=True, brighten_range = (0.4,0.0)) 2 train_generator = data_generator.flow (train_dataset['image'], train_dataset['previous_state'], train_dataset['label'], batch_size=batch_size, zero_drop_percentage=0.95, roi=[76,135,0,255]) 3 eval_generator = data_generator.flow (eval_dataset['image'], eval_dataset['previous_state'], eval_dataset['label'], batch_size=batch_size, zero_drop_percentage=0.95, roi=[76,135,0,255])

~/enpm-809k/AutonomousDrivingCookbook/AirSimE2EDeepLearning/Generator.py in init(self, featurewise_center, samplewise_center, featurewise_std_normalization, samplewise_std_normalization, zca_whitening, zca_epsilon, rotation_range, width_shift_range, height_shift_range, shear_range, zoom_range, channel_shift_range, fill_mode, cval, horizontal_flip, vertical_flip, rescale, preprocessing_function, data_format, brighten_range) 45 rescale, 46 preprocessing_function, ---> 47 data_format) 48 self.brighten_range = brighten_range 49

~/anaconda3/envs/airsim/lib/python3.5/site-packages/keras/preprocessing/image.py in init(self, featurewise_center, samplewise_center, featurewise_std_normalization, samplewise_std_normalization, zca_whitening, zca_epsilon, rotation_range, width_shift_range, height_shift_range, brightness_range, shear_range, zoom_range, channel_shift_range, fill_mode, cval, horizontal_flip, vertical_flip, rescale, preprocessing_function, data_format, validation_split, dtype) 464 data_format=data_format, 465 validation_split=validation_split, --> 466 **kwargs) 467 468

~/anaconda3/envs/airsim/lib/python3.5/site-packages/keras_preprocessing/image/image_data_generator.py in init(self, featurewise_center, samplewise_center, featurewise_std_normalization, samplewise_std_normalization, zca_whitening, zca_epsilon, rotation_range, width_shift_range, height_shift_range, brightness_range, shear_range, zoom_range, channel_shift_range, fill_mode, cval, horizontal_flip, vertical_flip, rescale, preprocessing_function, data_format, validation_split, interpolation_order, dtype) 360 raise ValueError( 361 '`brightness_range should be tuple or list of two floats. ' --> 362 'Received: %s' % (brightness_range,)) 363 self.brightness_range = brightness_range 364

ValueError: `brightness_range should be tuple or list of two floats. Received: 0.0

hrishikeshtawade04 avatar Feb 12 '19 19:02 hrishikeshtawade04

Hello, I have encountered the same problem. Have you solved this problem?Thanks a lot!

Misslindalian avatar Feb 16 '19 08:02 Misslindalian

I think there is a problem of keras version

On Sat, Feb 16, 2019, 3:59 AM Misslindalian <[email protected] wrote:

Hello, I have encountered the same problem. Have you solved this problem?Thanks a lot!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Microsoft/AutonomousDrivingCookbook/issues/89#issuecomment-464319317, or mute the thread https://github.com/notifications/unsubscribe-auth/AgaGbzU4uscWuuh-vlnRZ4qXMTZxZjIKks5vN8hggaJpZM4a35pq .

hrishikeshtawade04 avatar Feb 16 '19 09:02 hrishikeshtawade04

So how to solve it? Just upgrade keras version?Thanks a lot!

Misslindalian avatar Feb 16 '19 09:02 Misslindalian

Ya. That should work. Haven't tried it. But one of my colleague have done it. Jist check the issue section of airsim

On Sat, Feb 16, 2019, 4:11 AM Misslindalian <[email protected] wrote:

So how to solve it? Just upgrade keras version?Thanks a lot!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Microsoft/AutonomousDrivingCookbook/issues/89#issuecomment-464321088, or mute the thread https://github.com/notifications/unsubscribe-auth/AgaGb-evcRddV0JQjAMMOmxwCC6ajeufks5vN8skgaJpZM4a35pq .

hrishikeshtawade04 avatar Feb 16 '19 09:02 hrishikeshtawade04

Airsim?Can you tell me in detail?

Misslindalian avatar Feb 16 '19 09:02 Misslindalian

Haven't tried it though. I have directly used the trained models. But take a look at all issues. The solution is in one of them

On Sat, Feb 16, 2019, 4:20 AM Misslindalian <[email protected] wrote:

Airsim?Can you tell me in detail?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Microsoft/AutonomousDrivingCookbook/issues/89#issuecomment-464322690, or mute the thread https://github.com/notifications/unsubscribe-auth/AgaGb9w7POHNDeoKsne9g_IQi6Oj-9Gsks5vN817gaJpZM4a35pq .

hrishikeshtawade04 avatar Feb 16 '19 09:02 hrishikeshtawade04

Hello! How about your trained models? My tested result is not good. When I trained the models, it stopped when the iterator = 45. But in fact, it needs to run 500 iterators. What I mean is that it "stopped early". Thank you for your patience!

Misslindalian avatar Feb 18 '19 14:02 Misslindalian

What error did it show when it stopped at 45?

hrishikeshtawade04 avatar Feb 18 '19 22:02 hrishikeshtawade04

For the initial keras error, make sure you are using version 2.1.2. See this issue as to why.

It probably stopped early because of the EarlyStopping Callback. Here is why you want to use that callback.

If it actually showed an error, open a new issue. Please use the issue template and fill out all relevant forms.

mitchellspryn avatar Feb 18 '19 23:02 mitchellspryn

Thank you for your answer! However, the model does not perform well. It can only run normally in the first few seconds. When it turns, it will collide and rush into the grass.

Misslindalian avatar Feb 19 '19 02:02 Misslindalian

Try retraining with a different RNG seed. There isn't enough data to guarantee that the network fully converges every time. But after a few attempts, you should get one that works.

mitchellspryn avatar Feb 19 '19 03:02 mitchellspryn

Can we go back please to the original post about Keras brightness_range ? I have the same problem (I moved the notebook to a simple py file and run it) :

C:\AirSim_RL>python TrainModel.py Using TensorFlow backend. Traceback (most recent call last): File "TrainModel.py", line 44, in data_generator = DriveDataGenerator(rescale=1./255., horizontal_flip=True, brighten_range=(0.0,0.0))#brighten_range=0.4) File "C:\AirSim_RL\Generator.py", line 93, in init data_format) File "C:\Python\Python35\lib\site-packages\keras\preprocessing\image.py", line 466, in init **kwargs) File "C:\Python\Python35\lib\site-packages\keras_preprocessing\image\image_data_generator.py", line 362, in init 'Received: %s' % (brightness_range,)) ValueError: `brightness_range should be tuple or list of two floats. Received: 0.0

Any help will be appreciated...

OrSh1234 avatar Apr 09 '19 07:04 OrSh1234

@Orsh1234 just change the keras version to 2.1.2 using the command conda install keras==2.1.2 and it solves the problem

hrishikeshtawade04 avatar Apr 09 '19 07:04 hrishikeshtawade04

hrishikeshtawade04 - thanks. It solves the problem.

OrSh1234 avatar Apr 30 '19 06:04 OrSh1234