82 lines
2.0 KiB
Markdown
82 lines
2.0 KiB
Markdown
# Python venv
|
|
Start a python environment here in this directory
|
|
```py
|
|
python -m venv .
|
|
```
|
|
|
|
Then we start the env using
|
|
```py
|
|
source ./bin/activate
|
|
```
|
|
|
|
We can then install whats needed with `pip`. for exampe
|
|
we can put all dependencies in some text file. say dependencies.txt
|
|
```py
|
|
# pip install
|
|
# already added dependencies.txt
|
|
pip install -r dependencies.txt
|
|
|
|
```
|
|
|
|
Downloading the data from google drive was impossible. So Downloaded them manualy
|
|
and They need to be put in the a ./data directory
|
|
The download url was available in the error log.
|
|
`https://drive.google.com/uc?id=0B7EVK8r0v71pZjFTYXZWM3FlRnM`
|
|
this is the same location thats available in the official site
|
|
|
|
```
|
|
Root_dir/
|
|
└── data/
|
|
└── celeba/
|
|
├── img_align_celeba.zip
|
|
├── list_attr_celeba.txt
|
|
├── list_bbox_celeba.txt
|
|
├── list_eval_partition.txt
|
|
└── list_landmarks_align_celeba.txt
|
|
|
|
```
|
|
|
|
once this is manually done, We can run finetunning a selected model. For now, 4 models are implemented.
|
|
- ResNet-18
|
|
- ResNet-50
|
|
- DenseNet121
|
|
- Inception
|
|
|
|
## Fine tuning
|
|
### Preparation
|
|
|
|
Lets say we want to finetune **Inception**. In `Tune.py` we have to adjust the variables accordingly like so:
|
|
```py
|
|
# Set the class size. e.g
|
|
CLASS_SIZE = 50
|
|
# set the batch eg.
|
|
BATCH_SIZE = 16
|
|
# set the Tuning epochs. e.g
|
|
EPOCH = 20
|
|
# set the correct image size
|
|
# if ResNet or DenseNet, we set this to 224
|
|
RESOLUTION = 299
|
|
# set the model architecture
|
|
arch = Architecture.INCEPTION
|
|
```
|
|
Other variable that we can change are those that are related to data size. Namely Training sample size and full sample size.
|
|
```py
|
|
# full sample size per class
|
|
SAMPLE_SIZE = 30
|
|
|
|
# Training sample size is then (full_sample - test_sample)
|
|
TRAINING_SMPLE = 28
|
|
|
|
# while at it, we can also set the learning rate
|
|
LR_RATE = 0.0001
|
|
```
|
|
|
|
|
|
### Rune the process
|
|
After we have set all necessary variables to our liking, we run the process by running Tune.py with python interpreter
|
|
```shell
|
|
# open terminal, cd to project root and run
|
|
python Tune.py
|
|
```
|
|
|