Detectron.pytorch代码解读--tools test_net.py

本文档详细解读Detectron.pytorch库中tools的test_net.py文件,该程序专注于在多个测试集上执行推理,并生成预测结果.json及detections.pkl。程序主要功能包括参数解析和调用run_inference函数,该函数实际来源于core.test_engine。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

代码

这个程序的主要目的是 :"""Perform inference on one or more datasets."""

在一个或多个测试集上进行测试

最后返回结果包括  预测的结果文件.json

detections.pkl

分析结果 map recall等(当然是调用其他函数实现的)

本程序的代码功能是解析输入的参数 等

主要的函数在于

    run_inference(
        args,
        ind_range=args.range,
        multi_gpu_testing=args.multi_gpu_testing,
        check_expected_results=True)

 

而 run_inference 来自下面这个文件所以

from core.test_engine import run_inference

下次分析  core.test_engine

    run_inference(
        args,
        ind_range=args.range,
        multi_gpu_testing=args.multi_gpu_testing,
        check_expected_results=True)
"""Perform inference on one or more datasets."""

import argparse
import cv2
import os
conda安装环境出现问题:Building wheels for collected packages: torch-scatter, torch-cluster Building wheel for torch-scatter (setup.py) ... error error: subprocess-exited-with-error × python setup.py bdist_wheel did not run successfully. │ exit code: 1 ╰─> [31 lines of output] running bdist_wheel running build running build_py creating build\lib.win-amd64-cpython-38\torch_scatter copying torch_scatter\placeholder.py -> build\lib.win-amd64-cpython-38\torch_scatter copying torch_scatter\scatter.py -> build\lib.win-amd64-cpython-38\torch_scatter copying torch_scatter\segment_coo.py -> build\lib.win-amd64-cpython-38\torch_scatter copying torch_scatter\segment_csr.py -> build\lib.win-amd64-cpython-38\torch_scatter copying torch_scatter\testing.py -> build\lib.win-amd64-cpython-38\torch_scatter copying torch_scatter\utils.py -> build\lib.win-amd64-cpython-38\torch_scatter copying torch_scatter\__init__.py -> build\lib.win-amd64-cpython-38\torch_scatter creating build\lib.win-amd64-cpython-38\torch_scatter\composite copying torch_scatter\composite\logsumexp.py -> build\lib.win-amd64-cpython-38\torch_scatter\composite copying torch_scatter\composite\softmax.py -> build\lib.win-amd64-cpython-38\torch_scatter\composite copying torch_scatter\composite\std.py -> build\lib.win-amd64-cpython-38\torch_scatter\composite copying torch_scatter\composite\__init__.py -> build\lib.win-amd64-cpython-38\torch_scatter\composite running egg_info writing torch_scatter.egg-info\PKG-INFO writing dependency_links to torch_scatter.egg-info\dependency_links.txt writing requirements to torch_scatter.egg-info\requires.txt writing top-level names to torch_scatter.egg-info\top_level.txt reading manifest file 'torch_scatter.egg-info\SOURCES.txt' reading manifest template 'MANIFEST.in' warning: no previously-included files matching '*' found under directory 'test' adding license file 'LICENSE' writing manifest file 'torch_scatter.egg-info\SOURCES.txt' running build_ext D:\anaconda3\envs\NBFNet\lib\site-packages\torch\utils\cpp_extension.py:304: UserWarning: Error checking compiler version for cl: [WinError 2] 系统找不到指定的文件。 warnings.warn(f'Error checking compiler version for {compiler}: {error}') building 'torch_scatter._scatter_cpu' extension error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/ [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for torch-scatter Running setup.py clean for torch-scatter Building wheel for torch-cluster (setup.py) ... error error: subprocess-exited-with-error × python setup.py bdist_wheel did not run successfully. │ exit code: 1 ╰─> [30 lines of output] running bdist_wheel running build running build_py creating build\lib.win-amd64-cpython-38\torch_cluster copying torch_cluster\fps.py -> build\lib.win-amd64-cpython-38\torch_cluster copying torch_cluster\graclus.py -> build\lib.win-amd64-cpython-38\torch_cluster copying torch_cluster\grid.py -> build\lib.win-amd64-cpython-38\torch_cluster copying torch_cluster\knn.py -> build\lib.win-amd64-cpython-38\torch_cluster copying torch_cluster\nearest.py -> build\lib.win-amd64-cpython-38\torch_cluster copying torch_cluster\radius.py -> build\lib.win-amd64-cpython-38\torch_cluster copying torch_cluster\rw.py -> build\lib.win-amd64-cpython-38\torch_cluster copying torch_cluster\sampler.py -> build\lib.win-amd64-cpython-38\torch_cluster copying torch_cluster\testing.py -> build\lib.win-amd64-cpython-38\torch_cluster copying torch_cluster\typing.py -> build\lib.win-amd64-cpython-38\torch_cluster copying torch_cluster\__init__.py -> build\lib.win-amd64-cpython-38\torch_cluster running egg_info writing torch_cluster.egg-info\PKG-INFO writing dependency_links to torch_cluster.egg-info\dependency_links.txt writing requirements to torch_cluster.egg-info\requires.txt writing top-level names to torch_cluster.egg-info\top_level.txt reading manifest file 'torch_cluster.egg-info\SOURCES.txt' reading manifest template 'MANIFEST.in' warning: no previously-included files matching '*' found under directory 'test' adding license file 'LICENSE' writing manifest file 'torch_cluster.egg-info\SOURCES.txt' running build_ext D:\anaconda3\envs\NBFNet\lib\site-packages\torch\utils\cpp_extension.py:304: UserWarning: Error checking compiler version for cl: [WinError 2] 系统找不到指定的文件。 warnings.warn(f'Error checking compiler version for {compiler}: {error}') building 'torch_cluster._fps_cpu' extension error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/ [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for torch-cluster Running setup.py clean for torch-cluster Failed to build torch-scatter torch-cluster ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (torch-scatter, torch-cluster)
最新发布
06-23
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值