Skip to content

Commit

Permalink
FIx cfg weight path & add more info
Browse files Browse the repository at this point in the history
  • Loading branch information
SamSamhuns committed May 19, 2024
1 parent e80dcd3 commit 34f2ae1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ https://github.com/SamSamhuns/yolov5_adversarial/assets/13418507/b389449f-98a4-4
| :----------------------------------------------------------: | :--------------------------------------------------------: |
| <img src="adv_patch_gen/media/visdrone_p.png" width="256" /> | <img src="adv_patch_gen/media/custom_p.png" width="256" /> |

## Setup
## 1. Setup

Note: Install all required dependencies as mentioned in the main YOLOv5 repository and install additional yolov5 adversarial dependency as follows:

Expand All @@ -29,23 +29,26 @@ pip install -r adv_patch_gen/requirements.txt

Detailed instructions for setup and docker use at [adv_patch_gen/README.md](adv_patch_gen/README.md)

## Download VisDrone Dataset
## 2. Download VisDrone Dataset

Download Task 1 trainset, valset, and testset-dev sets from <https://github.com/VisDrone/VisDrone-Dataset>. Place data under `data/visdrone_data`.

## Convert VisDrone Dataset to YOLO format
## 3. Convert VisDrone Dataset to YOLO format

Refer to [adv_patch_gen/conv_visdrone_2_yolo/README.md](adv_patch_gen/conv_visdrone_2_yolo/README.md)

## Download YOLOv5 4 Class (Car,Van,Truck,Bus) detection weights trained on VisDrone-2019
## 4. Download YOLOv5 4 Class (Car,Van,Truck,Bus) detection weights trained on VisDrone-2019

```shell
# inside a python virtual environment
pip install gdown
gdown 1Nw71j_zw_TUrXjR6VRvgp5wJmDePZMoS
# unzip models into runs/train directory
mkdir -p runs/train
unzip coco_e300_4Class_Vehicle.zip -d runs/train
```

## Train an adversarial patch against the detector
## 5. Train an adversarial patch against the detector

Dataset paths should be correctly set in the config json file.

Expand All @@ -55,7 +58,7 @@ python train_patch.py --cfg adv_patch_gen/configs/base.json

Instructions in creating the config json file present at [adv_patch_gen/configs/README.md](adv_patch_gen/configs/README.md).

## Test the performance of the adversarial patch
## 6. Test the performance of the adversarial patch

```shell
python test_patch.py --cfg CONFIG_JSON_FILE -w YOLOV5_TARGET_MODEL_WEIGHTS_PATH -p PATCH_IMG_FILE_PATH --id IMG_DIR_PATH_FOR_TESTING --sd SAVE_DIR_PATH
Expand Down
8 changes: 4 additions & 4 deletions adv_patch_gen/configs/base.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"image_dir": "data/visdrone_data/Custom_4Class_labels_vehicles/VisDrone2019-DET-train/images",
"label_dir": "data/visdrone_data/Custom_4Class_labels_vehicles/VisDrone2019-DET-train/labels",
"val_image_dir": "data/visdrone_data/Custom_4Class_labels_vehicles/VisDrone2019-DET-val/images",
"image_dir": "data/visdrone_data/VisDrone2019-DET-train/images",
"label_dir": "data/visdrone_data/VisDrone2019-DET-train/labels",
"val_image_dir": "data/visdrone_data/VisDrone2019-DET-val/images",
"use_even_odd_images": "all",
"log_dir": "runs/train_adversarial",
"tensorboard_port": 8994,
"tensorboard_batch_log_interval": 15,
"weights_file": "runs/train/s_coco_e100_4Class_Vehicle/weights/best.pt",
"weights_file": "runs/train/s_coco_e300_4Class_Vehicle/weights/best.pt",
"triplet_printfile": "adv_patch_gen/utils/30_rgb_triplets.csv",
"device": "cuda:0",
"use_amp": true,
Expand Down
4 changes: 2 additions & 2 deletions adv_patch_gen/conv_visdrone_2_yolo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ Tested with python 3.8
```shell
python -m venv venv
source venv/bin/activate
pip install tqdm==4.65.0
pip install tqdm==4.66.4
pip install imagesize==1.4.1
pip install opencv-python==4.7.0.72
pip install opencv-python==4.9.0.80
```

## VisDrone Dataset Format
Expand Down

0 comments on commit 34f2ae1

Please sign in to comment.