pretrain-finetuning
COMP3340 Group 10 - Pretrain-finetuning part implemented by Alex.
Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (12.9%) to scientific vocabulary
Repository
COMP3340 Group 10 - Pretrain-finetuning part implemented by Alex.
Basic Info
- Host: GitHub
- Owner: COMP3340-2024-GP11
- License: apache-2.0
- Language: Jupyter Notebook
- Default Branch: main
- Size: 4.81 MB
Statistics
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
- Releases: 0
Metadata Files
README.md
COMP3340 Group 10 - Pre-training
Contact
This repository contains code for various pre-training methods on COMP3340 course project CNN flower classification
For any question and enquiry, please feel free to reach out to HU Zhongyu (hzyalex@connect.hku.hk)
Thanks and enjoy =P
Overview
Prerequisite for Reproduction
Software, Hardware & System Requirements
Software
Set up environment as following
python==3.8.18
mmfewshot==0.1.0
mmdet==2.17.0
mmcv==1.3.14
Hardware
Experiments are conducted on one NVIDIA GeForce RTX 2080 Ti
System
Linux
Note
One model training typically takes 6-7 hours to run with one NVIDIA GeForce RTX 2080 Ti.
Environment setup
Basic Setup (Also required by some other Group 10 repos)
Step 1. Create virtual environment using anaconda
```
conda create -n open-mmlab python=3.8 -y
conda activate open-mmlab
```
Please make sure that you are create a virtual env with python version 3.8
Step 2 Install Pytorch from wheel
```
wget https://download.pytorch.org/whl/cu110/torch-1.7.1%2Bcu110-cp38-cp38-linuxx8664.whl#sha256=709cec07bb34735bcf49ad1d631e4d90d29fa56fe23ac9768089c854367a1ac9
pip install torch-1.7.1+cu110-cp38-cp38-linuxx8664.whl
```
Please double check that you install the correct version of pytorch using the following command

Step 3 Install cudatoolkit via conda-forge channel
You must be on the GPU compute node to install cudatoolkit and mmcv since GCC compiler and CUDA drivers only available on GPU computing nodes
```
gpu-interactive
conda activate open-mmlab
conda install -c conda-forge cudatoolkit=11.0
```
Step 4 Install torchvision, mmcv-full and mmcls package using pip
Make sure you are on GPU compute node!!
-
gpu-interactive
Make sure you did not previously installed any relevant package
Following pip show command show output a message like "no such package found"
```
pip show torchvision
pip show mmcv
pip show mmcv-full
pip show mmcls
```
remove pip cache
```
pip cache remove torchvision
pip cache remove mmcv
pip cache remove mmcv-full
pip cache remove mmcls
```
install packages
```
pip install torchvision==0.8.2
pip install mmcv-full==1.3.14 -f https://download.openmmlab.com/mmcv/dist/cu110/torch1.7.0/index.html
```
install mmclassification (mmcls-0.x)
git clone https://github.com/open-mmlab/mmclassification.git
cd mmclassification
pip install -v -e .
check installation
python demo/imagedemo.py demo/demo.JPEG resnet188xb32_in1k --device cpu
Download data & checkpoints
Contains:
Oxford-17 Flower Dataset
Oxford-102 Flower Dataset
Various saved trained model (as .pth checkpoint files) and training logs
Open-source pretrained model checkpoints
Move data to right place
Download and unzip the "data" folder
Move everything inside the "data" folder under mmclassification/data
Move checkpoints to right place
Download and unzip the "output_pretrain" folder
Move everything inside into "mmclassification/output"
Download and unzip the "pretrain_checkpoint" folder
Move everything inside into "mmclassification/resources" folder
Train & test
how to train
python tools/train.py --config [CONFIG FILE PATH] --work-dir [OUTPUT DIRECTORY PATH]
how to test
python tools/test.py --config [CONFIG FILE PATH] --checkpoint [.pth CHECKPOINT FILE PATH] --out [OUTPUT TEXT FILE PATH]
How to reproduce & evaluate our experiments
If you want to reproduce our experiment, just plug config file path and output directory path into the train command above
If you want to test trained model, just plug config file path and output directory path + "/latest.pth" into the test command above.
Also, corresponding training log files are inside the output folders
- Baseline: ResNet18, train from scratch for 200 epochs on oxford flower 17 dataset
config file: mmclassification/configs/resnet/resnet18flowersbs128.py
output directory:mmclassification/output/resnet18flowersbs128
- Finetune ResNet18 (pretrained on imagenet1k) on oxford flower 17
config:
mmclassification/configs/resnet/resnet18flowersfinetune.py
output:
mmclassification/output/resnet18flowerpretrainmodifiedparameter
- Finetune ResNet18 (pretrained on cifar10) on oxford flower 17
config: mmclassification/configs/resnet/resnet18flowersfinetune_cifar10.py
output:
mmclassification/output/resnet18pretraincifar10
- ResNet50 trained from scratch on oxford flower 17
config:
mmclassification/configs/resnet/resnet50_flowers.py
output:
mmclassification/output/resnet50
- Finetune ResNet50 (pretrained on cifar10) on oxford flower 17
config:
mmclassification/configs/resnet/resnet50flowersfinetune_cifar10.py
output:
mmclassification/output/resnet50flowercifar10
- Finetune ResNet50 (pretrained on cifar100) on oxford flower 17
config:
mmclassification/configs/resnet/resnet50flowersfinetune_cifar100.py
output:
mmclassification/output/resnet50flowercifar100
- Finetune ResNet50 (pretrained on imagenet1k) on oxford flower 17
config:
mmclassification/configs/resnet/resnet50flowersimagenet1k.py
output:
mmclassification/output/resnet50flowerimagenet1k
- Finetune ResNet50 (pretrained on imagenet21k) on oxford flower 17
config:
mmclassification/configs/resnet/resnet50flowersimagenet21k.py
output:
mmclassification/output/resnet50flowerimagenet21k
- ResNet152 trained from scratch on oxford flower 17
config:
mmclassification/configs/resnet/resnet152_flowers.py
output:
mmclassification/output/resnet152
- Finetune ResNet152 (pretrained on cifar10) on oxford flower 17
config:
mmclassification/configs/resnet/resnet152flowersfinetune_cifar10.py
output:
mmclassification/output/resnet152flowercifar10
Owner
- Name: COMP3340 Group 10
- Login: COMP3340-2024-GP11
- Kind: organization
- Repositories: 1
- Profile: https://github.com/COMP3340-2024-GP11
HKU COMP3340 Group 10 (2023-24 Second Semester)
Citation (CITATION.cff)
cff-version: 1.2.0 message: "If you use this software, please cite it as below." title: "OpenMMLab's Image Classification Toolbox and Benchmark" authors: - name: "MMClassification Contributors" version: 0.15.0 date-released: 2020-07-09 repository-code: "https://github.com/open-mmlab/mmclassification" license: Apache-2.0
GitHub Events
Total
Last Year
Dependencies
- actions/checkout v2 composite
- actions/setup-python v1 composite
- actions/setup-python v2 composite
- codecov/codecov-action v1.0.10 composite
- actions/checkout v2 composite
- actions/setup-python v2 composite
- pytorch/pytorch ${PYTORCH}-cuda${CUDA}-cudnn${CUDNN}-devel build
- pytorch/pytorch ${PYTORCH}-cuda${CUDA}-cudnn${CUDNN}-devel build
- docutils ==0.16.0
- recommonmark *
- sphinx ==4.0.2
- sphinx_markdown_tables *
- sphinx_rtd_theme ==0.5.2
- mmcv-full >=1.3.8,<=1.5.0
- albumentations >=0.3.2
- mmcv >=1.3.8
- torch *
- torchvision *
- matplotlib *
- numpy *
- codecov * test
- flake8 * test
- interrogate * test
- isort ==4.3.21 test
- mmdet * test
- pytest * test
- xdoctest >=0.10.0 test
- yapf * test