ResNet: Deep Residual Learning for Image Recognition
This is a pytorch implementation of ResNet for image classification by JeasunLok. If it is useful for you, please give me a star!
Besides, this is the repository of the Section V. of open course for "starting deep learning" of IMARS, School of Geography and Planning, Sun Yat-Sen University. For this open course, this repository aims at completing scene classification of Remote Sensing images.
Here is the video of how to use this repository in Chinese.
Create the environment and install the requirements.
git clone https://github.com/JeasunLok/ResNet-pytorch.git
conda create -n resnet python=3.9
conda activate resnet
pip install -r requirements.txt
If you want to use GPU, please check your CUDA version and download the proper version of pytorch. Use CUDA 12.1 as example:
nvidia-smi
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
The file cifar-10_unpack.py
provides the method of downloading cifar-10 dataset. So please run this file (maybe you should change the path and make sure it is correct) to get the cifar-10 dataset in dataset
folder. Besides, this file will split the dataset automatically.
Please download the dataset SIRI-WHU in http://www.lmars.whu.edu.cn/prof_web/zhongyanfei/e-code.html and place it in dataset
folder of the repository.
Then run the dataset_split.py
file to split the dataset into train, validate and test set with a proper ratio (3 ratio can be set in the file). You should change the parameter input folder
With your dataset SIRI-WHU downloading path.
Attention: pond 0002.tif is wrong and please delete it or replace it with a corret image with shape (200, 200, 3) or you can change the set the parameter IsResize=True
of image_transform in main.
- When the dataset is perpared and split correctly, you should revise the file
dataset/cls_classes.txt
with all classes of the dataset (cifar-10 and SIRI-WHU are both provided). - Place the
train
,val
andtest
folder with images underimages
folder. - Run the file of
dataset_create.py
to generate the train, validate and test list of your dataset underimages
folder. After that, you can seecls_train.txt
,cls_val.txt
andcls_test.txt
underimages
folder. - Revise and define your settings in
main.py
, all the settings can be revised in this file, including epoch, lr, batch size and so on. One thing should be noted that theinput_shape
parameter in main.py should be the same as the size of the images in the dataset. - Run the file of
main.py
to train, validate and test your model.
The repository is licensed under the Apache 2.0 license.