{"id":28354271,"url":"https://github.com/soroushesnaashari/anime-faces-generator-with-gan-using-tensorflow","last_synced_at":"2025-10-06T13:48:48.018Z","repository":{"id":295247628,"uuid":"987510774","full_name":"soroushesnaashari/Anime-Faces-Generator-with-GAN-using-TensorFlow","owner":"soroushesnaashari","description":"A GAN project using \"TensorFlow\" creating model to generate new random Anime faces","archived":false,"fork":false,"pushed_at":"2025-06-12T07:12:56.000Z","size":16510,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-21T22:36:45.896Z","etag":null,"topics":["deep-learning","gan","neural-network","tensorflow"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/soroushesnaashari.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-21T07:21:21.000Z","updated_at":"2025-06-17T08:30:24.000Z","dependencies_parsed_at":"2025-05-24T13:47:19.915Z","dependency_job_id":null,"html_url":"https://github.com/soroushesnaashari/Anime-Faces-Generator-with-GAN-using-TensorFlow","commit_stats":null,"previous_names":["soroushesnaashari/anime-faces-generator-with-gan-using-tensorflow"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/soroushesnaashari/Anime-Faces-Generator-with-GAN-using-TensorFlow","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soroushesnaashari%2FAnime-Faces-Generator-with-GAN-using-TensorFlow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soroushesnaashari%2FAnime-Faces-Generator-with-GAN-using-TensorFlow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soroushesnaashari%2FAnime-Faces-Generator-with-GAN-using-TensorFlow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soroushesnaashari%2FAnime-Faces-Generator-with-GAN-using-TensorFlow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/soroushesnaashari","download_url":"https://codeload.github.com/soroushesnaashari/Anime-Faces-Generator-with-GAN-using-TensorFlow/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soroushesnaashari%2FAnime-Faces-Generator-with-GAN-using-TensorFlow/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278621840,"owners_count":26017253,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-06T02:00:05.630Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deep-learning","gan","neural-network","tensorflow"],"created_at":"2025-05-28T02:11:06.759Z","updated_at":"2025-10-06T13:48:48.013Z","avatar_url":"https://github.com/soroushesnaashari.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Anime Faces Generator with GAN using TensorFlow\n[![](images/Image.gif)](https://www.kaggle.com/code/soroushesnaashari/anime-faces-generator-gan-using-tensorflow/output)\n\n### Overview\n\nThis project implements a Deep Convolutional Generative Adversarial Network (DCGAN) in TensorFlow/Keras to generate anime-style faces. By training on a curated dataset of ~21 k anime character portraits (cropped and resized to 64×64 px), the GAN learns to map a 100-dimensional latent vector to realistic-looking anime faces. The entire pipeline, from data ingestion through model definition, training, and image sampling—is contained in this repository.\n\n\u003cbr\u003e\n\n### Project Flow\n\n1. **Data Preparation**  \n   - Download anime face images (21 551 samples) from the “Anime Faces” dataset.  \n   - Crop to facial regions and resize all images to 64×64 pixels.  \n   - Normalize pixel values to \\[-1, +1\\] for GAN training.\n\n2. **Model Definition**  \n   - **Generator:**  \n     - Input: 100-dimensional noise vector.  \n     - Upsampling path: series of `Conv2DTranspose` layers with increasing spatial resolution (4→8→16→32→64), each followed by BatchNorm + ReLU, ending in a 64×64×3 `tanh` output.  \n   - **Discriminator:**  \n     - Input: 64×64×3 image.  \n     - Downsampling path: series of `Conv2D` layers with LeakyReLU activations and Dropout, reducing to a single scalar probability via a final dense layer with `sigmoid`.\n\n3. **Training Loop**  \n   - Batch size: 256  \n   - Latent dimension: 100  \n   - Optimizer: Adam (learning rate 2e-4, β₁ = 0.5)  \n   - Number of epochs: 50  \n   - At each step:  \n     1. Sample a batch of real anime faces and a batch of random noise.  \n     2. Update the discriminator on real vs. generated (“fake”) images.  \n     3. Update the generator via its ability to fool the discriminator.  \n   - Periodically save checkpointed model weights and sample grids of generated faces.\n\n4. **Sampling \u0026 Visualization**  \n   - After every N epochs (e.g. 5), generate a 5×5 grid of new faces from fixed noise vectors.  \n   - Plot and save loss curves for both generator and discriminator.\n\n\u003cbr\u003e\n\n### Key Features\n\n- **Custom DCGAN Architecture**  \n  Lightweight yet expressive convolutional generator and discriminator networks tailored for 64×64 anime faces.\n\n- **TensorFlow 2.x / Keras**  \n  Leverages the `tf.GradientTape` API for full control over training; easily extensible.\n\n- **Flexible Hyperparameters**  \n  Easily adjust latent dimension, batch size, learning rates, and number of epochs via the configuration section.\n\n- **Built-in Visualization**  \n  Automatic generation of sample image grids and loss plots to monitor training progress.\n\n- **Checkpoints \u0026 Resume**  \n  Save and load model weights to resume long-running training jobs.\n\n\u003cbr\u003e\n\n### Results\n\nAfter 50 epochs of training:\n\n- The generator produces high-quality anime faces with coherent hair styles, facial features, and coloring.\n- Sample outputs (5×5 grid at epochs 5, 15, 30):  \n  ![Samples @ Ep 5](images/epoch05.png)  \n  ![Samples @ Ep 15](images/epoch15.png)  \n  ![Samples @ Ep 30](images/epoch30.png)\n- After 50 epoches the model generated some acceptable anime characters (bottom image) which can be improved a lot with some more profeesional GAN model and also with more epoches.\n  ![Fresh image](images/fresh.png)\n\n\u003cbr\u003e\n\n### Repository Contents\n- **`anime-faces-generator-gan-using-tensorflow.ipynb`**: Jupyter Notebook with full code, visualizations and explanations.\n- **`Data`:** Contains the [Original Dataset](https://www.kaggle.com/datasets/splcher/animefacedataset) and you can see the cleaned dataset in notebook.\n- **`README.md`:** Project documentation.\n\n\u003cbr\u003e\n\n### How to Contribute\nContributions are welcome! If you'd like to improve the project or add new features:\n\n1. **Fork the repository.**\n2. **Create a new branch.**\n3. **Make your changes and submit a pull request.**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoroushesnaashari%2Fanime-faces-generator-with-gan-using-tensorflow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoroushesnaashari%2Fanime-faces-generator-with-gan-using-tensorflow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoroushesnaashari%2Fanime-faces-generator-with-gan-using-tensorflow/lists"}