AutonomousDrivingCookbook icon indicating copy to clipboard operation
AutonomousDrivingCookbook copied to clipboard

AirSimE2EDeepLearning TrainModel 'keras.preprocessing.image' has no attribute 'flip_axis'

Open aschwarz387 opened this issue 6 years ago • 6 comments

Problem description

AttributeError: module 'keras.preprocessing.image' has no attribute 'flip_axis' but I can look at the object and see it.

Problem details

I solved my problems with getting past the from keras_tqdm import TQDMNotebookCallback problem, and now am stuck with a AttributeError: module 'keras.preprocessing.image' has no attribute 'flip_axis' image but I can see it in the code. I have added that location to path variable, and even sys.path.insert(2,'C:\Anaconda3\envs\quadcop2019\Lib\site-packages\keras_preprocessing') but still no success. recreated environment 3 times, today alone.

Experiment/Environment details

  • Tutorial used: (AutonomousDrivingCookbook-master\AirSimE2EDeepLearning)
  • Machine used: (Thinkpad P71 with Nvidia P3000 GPU Windows 10 Pro for Workstations )
  • Versions of artifacts used (if applicable): () python 3.6.8 , keras 2.1.2 , keras-applications 1.0.6 , keras-preprocessing 1.0.5 , keras-tqdm 2.0.1 matplotlib 2.1.2 , opencv 3.4.4 , pandas 0.24.0 , tensorflow-gpu 1.7.1 , tensorboard 1.7.0 . tensorflow 1.12.0 , tensorflow-base 1.12.0

sys.path ['C:\Python36', 'C:\Anaconda3\envs\quadcop2019\Lib\site-packages\keras_tqdm', 'C:\Anaconda3\envs\quadcop2019\Lib\site-packages\keras_preprocessing', 'C:\Anaconda3\envs\quadcop2019\python36.zip', 'C:\Anaconda3\envs\quadcop2019\DLLs', 'C:\Anaconda3\envs\quadcop2019\lib', 'C:\Anaconda3\envs\quadcop2019', 'C:\Anaconda3\envs\quadcop2019\lib\site-packages', 'C:\Anaconda3\envs\quadcop2019\lib\site-packages\IPython\extensions', 'C:\Users\Al\.ipython']

aschwarz387 avatar Jan 27 '19 21:01 aschwarz387

I tried installing the package versions that you have listed, and was unable to repro. Can you import the problematic library in a fresh notebook? If not, consider opening up an issue on the repo hosting the library.

mitchellspryn avatar Feb 18 '19 23:02 mitchellspryn

Had the same problem. Resolved it by changing x = image.flip_axis(x, img_col_axis) to x = image.image.flip_axis(x, img_col_axis) and x = image.flip_axis(x, img_row_axis) to x = image.image.flip_axis(x, img_row_axis) in Generator.py

micdahl avatar Mar 06 '19 14:03 micdahl

I have the same problem. Do you have solved this problem.Thank you!

smartboy110 avatar Sep 17 '19 05:09 smartboy110

Had the same problem. Resolved it by changing x = image.flip_axis(x, img_col_axis) to x = image.image.flip_axis(x, img_col_axis) and x = image.flip_axis(x, img_row_axis) to x = image.image.flip_axis(x, img_row_axis) in Generator.py

thx

JFrankLee avatar Mar 19 '20 06:03 JFrankLee

I don't know if @micdahl 's solution works. But I tried adding the function source to my code. If you see here, you can find the original code. Just take it and add it to your function. I believe that this error occurs in TF2 and afterwards, since the age of the file is old(Mar 22, 2018).

If you have a function that you use inside the flip_axis, just add the flip_axis implementation function inside that function.

TLDR add the code below to your implementation def flip_axis(x, axis): x = np.asarray(x).swapaxes(axis, 0) x = x[::-1, ...] x = x.swapaxes(0, axis) return x

antonyalexos avatar Apr 15 '20 21:04 antonyalexos

Had the same problem. Resolved it by changing x = image.flip_axis(x, img_col_axis) to x = image.image.flip_axis(x, img_col_axis) and x = image.flip_axis(x, img_row_axis) to x = image.image.flip_axis(x, img_row_axis) in Generator.py

Thx, this fix works !

rkuo2000 avatar Nov 28 '21 02:11 rkuo2000