pubgeo / dfc2019

2019 IEEE GRSS Data Fusion Contest data, baselines, and metrics
MIT License
139 stars 57 forks source link

AttributeError: module 'tensorflow._api.v2.image' has no attribute 'resize_bilinear' #13

Closed SBCV closed 3 years ago

SBCV commented 3 years ago

After setting up anaconda with conda env create --name dfc2019 --file=dev-gpu.yml and running

conda activate dfc2019
cd track3
python ./mvs/test-mvs.py

I receive the following error message

Traceback (most recent call last):
  File "./mvs/test-mvs.py", line 693, in <module>
    predictor.build_seg_model(seg_weights_file)
  File "./mvs/test-mvs.py", line 103, in build_seg_model
    self.seg_model = build_icnet(self.height, self.width, self.bands, self.num_categories + 1,
  File "/mnt/Data-512GB/libraries_ml_geo/dfc2019/dfc2019/track3/mvs/model_icnet.py", line 52, in build_icnet
    y = Lambda(lambda x: tf.image.resize_bilinear(x, size=(int(x.shape[1])//2, int(x.shape[2])//2)), name='data_sub2')(inp)
  File "/home/sebastian/miniconda3/envs/dfc2019/lib/python3.8/site-packages/tensorflow/python/keras/engine/base_layer.py", line 922, in __call__
    outputs = call_fn(cast_inputs, *args, **kwargs)
  File "/home/sebastian/miniconda3/envs/dfc2019/lib/python3.8/site-packages/tensorflow/python/keras/layers/core.py", line 888, in call
    result = self.function(inputs, **kwargs)
  File "/mnt/Data-512GB/libraries_ml_geo/dfc2019/dfc2019/track3/mvs/model_icnet.py", line 52, in <lambda>
    y = Lambda(lambda x: tf.image.resize_bilinear(x, size=(int(x.shape[1])//2, int(x.shape[2])//2)), name='data_sub2')(inp)
AttributeError: module 'tensorflow._api.v2.image' has no attribute 'resize_bilinear'
SBCV commented 3 years ago

Apparently, the code accompanying the data set uses Tensorflow 1. With Tensorflow 2 one should replace

import tensorflow as tf

with

import tensorflow.compat.v1 as tf