divamgupta / image-segmentation-keras

Implementation of Segnet, FCN, UNet , PSPNet and other models in Keras.
https://divamgupta.com/image-segmentation/2019/06/06/deep-learning-semantic-segmentation-keras.html
MIT License
2.91k stars 1.16k forks source link

Can't Use Any Model Except fcn_8 #336

Open abertonica opened 3 years ago

abertonica commented 3 years ago

Any time I try to use any model except fcn_8 I get this error:

weights_path = keras.utils.get_file( AttributeError: module 'keras.utils' has no attribute 'get_file'

Any ideas?

Thanks

HoseinHashemi commented 3 years ago

I have the same issue. Did anyone manage to work around it?

abertonica commented 2 years ago

If you download and build locally, before running the setup.py init, set the optional parameter in the get__encoder(...) function, "pretrained", to 'false' in resnet50.py and vgg16.py along with any other encoders that might use a pretrained model you intend to use.

This is a work around and disables the "if pretrained: " code block that uses .get_file(). This works for me since we are using these models for completely custom datasets.

I am wondering if this issue has anything to do with the fact that keras was integrated into tensorflow 2.0 in 2019. No idea though.

Nimdoc commented 2 years ago

If you're doing it in the colab example like I am you can navigate to this directory /usr/local/lib/python3.7/dist-packages/keras_segmentation, make the edit there from what abertonica said, save, then restart the runtime.

sushantag9 commented 2 years ago

Everywhere update

import keras to import tensorflow.keras

This will solve the issue.

You can also clone this repo and use it image-segmentation-keras

santra11 commented 2 years ago

Hello Sushantag9, I cloned your repository. I have my current work directory, I cloned your Keras segmentation and I have a Jupyter notebook. Now I use the model = vgg_unet(n_classes=n_classes,input_height=img_height,input_width=img_width) gives the error keras.utils has no attribute. But when I run it in Colab everything seems to run

sushantag9 commented 2 years ago

Can you share the full error.

subramanyakrishna commented 2 years ago

Please install from @sushantag9 's repo replace from tensorflow.keras.layers.merge import Concatenate with from tensorflow.keras.layers import Concatenate it worked for me

santra11 commented 2 years ago

Hello, Sushant, I am using the image segmentation for cityscapes pertained models. When I do model.train() , what is mean IoU considered as the metric. I am not able to to understand as it is different from normal the mean IoU. Also how to plot the history of the models.

omarreess commented 1 year ago

Just import those

!apt-get install -y libsm6 libxext6 libxrender-dev

!pip install opencv-python

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

from keras_segmentation.models.unet import vgg_unet