image-segmentation-keras icon indicating copy to clipboard operation
image-segmentation-keras copied to clipboard

1.Error in loading augmentation, can't import imgaug.Please make sure it is installed. and 2.module 'keras.utils' has no attribute 'get_file'

Open Tiazarias opened this issue 4 years ago • 3 comments
trafficstars

I have 2 error: 1.Error in loading augmentation, can't import imgaug.Please make sure it is installed. When I run command in cmd (Windows10):

python -m keras_segmentation train
--checkpoints_path="path_to_checkpoints"
--train_images="dataset1/images_prepped_train/"
--train_annotations="dataset1/annotations_prepped_train/"
--val_images="dataset1/images_prepped_test/"
--val_annotations="dataset1/annotations_prepped_test/"
--n_classes=50
--input_height=320
--input_width=640
--model_name="vgg_unet"

It show : Error in loading augmentation, can't import imgaug.Please make sure it is installed.

When I run this code on jupyter notebook :

from keras_segmentation.models.unet import vgg_unet

It show: Error in loading augmentation, can't import imgaug.Please make sure it is installed.

pip library version that install on my laptop. imgaug 0.2.9 Keras 2.4.3 keras-segmentation 0.3.0 opencv-python 4.5.2.52 tensorflow 2.4.1 tensorflow-gpu 2.4.1

  1. module 'keras.utils' has no attribute 'get_file'. When i copy Working Google Colab Examples: for run. Python Interface: https://colab.research.google.com/drive/1q_eCYEzKxixpCKH1YDsLnsvgxl92ORcv?usp=sharing

When i run this code:

model = vgg_unet(n_classes=50 , input_height=320, input_width=640 )

It show:

AttributeError Traceback (most recent call last)

in () ----> 1 model = vgg_unet(n_classes=50 , input_height=320, input_width=640 )

2 frames

/usr/local/lib/python3.7/dist-packages/keras_segmentation/models/vgg16.py in get_vgg_encoder(input_height, input_width, pretrained, channels) 75 76 if pretrained == 'imagenet': ---> 77 VGG_Weights_path = keras.utils.get_file( 78 pretrained_url.split("/")[-1], pretrained_url) 79 Model(img_input, x).load_weights(VGG_Weights_path, by_name=True, skip_mismatch=True)

AttributeError: module 'keras.utils' has no attribute 'get_file'

How do I fix it?

Tiazarias avatar Sep 15 '21 12:09 Tiazarias

hello, you should modify the line 77 in image-segmentation-keras/keras_segmentation/models/vgg16.py by replacing: VGG_Weights_path = keras.utils.get_file( by VGG_Weights_path = tf.keras.utils.get_file( do not forgot to add import tensorflow as tf and reinstall the image-segmentation-keras library

alwansm avatar Sep 20 '21 23:09 alwansm

We need to execute this again to reinstall?

!pip install git+https://github.com/divamgupta/image-segmentation-keras

CharlsOliver avatar Nov 29 '21 18:11 CharlsOliver

Please follow this comment!!! https://github.com/divamgupta/image-segmentation-keras/issues/336#issuecomment-983511076

sushantag9 avatar Dec 01 '21 10:12 sushantag9