以前のentryで Deep Floor Plan を動かした気がしていますが、 なぜか、動作しなくなっていましたので、改めて。
今回は、以下の参考urlにある colab.research.google.com の内容を rhel9 & python 3.10 の環境で写経します。
参考url
- https://colab.research.google.com/github/zcemycl/TF2DeepFloorplan/blob/master/deepfloorplan.ipynb#scrollTo=xzqbdPC0uJNc
- https://github.com/zcemycl/TF2DeepFloorplan
- https://github.com/zlzeng/DeepFloorplan
- https://openaccess.thecvf.com/ICCV2019?day=2019-11-01 (※1)
※1 Deep Floor Plan Recognition Using a Multi-Task Network With Room-Boundary-Guided Attention
python仮想環境の作成
$ pyenv install 3.7.16 $ pyenv install 3.10.10 $ pyenv versions * system (set by /home/end0tknr/.pyenv/version) * 3.7.16 3.10.10 3.11.2 $ pyenv local 3.10.10 $ python --version Python 3.10.10 $ cd /home/end0tknr/proj $ python -m venv deep_floor_plan $ cd deep_floor_plan $ source ./bin/activate
git cloneや pip install
GPUなしの環境を使用していますので、 以下では pip install tensorflow-cpu しています
$ cd /home/end0tknr/proj/deep_floor_plan $ git clone https://github.com/zcemycl/TF2DeepFloorplan.git $ pip install gdown $ pip install --upgrade --no-cache-dir gdown $ pip install matplotlib numpy opencv-python pdbpp \ tensorboard tensorflow-cpu scipy Pillow gdown
学習済みデータのdownload & 解凍
$ cd /home/end0tknr/proj/deep_floor_plan $ gdown https://drive.google.com/uc?id=1czUSFvk6Z49H-zRikTc67g2HUUz4imON $ unzip log.zip $ rm log.zip
Deep Floor Plan for python の実行
python script
import tensorflow as tf import sys sys.path.append('./TF2DeepFloorplan/') sys.path.append('./TF2DeepFloorplan/dfp') from dfp.net import * from dfp.data import * import matplotlib.image as mpimg import matplotlib.pyplot as plt from argparse import Namespace import os import gc os.environ['TF_FORCE_GPU_ALLOW_GROWTH'] = 'false' sys.path.append('./TF2DeepFloorplan/dfp/utils/') from dfp.utils.rgb_ind_convertor import * from dfp.utils.util import * from dfp.utils.legend import * from dfp.deploy import * #print( tf.config.list_physical_devices('GPU') ) #print(tf.test.is_gpu_available()) args = Namespace(image='./TF2DeepFloorplan/resources/30939153.jpg', weight='./log/store/G', loadmethod='log', postprocess=True, colorize=True, save="output.png") result = dfp.deploy.main(args) # 凡例を legend.png として出力 # dfp.utils.legend.main()
標準出力結果
実行時にwarningのようなメッセージが表示されましたが、 生成された画像には悪影響していないようでした。
2023-05-06 15:10:40.477830: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations. To enable the following instructions: AVX2, in other operations, rebuild TensorFlow with the appropriate compiler flags. <module 'dfp.utils._paths' from '/home/end0tknr/proj/deep_floor_plan/./TF2DeepFloorplan/dfp/utils/_paths.py'> <module 'dfp._paths' from '/home/end0tknr/proj/deep_floor_plan/./TF2DeepFloorplan/dfp/_paths.py'> 2023-05-06 15:10:44.888348: W tensorflow/tsl/framework/cpu_allocator_impl.cc:83] Allocation of 67108864 exceeds 10% of free system memory. 2023-05-06 15:10:44.937080: W tensorflow/tsl/framework/cpu_allocator_impl.cc:83] Allocation of 67108864 exceeds 10% of free system memory. 2023-05-06 15:10:44.954258: W tensorflow/tsl/framework/cpu_allocator_impl.cc:83] Allocation of 67108864 exceeds 10% of free system memory. 2023-05-06 15:10:44.970637: W tensorflow/tsl/framework/cpu_allocator_impl.cc:83] Allocation of 67108864 exceeds 10% of free system memory. 2023-05-06 15:10:45.170290: W tensorflow/tsl/framework/cpu_allocator_impl.cc:83] Allocation of 67108864 exceeds 10% of free system memory. /home/end0tknr/proj/deep_floor_plan/./TF2DeepFloorplan/dfp/utils/util.py:33: UserWarning: ignoring size because footprint is set ndimage.grey_erosion(output_array, size=(3, 3), footprint=el), (600, 419, 3) (600, 419, 3)
標準出力画像
(参考)入力画像
入力に使用した 30939153.jpg も git cloneに含まれています