/anime-diffusion

Primary LanguageJupyter Notebook

ETHz

Welcome to the ETH Zurich Hackathon 2023, this repository contains the code and instructions for the hackathon.

Getting Started

  • Clone this repository
  • Choose a Machine with PyTorch preinstalled on JarvisLabs.
  • Install the requirements: pip install -r requirements.txt

You will need master dev version of diffusers (we are doing bleeding edge stuff here šŸ¤£)

git clone https://github.com/huggingface/diffusers
cd diffusers
pip install -e .

Creating a Dataset

To construct a dataset you will need to download images form the internet. Consider using a scraper like:

LoRA

We will mainly be using this: https://huggingface.co/blog/lora You have two options to train your LoRA:

Pure LoRA:

Using LoRA's training script, you will need an annotated dataset for that. LoRA is fast but requires you to annotate a dataset.

The training script is in this repo, and it's just a modified version of the one in the blog post. You can define the variables as environment variables or pass them as arguments to the script.

accelerate launch train_text_to_image_lora.py
  • The other one is using Dreambooth-Lora, you will need a dataset of images without tags for that. The quality here is not as good as the one from the training script, but it's much faster to train. The training script is in this repo, and it's just a modified version of the one in the blog post.
accelerate launch train_dreambooth_lora.py

I changed some defaults and added a few more options to the script, you can see them by running python train_lora.py --help

Models

There are multiple models trained on Anime/Cartoon/drawings out there, this is a good model to start from

  • Waifu Diffusion
  • I also like the runwayml/stable-diffusion-v1-5 model, but it is not as good as the one above as it's trained on more artisitc images instead of anime/cartoon/drawings.

Resources