You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+13-3Lines changed: 13 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ This repository contains training scripts, helper utilities, inference scripts,
6
6
## Features
7
7
-**CycleGAN Architecture** - ResNet‑style "encoder-residual-decoder" generators and PatchGAN discriminators. In addition to adversarial loss, cycle‑consistency loss was used to preserve content/structure. Moreover, identity loss was added to preserve color and style of the original image.
8
8
-**Data Pipeline & Preprocessing** - deterministic train/val/test splits, on-the-fly augmentations, unpaired DataLoader that pairs Young (18–28) and Old (40+) faces at each batch.
9
-
-**Training Utilities & Efficiency** - gradient clipping to stabilize adversarial updates, separate generator/discriminator learning rates with linear decay for latter half of training, mixed precision via `accelerate` for 2× speed/memory improvements, and checkpoint archiving.
9
+
-**Training Utilities & Efficiency** - gradient clipping to stabilize adversarial updates, separate generator/discriminator learning rates with linear decay for latter half of training, mixed precision via `accelerate` for 2× speed/memory improvements, and checkpointing models with per-epoch generated sample images for evaluation.
10
10
-**Evaluation** - FID (Frechet Inception Distance) evaluation on validation and test splits.
11
11
-**Weights & Biases Logging** - track losses and metrics during training.
12
12
-**Inference Utilities** - command-line interface for image generation on user input.
@@ -37,14 +37,14 @@ This repository contains training scripts, helper utilities, inference scripts,
37
37
pip install -e .
38
38
```
39
39
40
-
## Data
40
+
## Data Preprocessing
41
41
We leverage the UTKFace dataset—a public collection of over 20,000 face images with age annotations (0–116), then use the aligned and cropped version for consistency. You can download from [here](https://www.kaggle.com/datasets/jangedoo/utkface-new).
42
42
43
43
Place your data on project root at:
44
44
> data/utkface_aligned_cropped/UTKFace
45
45
46
46
The prepare_dataset functionhandles:
47
-
- Age-based splits: thresholds at 18–28 for Young, 40+ for Old, ignoring mid-range ages.
47
+
- Age-based splits: thresholds at 18–28 for Young, 40+ for Old, ignoring mid-range ages. 7134 examples were filtered for each Young and Old pair. The reasoning behind removing children under age 18 was to help the model converge better as the facial shape often differs a lot between children and adults. It was observed that the model converges better when removing photos of babies that have much larger eye proportions and a rounder face.
48
48
- Deterministic shuffling: 80% train, 10% validation, 10% test with a fixed RNG seed.
49
49
- Augmentations (train only): random horizontal flips, resizing to img_size+50, center/random cropping to img_size, random rotations up to 80°, and normalization to [-1, 1].
50
50
- Evaluation transforms: resize → center crop → normalization (no randomness).
@@ -137,6 +137,16 @@ You can download this checkpoint model on [Releases](https://github.com/codingla
137
137
</tr>
138
138
</table>
139
139
140
+
### Considerations for Training and Improving Model
141
+
In the case you have time and resources to better train and improve the model, good points to start are...
142
+
143
+
- **Increase the dataset** size by adding not noisey and high quality data. The limit of the dataset was usually due to the lack of images for the Old group, so adding more images of older faces would certainly help.
144
+
- Consider using **various evaluation metrics**. There is often not always a best single metric to measure image quality for validation. Utilize other metrics such as KID (Kernel Inception Distance), which yield better results with small-sample behavior, or LPIPS (Learned Perceptual Image Patch Similarity) to measure how well your model preserves content or produces diverse outputs. Moreover, **qualitative human evaluation** on generated samples is good practice for these image generation models instead of relying on just metrics.
145
+
- Use a **small batch size**. I made the mistake in the beginning of aiming for a too high batch size for efficiency, but the discriminator easily memorized the training dataset. Lowering batch sizes to 1-16 are recommended, espeically if you have limited data. Also, you may consider adding gradient penalty or spetral normalization to hinder the discimrinator from memorization.
146
+
- Train for **more epochs**. Approach this with caution for GANs, as it might easily lead to overfitting. It is typical for the best models to be produced before training ends. Use your additional metrics as explained previously to choose the best checkpoint.
147
+
- If you really desire to output higher quality results, experiment with other **architectures** or strategies that often yield better results such as CAAE (Conditional Adversarial Autoencoders), StarGAN v2, or AttGAN.
148
+
- Extensive **hyperparameters sweeps** would also improve your hyperparameter choices, but may be computationally expensive and time consuming.
149
+
140
150
## Running the Gradio Inference App
141
151
This project includes an interactive Gradio app for making predictions with the trained model.
0 commit comments