配置和运行 MatchNet CVPR 2015
GitHub: https://github.com/hanxf/matchnet
最近一个同学在配置,测试这个网络,但是总是遇到各种问题. 我也尝试了一下,结果也是一堆问题. 这里记录一下.
问题1. ImportError: No module named leveldb
[email protected]:~/Downloads/matchnet-master$ ./run_gen_data.sh
Traceback (most recent call last):
File "generate_patch_db.py", line 19, in <module>
import leveldb, numpy as np, skimage
ImportError: No module named leveldb
Traceback (most recent call last):
File "generate_patch_db.py", line 19, in <module>
import leveldb, numpy as np, skimage
ImportError: No module named leveldb
Traceback (most recent call last):
File "generate_patch_db.py", line 19, in <module>
import leveldb, numpy as np, skimage
ImportError: No module named leveldb
可以看到, 总是提示没有这个 leveldb . Ok, 没有就安装就是了:
[email protected]:~$ pip install leveldb
Collecting leveldb
Downloading leveldb-0.194.tar.gz (228kB)
100% |████████████████████████████████| 235kB 13kB/s
Building wheels for collected packages: leveldb
Running setup.py bdist_wheel for leveldb ... done
Stored in directory: /home/wangxiao/.cache/pip/wheels/36/8f/73/51df0d55dae7b540bc560eb223fff5f909033954552eae8d15
Successfully built leveldb
Installing collected packages: leveldb
Successfully installed leveldb-0.194
然后,这个问题就解决了.
但是, 新出了一个问题2: No module named caffe.proto
[email protected]:~/Downloads/matchnet-master$ ./run_gen_data.sh
Traceback (most recent call last):
File "generate_patch_db.py", line 21, in <module>
from caffe.proto import caffe_pb2
ImportError: No module named caffe.proto
Traceback (most recent call last):
File "generate_patch_db.py", line 21, in <module>
from caffe.proto import caffe_pb2
ImportError: No module named caffe.proto
Traceback (most recent call last):
File "generate_patch_db.py", line 21, in <module>
from caffe.proto import caffe_pb2
ImportError: No module named caffe.proto
Ok, 感觉其实, 这个工程代码没有提示 caffe 该放在哪个文件夹, 是麻烦的问题所在. 那么, 现在只有猜测了.
我们在编译 pycaffe 的时候, 终端有提示我们 caffe.proto 的位置 :
[email protected]:~/Downloads/matchnet-master/caffe-master$ make pycaffe
CXX/LD -o python/caffe/_caffe.so python/caffe/_caffe.cpp
touch python/caffe/proto/__init__.py
PROTOC (python) src/caffe/proto/caffe.proto
[email protected]:~/Downloads/matchnet-master/caffe-master$
终于找到原因了: 是 caffe 文件夹放置的路径不对 !
我之前一直将 caffe 文件夹放置在下载的 match net 文件夹下, 如下图所示:
但是, 其实这样子是不对的. 应该将下载的代码放到 caffe 文件中, 或者你也可以将 caffe 中的文件 拷贝到 matchnet 文件中.
然后运行
./run_gen_data.sh
就可以开始处理数据,然后运行了.
@inproceedings{matchnet_cvpr_15,
Author = {Han, Xufeng and Leung, Thomas and Jia, Yangqing and Sukthankar, Rahul and Berg, Alexander. C.},
Booktitle = {CVPR},
Title = {MatchNet: Unifying Feature and Metric Learning for Patch-Based Matching},
Year = {2015}
}