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

Can't Use Any Model Except fcn_8

Open abertonica opened this issue 3 years ago • 9 comments

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

abertonica avatar Oct 08 '21 18:10 abertonica

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

HoseinHashemi avatar Oct 11 '21 03:10 HoseinHashemi

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.

abertonica avatar Oct 18 '21 16:10 abertonica

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.

Nimdoc avatar Oct 19 '21 09:10 Nimdoc

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

sushantag9 avatar Dec 01 '21 10:12 sushantag9

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

santra11 avatar Dec 22 '21 10:12 santra11

Can you share the full error.

sushantag9 avatar Dec 24 '21 13:12 sushantag9

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

subramanyakrishna avatar Dec 31 '21 09:12 subramanyakrishna

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.

santra11 avatar Jan 03 '22 17:01 santra11

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

omarreess avatar Nov 21 '22 22:11 omarreess