[LAB 10 · 从 RGB 图像训练小型检测器](/course/notebooks/a14237bfa9dd413d959ab4e458e11f42.html) # 主实验的输入、目标和固定协议 · 实现代码 [独立阅读](/course/notebook-blocks/7be8ac6a71494b79a0db46868b83e27f.html) 主线阅读与优先实验 RGB图像、单特征层锚框检测器、分类/位置损失、NMS、独立检测评价 展开完整实现代码 ``` import importlib.util, subprocess, sys from pathlib import Path # The only download, if needed, is open-source Python packages, not model weights. if importlib.util.find_spec('torch') is None: subprocess.check_call([sys.executable, '-m', 'pip', 'install', 'torch', '--index-url', 'https://download.pytorch.org/whl/cpu']) missing=[p for p in ['numpy','matplotlib'] if importlib.util.find_spec(p) is None] if missing: subprocess.check_call([sys.executable,'-m','pip','install',*missing]) import torch, numpy as np print('Python',sys.version.split()[0], 'torch',torch.__version__, 'numpy',np.__version__, 'device: CPU') ```