Git Product home page Git Product logo

msai-celeba-attributes-prediction's Introduction

[MSAI Advanced Computer Vision Course Project]

Description

CelebA face attributes prediction using Large-scale CelebFaces Attributes (CelebA) Dataset

The model is based on pretrained Resnet18 + 1fc layer.

Requirements

  • Anaconda3
  • Pytorch
  • Torchvision

Data

  • Training, validation and test data in .jpg format is downloaded from here into img_align_celeba folder for the training, the dataloader in utils.py will load the datasets according to the annotations files.
  • Private unlabelled dataset is downloaded from here into 'test_data/imgae_folder' for labelling.
  • Data augmentation(random rotation, flip, >0.8 scale crop) is performed

Files

├── My\ acv\ project.ipynb  #illustration file for code preparation
├── README.md
├── annotations
│   ├── test_attr_list.txt
│   ├── train_attr_list.txt
│   └── val_attr_list.txt
├── celeba.py        #CelebA dataset class
├── checkpoints
│   └── checkpoint_best.pth
├── img_align_celeba        #cropped and aligned jpg dataset
├── log.txt          #accuracy log for 20epoches, the lr displayed is the initial setting
├── loss.py          #focal loss
├── main.py
├── normalize.py     #compute train datasets mean and std
├── test_data
│   └── 13233_imgs        #unlabelled test data
└── utils.py 

Running the codes

  • Restart model training (pretrained Resnet18 finetuning) for 20 epoches:
python main.py --train_conv --batch_size=512 --epoches=20 --lr=0.1 --checkpoint='checkpoint_best.pth' --root='current directory'
  • Resume model training for another 20 epoches:
python main.py --train_conv --batch_size=512 --epoches=20 --lr=0.1 --checkpoint='checkpoint_best.pth'  --resume --root='current directory'
  • Retrieve test accuracy of lastest trained model:
python main.py --batch_size=512 --checkpoint='checkpoint_best.pth'  --test-mode --root='current directory'
  • Make predictions for the unlabelled data into predictions.txt:
python main.py --batch_size=512 --checkpoint='checkpoint_best.pth'  --test-unlabelled --root='current directory'

Results

After running the model with the selected hyperparameters on the total dataset for 20 epochs, the resulting average validation accuracy is 91.8% and average test accuracy is 91.4%.

The test accuracies for 40 attributes is as below: [0.9482, 0.8340, 0.8293, 0.8538, 0.9893, 0.9600, 0.7152, 0.8398, 0.9002, 0.9596, 0.9632, 0.8904, 0.9260, 0.9589, 0.9639, 0.9962, 0.9744, 0.9833, 0.9184, 0.8758, 0.9813, 0.9377, 0.9696, 0.8766, 0.9619, 0.7556, 0.9706, 0.7684, 0.9381, 0.9504, 0.9775, 0.9283, 0.8448, 0.8488, 0.9031, 0.9904, 0.9385, 0.8739, 0.9682, 0.8886]

Among test accuracies for 40 attributes, the minimum accuracy is 71.5% for attribute 7 and the maximum accuracy is 99.6% for attribute 16. Details can refer to log.txt

Readings

msai-celeba-attributes-prediction's People

Contributors

bamboopalace avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.