Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pvt medium #292

Merged
merged 3 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions cv/classification/pvt_medium/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
## PVT_medium

### Installation
- Install the latest version of OneFlow
```bash
python3 -m pip install oneflow -f https://staging.oneflow.info/branch/master/[PLATFORM]
```
Find more information on [install oneflow](https://github.com/Oneflow-Inc/oneflow#install-oneflow)

- Install flowvision

Then install the latest stable release of flowvision

```bash
pip install flowvision==0.2.1
```

- Install other requirements
```bash
python3 -m pip install -r requirements.txt
```

### Dataset
#### ImageNet
For ImageNet dataset, you can download it from http://image-net.org/. We provide the following two ways to load data:

- For standard folder dataset, move validation images to labeled sub-folders. The file structure should look like:
```bash
$ tree data
imagenet
├── train
│ ├── class1
│ │ ├── img1.jpeg
│ │ ├── img2.jpeg
│ │ └── ...
│ ├── class2
│ │ ├── img3.jpeg
│ │ └── ...
│ └── ...
└── val
├── class1
│ ├── img4.jpeg
│ ├── img5.jpeg
│ └── ...
├── class2
│ ├── img6.jpeg
│ └── ...
└── ...


### Training

You can use bash script `train.sh` to train this model.

```bash
sh train.sh
```

### inference

Bash script `infer.sh` is used to infer the trained model.

```bash
sh infer.sh
```

1 change: 1 addition & 0 deletions cv/classification/pvt_medium/config.py
1 change: 1 addition & 0 deletions cv/classification/pvt_medium/configs
1 change: 1 addition & 0 deletions cv/classification/pvt_medium/data
16 changes: 16 additions & 0 deletions cv/classification/pvt_medium/infer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export PYTHONPATH=$PWD:$PYTHONPATH
set -aux

GPU_NUMS=1
PORT=12346
MODEL_ARCH="pvt_medium"

python3 -m oneflow.distributed.launch \
--nproc_per_node $GPU_NUMS \
--master_addr 127.0.0.1 \
--master_port $PORT \
main.py \
--cfg configs/default_settings.yaml \
--model_arch $MODEL_ARCH \
--throughput

1 change: 1 addition & 0 deletions cv/classification/pvt_medium/logger.py
1 change: 1 addition & 0 deletions cv/classification/pvt_medium/lr_scheduler.py
1 change: 1 addition & 0 deletions cv/classification/pvt_medium/main.py
1 change: 1 addition & 0 deletions cv/classification/pvt_medium/optimizer.py
1 change: 1 addition & 0 deletions cv/classification/pvt_medium/requirements.txt
20 changes: 20 additions & 0 deletions cv/classification/pvt_medium/train.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export PYTHONPATH=$PWD:$PYTHONPATH
set -aux

GPU_NUMS=4
PORT=12346
MODEL_ARCH="pvt_medium"
BATCH_SIZE=32
LEARNING_RATE=1e-4

python3 -m oneflow.distributed.launch \
--nproc_per_node $GPU_NUMS \
--master_addr 127.0.0.1 \
--master_port $PORT \
main.py \
--cfg configs/default_settings.yaml \
--model_arch $MODEL_ARCH \
--batch-size $BATCH_SIZE \
--lr $LEARNING_RATE


1 change: 1 addition & 0 deletions cv/classification/pvt_medium/utils.py