XPAPA
XPAPA

Reputation: 41

cannot import name 'get_source_inputs' from 'keras.engine' (Spyder IDE launched from Anaconda Navigator)

I need your help to solve this error problem:

In brief, when I run the following code:

import os
import cv2
import numpy as np
from matplotlib import pyplot as plt
from patchify import patchify
from PIL import Image
import segmentation_models as sm
from tensorflow.keras.metrics import MeanIoU

I get this error:

ImportError: cannot import name 'get_source_inputs' from 'keras.engine' (C:\Users\xpapa\.conda\envs\TensorFlow\lib\site-packages\keras\engine\__init__.py)

Here's the situation**

2022-09-20 07:56:06.902214: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found 2022-09-20 07:56:06.902313: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine. Traceback (most recent call last):

  File "C:\Users\xpapa\.conda\envs\TensorFlow\lib\site-packages\spyder_kernels\py3compat.py", line 356, in compat_exec
    exec(code, globals, locals)

  File "c:\users\xpapa\untitled2.py", line 38, in <module>
    import segmentation_models as sm

  File "C:\Users\xpapa\.conda\envs\TensorFlow\lib\site-packages\segmentation_models\__init__.py", line 5, in <module>
    from .unet import Unet

  File "C:\Users\xpapa\.conda\envs\TensorFlow\lib\site-packages\segmentation_models\unet\__init__.py", line 1, in <module>
    from .model import Unet

  File "C:\Users\xpapa\.conda\envs\TensorFlow\lib\site-packages\segmentation_models\unet\model.py", line 4, in <module>
    from ..backbones import get_backbone, get_feature_layers

  File "C:\Users\xpapa\.conda\envs\TensorFlow\lib\site-packages\segmentation_models\backbones\__init__.py", line 1, in <module>
    from classification_models import Classifiers

  File "C:\Users\xpapa\.conda\envs\TensorFlow\lib\site-packages\classification_models\__init__.py", line 3, in <module>
    from . import resnet as rn

  File "C:\Users\xpapa\.conda\envs\TensorFlow\lib\site-packages\classification_models\resnet\__init__.py", line 1, in <module>
    from .models import *

  File "C:\Users\xpapa\.conda\envs\TensorFlow\lib\site-packages\classification_models\resnet\models.py", line 1, in <module>
    from .builder import build_resnet

  File "C:\Users\xpapa\.conda\envs\TensorFlow\lib\site-packages\classification_models\resnet\builder.py", line 11, in <module>
    from keras.engine import get_source_inputs

ImportError: cannot import name 'get_source_inputs' from 'keras.engine' (C:\Users\xpapa\.conda\envs\TensorFlow\lib\site-packages\keras\engine\__init__.py)

CAN YOU PLEASE TELL ME HOW TO SOLVE THIS?

Upvotes: 2

Views: 1458

Answers (1)

user11530462
user11530462

Reputation:

I was able to replicate the issue in colab and Spyder IDE. Please make sure that you are installing segmentation_models version 1.0.1. Kindly refer the gist.

pip install segmentation_models==1.0.1

You can install it with the above code to avoid the error. Thank you!

Upvotes: 3

Related Questions