Deep Learning for Computer Vision final project
Team: DLCV1
Member & Contribution:
- 林彥廷 (R06943184): 主程式撰寫、模型訓練 (50%)
- 王擎天 (R06945055): 副程式撰寫、模型訓練、海報設計 (50%)
Overview:
This project contains code to predict image's type from different domain using moment matching.
Description:
Folders:
- script: folder contains scripts
- src: folder contains source code
- model: folder contains saved models which automatically download from network
Files:
- script/get_dataset.sh: script which downloads training and testing dataset
- script/download_from_gdrive.sh: script which downloads googledrive data
- script/parse_data.sh: script which loads training dataset and converts to torch dataset
- script/predict.sh: script which predicts images
- script/evaluate.sh: script which evaluates the model
- script/predict_for_verify.sh script which generates mini-batch average validation accuracy and loss plot
- src/models/classifier.py: classifier model
- src/models/loss.py: loss function
- src/models/pretrained.py: pretrained model
- src/models/model.py: Model and function for prediction and evaluation
- src/parse_data.py: load data in folder and convert them to torch dataset
- src/predict.py: prediction main function
- src/evaluate.py: evaluation main function
- src/train.py: training function
- src/utils.py: code for parsing and saving
- src/util/dataset.py: customized dataloader
- src/util/visual.py: code for visualization
- src/create_path_csv.py:main function to create image path csv file for image folder
Dataset:
Download training and testing dataset to folder named "dataset_public":
bash ./script/get_dataset.sh
WARNING:
You MUST use src/create_path_csv.py to create image-path csv file for image folder which hasn't contain image-path csv file, the usage will teach you how to use it!!! |
---|
Usage:
Create image-path csv file for image folder:
User can use this script to create image-path csv file
python3 src/create_path_csv.py $1
$1
is the folder containing the images
Example: (path: /home/final-dlcv1)
python3 src/create_path_csv.py dataset_public/test
The result will look like following text: image_name,label test/018764.jpg,-1 test/034458.jpg,-1 test/050001.jpg,-1 test/027193.jpg,-1 test/002637.jpg,-1 test/017265.jpg,-1 test/048396.jpg,-1 test/013178.jpg,-1 test/036777.jpg,-1 ......
Predict labels of images:
User can use this script to predict labels of images
bash ./script/predict.sh $1 $2 $3 $4 $5
$1
is the domain of images (Option: infograph, quickdraw, real, sketch)$2
is the folder containing the images$3
is the csv file contains image paths$4
is the folder to saved the result file$5
is the batch size
Example 1: Predict images from real domain (path: /home/final-dlcv1)
bash script/predict.sh real dataset_public dataset_public/test/image_path.csv predict 256
Example 2: Predict images from sketch domain (path: /home/final-dlcv1)
bash script/predict.sh sketch dataset_public dataset_public/sketch/sketch_test.csv predict 256
Example 3: Predict images from infograph domain (path: /home/final-dlcv1)
bash script/predict.sh infograph dataset_public dataset_public/infograph/infograph_test.csv predict 256
Example 4: Predict images from quickdraw domain (path: /home/final-dlcv1)
bash script/predict.sh quickdraw dataset_public dataset_public/quickdraw/quickdraw_test.csv predict 256
Evaluate the result file:
User can use this script to evaluate the reuslt file with answer file, it will print result on the screen
bash ./script/evaluate.sh $1 $2
$1
is the predicted file csv$2
is the answer file csv
Example (path:/home/final-dlcv1)
bash ./script/evaluate.sh predict/real_predict.csv test/test_answer.csv
Reference
- https://gntuedutw-my.sharepoint.com/:p:/g/personal/b03901093_g_ntu_edu_tw/EUuiRqkxp69GjGDOzVcJeHoBIY61MIbEEbBVsMgNBfcEBg?rtime=uLaDbmDq1kg
- Peng, X., Bai, Q., Xia, X., Huang, Z., Saenko, K. and Wang, B., 2018. Moment Matching for Multi-Source Domain Adaptation. arXiv preprint arXiv:1812.01754.