十分艰难,环境比较复杂,版本冲突很多,最后终于调试好了。可以直接用这个环境(也包含了tensorflow2.5,要求mac OS 12+)。
tensorflow2.5安装可参考:https://www.jianshu.com/p/0b5342f4af95
先下载 conda环境
wget -c 'https://github.com/chenyangkang/Mac_m1_Object_detection_API_tensorflow25_environment/blob/main/tf_environment/environment.yml'
conda env create -f environment.yml -n tf25
conda activate tf25
再下载pip安装的环境
wget -c 'https://github.com/chenyangkang/Mac_m1_Object_detection_API_tensorflow25_environment/blob/main/tf_environment/requirements.txt'
pip install -r requirements.txt
最后下载测试脚本
wget https://github.com/chenyangkang/Mac_m1_Object_detection_API_tensorflow25_environment/blob/main/tf_environment/model_builder_tf2_test.py
python model_builder_tf2_test.py
输出结果:
Init Plugin
Init Graph Optimizer
Init Kernel
Running tests under Python 3.8.11: /Users/chenyangkang/miniforge3/envs/tf25/bin/python
[ RUN ] ModelBuilderTF2Test.test_create_center_net_deepmac
Metal device set to: Apple M1
systemMemory: 16.00 GB
maxCacheSize: 5.33 GB
2021-09-27 14:32:24.426421: I tensorflow/core/common_runtime/pluggable_device/pluggable_device_factory.cc:305] Could not identify NUMA node of platform GPU ID 0, defaulting to 0. Your kernel may not have been built with NUMA support.
2021-09-27 14:32:24.426525: I tensorflow/core/common_runtime/pluggable_device/pluggable_device_factory.cc:271] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 0 MB memory) -> physical PluggableDevice (device: 0, name: METAL, pci bus id: <undefined>)
/Users/chenyangkang/miniforge3/envs/tf25/lib/python3.8/site-packages/object_detection/builders/model_builder.py:1091: DeprecationWarning: The 'warn' function is deprecated, use 'warning' instead
logging.warn(('Building experimental DeepMAC meta-arch.'
W0927 14:32:24.508294 4303684992 model_builder.py:1091] Building experimental DeepMAC meta-arch. Some features may be omitted.
INFO:tensorflow:time(__main__.ModelBuilderTF2Test.test_create_center_net_deepmac): 0.21s
I0927 14:32:24.631808 4303684992 test_util.py:2122] time(__main__.ModelBuilderTF2Test.test_create_center_net_deepmac): 0.21s
[ OK ] ModelBuilderTF2Test.test_create_center_net_deepmac
[ RUN ] ModelBuilderTF2Test.test_create_center_net_model0 (customize_head_params=True)
INFO:tensorflow:time(__main__.ModelBuilderTF2Test.test_create_center_net_model0 (customize_head_params=True)): 0.25s
I0927 14:32:24.884076 4303684992 test_util.py:2122] time(__main__.ModelBuilderTF2Test.test_create_center_net_model0 (customize_head_params=True)): 0.25s
[ OK ] ModelBuilderTF2Test.test_create_center_net_model0 (customize_head_params=True)
[ RUN ] ModelBuilderTF2Test.test_create_center_net_model1 (customize_head_params=False)
INFO:tensorflow:time(__main__.ModelBuilderTF2Test.test_create_center_net_model1 (customize_head_params=False)): 0.09s
I0927 14:32:24.975104 4303684992 test_util.py:2122] time(__main__.ModelBuilderTF2Test.test_create_center_net_model1 (customize_head_params=False)): 0.09s
[ OK ] ModelBuilderTF2Test.test_create_center_net_model1 (customize_head_params=False)
Det BiFPN num filters: 112
I0927 14:32:27.176032 4303684992 ssd_efficientnet_bifpn_feature_extractor.py:145] EfficientDet BiFPN num iterations: 5
I0927 14:32:27.176779 4303684992 efficientnet_model.py:147] round_filter input=32 output=32
I0927 14:32:27.183969 4303684992 efficientnet_model.py:147] round_filter input=32 output=32
I0927 14:32:27.184037 4303684992 efficientnet_model.py:147] round_filter input=16 output=16
I0927 14:32:27.275817 4303684992 efficientnet_model.py:147] round_filter input=16 output=16
I0927 14:32:27.275893 4303684992 efficientnet_model.py:147] round_filter input=24 output=24
I0927 14:32:27.350471 4303684992 efficientnet_model.py:147] round_filter input=24 output=24
I0927 14:32:27.350543 4303684992 efficientnet_model.py:147] round_filter input=40 output=48
I0927 14:32:27.427790 4303684992 efficientnet_model.py:147] round_filter input=40 output=48
I0927 14:32:27.427863 4303684992 efficientnet_model.py:147] round_filter input=80 output=88
I0927 14:32:27.536183 4303684992 efficientnet_model.py:147] round_filter input=80 output=88
I0927 14:32:27.536257 4303684992 efficientnet_model.py:147] round_filter input=112 output=120
I0927 14:32:27.645802 4303684992 efficientnet_model.py:147] round_filter input=112 output=120
I0927 14:32:27.645879 4303684992 efficientnet_model.py:147] round_filter input=192 output=208
I0927 14:32:27.791429 4303684992 efficientnet_model.py:147] round_filter input=192 output=208
I0927 14:32:27.791507 4303684992 efficientnet_model.py:147] round_filter input=320 output=352
I0927 14:32:27.860005 4303684992 efficientnet_model.py:147] round_filter input=1280 output=1408
.......
.......
----------------------------------------------------------------------
Ran 24 tests in 9.736s
OK (skipped=1)
运行正常
其他的参考官方流程:
https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/install.html#
网友评论