---
title: 3rd_Anti-UAV_CVPR23
canonical_url: "https://www.modelscope.cn/models/iic/3rd_Anti-UAV_CVPR23"
md_url: "https://www.modelscope.cn/models/iic/3rd_Anti-UAV_CVPR23.md"
repository: iic/3rd_Anti-UAV_CVPR23
chinese_name: "3rd-无人机检测竞赛_CodeBase_CVPR23"
last_updated: 2023-03-06
license: "MIT License"
library_name:
  - pytorch
frameworks:
  - pytorch
domain:
  - cv
downloads: 7531
stars: 26
tags:
  - "CVPR2023 Workshop"
  - "UAV Detection"
  - "Base Model"
---

# 3rd_Anti-UAV_CVPR23

> 3rd_Anti-UAV_CVPR23 - iic 在 ModelScope 开源的模型。3rd Anti-UAV Model and Dataset

iic/3rd_Anti-UAV_CVPR23 是 ModelScope 魔搭社区上的机器学习模型，采用 MIT License 许可。

- **Repository**: iic/3rd_Anti-UAV_CVPR23
- **License**: MIT License
- **Tags**: CVPR2023 Workshop, UAV Detection, Base Model
- **Downloads**: 7531
- **Stars**: 26
- **Last updated**: 2023-03-06

Source: https://www.modelscope.cn/models/iic/3rd_Anti-UAV_CVPR23

---

# 3rd Anti-UAV Model and Dataset

This project provides a baseline model and evaluation code for track1 and track2 for CVPR23 3rd Anti-UAV workshop.

# News
**Test Set can be downloaded with following code**:
```
from modelscope.msdatasets import MsDataset
from modelscope.utils.constant import DownloadMode

cache_dir = '/home/ly261666/datasets'
test_set_1 = MsDataset.load('3rd_Anti-UAV', namespace='ly261666', cache_dir=cache_dir, download_mode=DownloadMode.FORCE_REDOWNLOAD)
print(next(iter(test_set_1)))
```
You can also download dataset from the [url](https://modelscope.cn/datasets/ly261666/3rd_Anti-UAV/files)。
Evaluate code can be seen in the section "Baseline Evaluation Code for test Set" in this page.

# Installation
```
conda create -n anti_uav python=3.7
conda activate anti_uav
# pytorch >= 1.3.0
pip install torch==1.8.1+cu102  torchvision==0.9.1+cu102 torchaudio==0.8.1  --extra-index-url https://download.pytorch.org/whl/cu102
git clone https://github.com/ly19965/CVPR_Anti_UAV
cd CVPR_Anti_UAV
pip install -r requirements/tests.txt 
pip install -r requirements/framework.txt
pip install -r requirements/cv.txt 
pip install -r requirements/yolov5.txt
```


# Download Dataset 

Run the download code:
```python
from modelscope.msdatasets import MsDataset
from modelscope.utils.constant import DownloadMode


## set dataset path
cache_dir = '/home/ly261666/datasets' 

# Download train set
train_set = MsDataset.load('3rd_Anti-UAV', namespace='ly261666', split='train', cache_dir=cache_dir, download_mode=DownloadMode.FORCE_REDOWNLOAD)
print(next(iter(train_set)))

# Download validation set
val_set = MsDataset.load('3rd_Anti-UAV', namespace='ly261666', split='validation', cache_dir=cache_dir, download_mode=DownloadMode.FORCE_REDOWNLOAD)
print(next(iter(val_set)))
```

## Baseline Evaluation Code for validation Set (Only Support Evalutation Code)

#### Evaluation code for track1
```python
cd CVPR_Anti_UAV
CUDA_VISIBLE_DEVICES=0  PYTHONPATH=. python tests/pipelines/test_anti-uav_val_track1.py
eval result: 0.125
```

**Note**: 
- The validation dataset for track1 can be downloaded automatically.
- Set the dataset path (line 28) in tests/pipelines/test_anti-uav_val_track1.py

#### Evaluation code for track2

```python
cd CVPR_Anti_UAV
CUDA_VISIBLE_DEVICES=1  PYTHONPATH=. python tests/pipelines/test_anti-uav_val_track2.py
eval result: 0.125
```
**Note**: 
- The validation dataset for track2 can be downloaded automatically.
- Set the dataset path (line 28) in tests/pipelines/test_anti-uav_val_track2.py

## Baseline Training and Evalution Code on Validation Set

### Track 1

#### Ostracker Training code for track1 
```python
## git pull ostracker code
git clone -b ostracker https://github.com/ly19965/CVPR_Anti_UAV

## Training code on Got-10k dataset
cd CVPR_Anti_UAV
PYTHONPATH=. python uav_scripts/train_ostracker_got10k_l.py

## Training code on Anti-UAV 2023 dataset
cd CVPR_Anti_UAV
PYTHONPATH=. python uav_scripts/train_ostracker_uav_l.py

```
**Note**: 
- The training dataset (Anti-UAV-23 and Got-10k) can be downloaded automatically
- Set the dataset path, cache_path and pretrain_model path  in uav_scripts/train_ostracker_got10k_l.py  and uav_scripts/train_ostracker_uav_l.py
- More training Details can be seen in [Ostracker_Model_Got-10k_L](https://modelscope.cn/models/damo/cv_vitb_video-single-object-tracking_ostrack-l/summary) and [Ostracker_Model_UAV_L](https://modelscope.cn/models/damo/cv_vitb_video-single-object-tracking_ostrack-uav-l/summary). [Ostracker_Model_UAV_L](https://modelscope.cn/models/damo/cv_vitb_video-single-object-tracking_ostrack-uav-l/summary) is a pretrain model for [Ostracker_Model_Got-10k_L](https://modelscope.cn/models/damo/cv_vitb_video-single-object-tracking_ostrack-l/summary).

#### Training code for track1
```python
## Training code on Got-10k dataset
cd CVPR_Anti_UAV
PYTHONPATH=. python uav_scripts/train_siamfc_got10k.py

## Training code on Anti-UAV 2023 dataset
cd CVPR_Anti_UAV
PYTHONPATH=. python uav_scripts/train_siamfc_uav.py

```
**Note**: 
- The training dataset (Anti-UAV-23 and Got-10k) can be downloaded automatically
- Set the dataset path, cache_path and pretrain_model path  in uav_scripts/train_siamfc_got10k.py and uav_scripts/train_siamfc_uav.py
- More training Details can be seen in [Siamfc_Model_Got-10k_S](https://modelscope.cn/models/damo/cv_alex_video-single-object-tracking_siamfc/summary) and [Siamfc_Model_Anti-UAV-23_S](https://modelscope.cn/models/damo/cv_alex_video-single-object-tracking_siamfc-uav/summary). [Siamfc_Model_Got-10k_S](https://modelscope.cn/models/damo/cv_alex_video-single-object-tracking_siamfc/summary) is a pretrain model for [Siamfc_Model_Anti-UAV-23_S](https://modelscope.cn/models/damo/cv_alex_video-single-object-tracking_siamfc-uav/summary).

#### Evaluation code for track1
```python
cd CVPR_Anti_UAV
PYTHONPATH=. python uav_scripts/test_anti-uav_val_track1.py
```
**Note**: 
- The validation dataset (Anti-UAV-23) can be downloaded automatically.
- Set the model_id (line25 damo/cv_alex_video-single-object-tracking_siamfc or damo/cv_alex_video-single-object-tracking_siamfc-uav) in uav_scripts/test_anti-uav_val_track1.py

### Track 1
#### Training code for track2

```python
cd CVPR_Anti_UAV
CUDA_VISIBLE_DEVICES=1 PYTHONPATH=. python uav_scripts/train_uav_detection.py
```
**Note**: 
- The training dataset (Anti-UAV-23) can be downloaded automatically.
- Set the dataset path and cache_path in uav_scripts/train_uav_detection.py
- More training Details can be seen in [DamoYolo_Anti-UAV-23_S](https://modelscope.cn/models/damo/cv_tinynas_uav-detection_damoyolo/summary)
- The Large model will be released in [DamoYolo_Anti-UAV-23_L](https://modelscope.cn/models/damo/cv_tinynas_uav-detection_damoyolo-l/summary) before 20230211

#### Evaluation code for track2
```python
cd CVPR_Anti_UAV
PYTHONPATH=. python uav_scripts/test_anti-uav_val_track2.py
eval result: 0.169
```
**Note**: 
- The validation dataset (Anti-UAV-23) can be downloaded automatically.
- Set the traker (line24 damo/cv_alex_video-single-object-tracking_siamfc-uav) and detetion model_id (line27 damo/cv_tinynas_uav-detection_damoyolo) in uav_scripts/test_anti-uav_val_track2.py
- Test your owr model:
```python
line 101 in uav_scripts/test_anti-uav_val_track2.py
tracker_model_path = ""
det_model_path = ""
uav_tracker.model.load_state_dcit(torch.load(tracker_model_path))
uav_detection.model.load_state_dcit(torch.load(det_model_path))

```

## Baseline Evaluation Code for test Set

**Note**: Code is available now, but the test set will be released in 2023.03.07.
#### Evaluation code for track1
- Test SiamFC tracker with initial target ground-truth box

```python
cd CVPR_Anti_UAV
python tests/pipelines/test_anti-uav_track1.py
```
**Note**: 
- The track1 dataset can be downloaded automatically.
- Set the dataset path (line 28) in test_anti-uav_track1.py
- **You can evaluation other model by setting model path (line 38) and model network architecture (line 11) in  modelscope/pipelines/cv/anti_uav_cvpr2023_pipeline.py**
- Submit track1.zip to [track1](https://codalab.lisn.upsaclay.fr/competitions/10176): cd results/SiamFC && zip track1.zip *


#### You will see following results (If IR_label.json is available):
```
[001/140]  20190925_131530_1_7    IR Fixed Measure: 0.245
[002/140]  20190925_213001_1_5    IR Fixed Measure: -0.164
[003/140]  20190925_222534_1_3    IR Fixed Measure: 0.800
[004/140]  20190926_183941_1_8    IR Fixed Measure: 0.754
...
[Overall]    IR Mixed Measure:
```

#### Evaluation code for track2
- Test SiamFC tracker and Yolov5 without initial target ground-truth box)
- Detect the initial state of target using yolov5 then track the target using SiamFC. (You can also use detectors and trackers together for localization.)
- Submit track2.zip to [track2](https://codalab.lisn.upsaclay.fr/competitions/10177): cd results/Yolo_SiamFC && zip track2.zip *



```python
cd CVPR_Anti_UAV
pip install -r yolov5/requirements.txt
python tests/pipelines/test_anti-uav_track2.py
```
**Note**: 
- The track2 dataset can be downloaded automatically.
- Set the dataset path (line 28) in test_anti-uav_track1.py
- **You can evaluation other model by setting model path (line 39) and model network architecture (line 12) in  modelscope/pipelines/cv/anti_uav_cvpr2023_pipeline.py**
