《人工智能A》课程PJ,搭配使用数据增强达到deit_small上的较高的图像分类准确率
Our code base is developed and tested with PyTorch 1.7.0, TorchVision 0.8.1, CUDA 10.2, and Python 3.7.
conda create -n baseline python=3.7 -y
conda activate baseline
conda install pytorch==1.7.0 torchvision==0.8.1 cudatoolkit=10.2 -c pytorch
pip install -r requirements.txt
Loading pre-trained weights is allowed. You can use the pre-trained model under ImageNet-1k, while other datasets like ImageNet-21k, CC3M, LAION, etc., are not allowed.
Five datasets are given in /remote-home/share/course23
, which include:
'10shot_cifar100_20200721','10shot_country211_20210924','10shot_food_101_20211007','10shot_oxford_iiit_pets_20211007','10shot_stanford_cars_20211007'
The executable pretrained models are offered by timm
. You can check and use the offered pretrained timm models.
python main.py --model $selected_model --batch-size 64 --data-path $path_to_dataset --output_dir output/$selected_model --epochs 50 --lr 1e-4 --weight-decay 0.01
There are three modes to execute the code.
- Operate on individual dataset seperately. You can change
--dataset_list
to achieve it. - Operate on known datasets. The dataset which given images belong to will be offered. You can check the
--known_data_source
option. - Operate on unknown datasets. The dataset which given image belong to will not be offered. You should predict both datasets that images belong to and images' corresponding labels. You can check the
--unknown_data_source
option.
After obtaining the checkpoint of certain modes, you should operate --test_only
to produce a prediction json file pred_all.json
. The file will be produced under your output directory.
python main.py --model $selected_model --batch-size 64 --data-path $path_to_dataset --output_dir output/$selected_model --epochs 50 --lr 1e-4 --weight-decay 0.01 --test_only --resume /path/of/your/trained/model
You should submit a zip file containing the pred_all.json
file into the colab websit.