根据官方文档,或同行的文章,安装 VMAF 后,都出现了各种各样的问题,经过较长时间才逐一解决掉,仅以此文记录。
brew install gcc meson doxygen nasm freetype pkg-config hdf5
brew install numpy scipy
# 下载源码
git clone https://github.com/Netflix/vmaf.git
cd vmaf
git submodule update --init --recursive
# 编译
make
报错信息:
A. 根据报错信息,看到 vmaf/core/../../../libvmaf/src/feature/adm_tools.c 的 22 行: #include "mem.h"报错:找不到 mem.h
B. find 目录 vmaf 下有没有 mem.h
$ find vmaf/ -name mem.h
.//libvmaf/src/mem.h # 该目录下有mem.h文件
C. 问题解决
打开 mem.h 看了一下,没有引用其他文件,所以直接把 mem.h 拷贝到 adm_tools.c 的同级目录中。
再次执行 make clean && make,编译通过。
cd python
pip3 install cython
pip3 install -r requirements.txt
pip3 install --user . # 此时,会出现各种报错
vmaf/core/adm_dwt2_cy.c:637:10: fatal error: '../../../libvmaf/src/feature/adm_tools.c' file not found
通过 ls 发现,文件是存在的,且相对路径没有问题,C 语言运行却没找到。因为 C 都已经还给大学老师了,所以暂时修改为绝对路径(有了解如何解决的小伙伴可以留言)
修改完后,继续执行pip3 install --user .
,显示 vmaf 安装成功
添加export PATH="$PATH:$HOME/.local/bin"
到~/.profile 中
执行source ~/.profile
使配置生效
在 vmaf 根目录下,
./unittest
执行结果有成功的,有失败的,暂时不管。继续下面的步骤。
PYTHONPATH=python ./python/vmaf/script/run_vmaf.py \
yuv420p 576 324 \
python/test/resource/yuv/src01_hrc00_576x324.yuv \
python/test/resource/yuv/src01_hrc01_576x324.yuv \
--out-fmt json
Can't import svmutil from /Users/lizhen/Library/Python/3.8/lib/python/third_party/libsvm/python: No module named 'svmutil'
ll 查看/Users/lizhen/Library/Python/3.8/lib/python/third_party/libsvm/python,发现文件不存在,一脸懵逼啊,卧槽。(欢迎解决过这个问题的小伙伴留言)
不过,初步怀疑是 python 环境的问题,所以用 Pycharm 直接打开 vmaf/python 项目,创建 env 虚拟环境。
在 python 虚拟环境下,运行:
Traceback (most recent call last):
File "./vmaf/script/run_vmaf.py", line 13, in <module>
from vmaf.config import VmafConfig, DisplayConfig
ModuleNotFoundError: No module named 'vmaf'
这个还算好解决:
2020-08-13 17:06:26.846 | ERROR | __main__:subprocess_cmd:55 - 执行失败,输出:
Traceback (most recent call last):
File "/vmaf/python/vmaf/script/run_vmaf.py", line 175, in <module>
ret = main()
File "/vmaf/python/vmaf/script/run_vmaf.py", line 135, in main
runner.run()
File "/vmaf/python/vmaf/core/executor.py", line 155, in run
self.results = list(map(self._run_on_asset, self.assets))
File "/vmaf/python/vmaf/core/quality_runner.py", line 335, in _run_on_asset
vmaf_fassembler = self._get_vmaf_feature_assembler_instance(asset)
File "/vmaf/python/vmaf/core/quality_runner.py", line 310, in _get_vmaf_feature_assembler_instance
feature_dict = self._load_model(asset).get_appended_info('feature_dict')
File "/vmaf/python/vmaf/core/quality_runner.py", line 443, in _load_model
model = train_test_model_class.from_file(model_filepath, self.logger)
File "/vmaf/python/vmaf/core/train_test_model.py", line 522, in from_file
train_test_model = model_class._from_info_loaded(info_loaded, filename,
File "/vmaf/python/vmaf/core/train_test_model.py", line 905, in _from_info_loaded
model = svmutil.svm_load_model(filename + '.model')
AttributeError: module 'vmaf.svmutil' has no attribute 'svm_load_model'
解决方法:
继续执行:
python ./vmaf/script/run_vmaf.py yuv420p 576 324 test/resource/yuv/src01_hrc00_576x324.yuv test/resource/yuv/src01_hrc01_576x324.yuv --out-fmt json