Skip to content

Commit

Permalink
Update setup instructions & reqs
Browse files Browse the repository at this point in the history
  • Loading branch information
SamSamhuns committed Feb 26, 2024
1 parent 6ac383a commit d72b6c1
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ 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

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

```shell
Expand All @@ -27,8 +29,18 @@ 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

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

## Conver 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)

## Train an adversarial patch against the detector

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

```shell
python train_patch.py --cfg adv_patch_gen/configs/base.json
```
Expand Down
22 changes: 12 additions & 10 deletions adv_patch_gen/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
# Installing additional requirements

To setup pycocotools:

```bash
pip install Cython
sudo apt-get install python3.8-dev # or any desired python version
pip install pycocotools # https://github.com/ppwwyyxx/cocoapi
# pip install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI # depreciated
```

## Convert YOLO annotation to COCO annotation

Refer to <https://github.com/SamSamhuns/ml_data_processing/tree/master/annotation_format_conv>
Expand All @@ -31,4 +22,15 @@ mkdir -p "$(pwd)"/data

```shell
t=yolov5_adversarial:latest && docker run -ti --rm --gpus device=0 -v "$(pwd)"/data:/home/user1/app/data -v "$(pwd)"/runs:/home/user1/app/runs $t bash
``
```

#### Notes on requirements for pycocotools setup:

If the `pip install -r requirements.txt` is not working.

```bash
pip install Cython
sudo apt-get install python3.8-dev # or any desired python version
pip install pycocotools # https://github.com/ppwwyyxx/cocoapi
# pip install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI # depreciated
```
1 change: 1 addition & 0 deletions adv_patch_gen/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# specific to adv_patch_gen, yolov5 base requirements should be installed as well
Cython==3.0.8
easydict==1.12
pycocotools==2.0.6
tensorboard==2.16.2
2 changes: 1 addition & 1 deletion train_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from torch.cuda.amp import autocast
from torchvision import transforms as T

from tensorboardX import SummaryWriter
from torch.utils.tensorboard import SummaryWriter
from tensorboard import program

from models.common import DetectMultiBackend
Expand Down

0 comments on commit d72b6c1

Please sign in to comment.