> For the complete documentation index, see [llms.txt](https://hhu-leons-organization.gitbook.io/uav_lodboost_docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hhu-leons-organization.gitbook.io/uav_lodboost_docs/user-guide/ban-jian-du-zi-xun-lian.md).

# 半监督自训练

### 手动配置

1. 数据准备：

准备未标注图像，建议把图像放在 *'Semi-Supervised/JPEGImages'* 目录下

2. 利用源域数据训练好的模型生成伪标签：

运行*getPseudoLabel.py，*&#x6CE8;意修改相关路径，imgs\_path为目标域图像所在路径，output\_xml\_path为标签保存路径

```
torchrun getPseudoLabel.py \
  --imgs_path 'Semi-Supervised/JPEGImages' \
  --output_xmlpath 'Semi-Supervised/Annotations'
```

3. 与源域数据集合并

运行*merge\_data.py ，*&#x6F;rigin代表源域数据路径，new代表目标域数据路径

```
python3 merge_data.py \
  --origin_image_path 'VOCdevkit/VOC2007/JPEGImages'\
  --origin_xml_path 'VOCdevkit/VOC2007/Annotations'\
  --new_image_path 'Semi-Supervised/JPEGImages'\
  --new_xml_path 'Semi-Supervised/Annotations'
```

4. 标签处理

运行*voc\_annotation.py*

5. 使用新数据集继续训练模型

训练步骤参考[*训练YOLO模型*](/uav_lodboost_docs/user-guide/xun-lian-yolo-mo-xing.md) 部分

### 一键式实现

本代码提供一键式的半监督自训练脚本，您可以通过在控制台运行*self\_training.sh*实现此功能
