Train Your Own AI Model

This should guide will show you how to create your own AI model that can be used in the Disco Diffusion AI Script. Before you begin, you will need a nvidia GPU with at least 16GB VRAM, at least 10GB available storage space, a reliable internet connection, and a set of training images. An image AI training set is any set of images, often thousands of them, you can use any images as long as they’re all PNGs. Whatever images you use is what the final result images will look more like. If you run into any errors while running this, post your question as a comment on this page, and I will try to help you solve it.

Instructions:

  1. Download the main code from here.
  2. Install VS code if you don’t already have it.
  3. Install python if it isn’t already installed.
  4. Unzip the folder you downloaded in step one and open it in VS code.
  5. Open a terminal in VS code by pressing ctrl+shift+`
  6. Download the requirements folder from here.
  7. Put that file into the main code folder.
  8. In the terminal you opened in VS code, type “pip install -r trainmodelrequirements.txt”
  9. Enter a command listed here based on your computer.
  10. Take your training images and put them into the images folder in the main code folder.
  11. In the terminal type “python train.py”
  12. That will run for a while (12 hours to a day, depending on your GPU).
  13. After it’s done, click the “DiscoDiffusion-Warp” folder to open it.
  14. Then click on the file called “DiscoDiffusion-Warp\Disco_Diffusion_v5_2_Warp_custom_model.ipynb” to open it.
  15. It should show up similar to how colab notebooks look, but in VS code.
  16. Run all the cells, and it will create an image using the AI model you trained.

If you have any questions or suggestions about this guide, feel free to comment on this page, or email me (eliso@botbox.dev).

13 Comments

  1. In step 9 What command are you refering to ?

  2. I also got this error
    Preparing metadata (setup.py) … error
    error: subprocess-exited-with-error

    × python setup.py egg_info did not run successfully.
    │ exit code: 1
    ╰─> [6 lines of output]
    Traceback (most recent call last):
    File “”, line 2, in
    File “”, line 34, in
    File “C:\Users\Mr Peculiar\AppData\Local\Temp\pip-install-hmrb5o5g\youtokentome_64ba4660c8a243a39c05d93dc64ee1fd\setup.py”, line 5, in
    from Cython.Build import cythonize
    ModuleNotFoundError: No module named ‘Cython’
    [end of output]

    note: This error originates from a subprocess, and is likely not a problem with pip.
    error: metadata-generation-failed

    × Encountered error while generating package metadata.
    ╰─> See above for output.

  3. Sorry to message again but im new to all this, everything is working until i go to train my model.

    Now the code says
    FileNotFoundError: [WinError 3] The system cannot find the path specified: ‘cd ./guided-diffusion-sxela’

    The folder is in the right place but for some reason it wont link to it.
    My train.py looks as follows

    import os
    os.system(“git clone https://github.com/Sxela/guided-diffusion-sxela“)
    os.chdir(“cd ./guided-diffusion-sxela”)
    os.system(“pip install -e .”)
    os.system(“cd ..”)
    os.system(“wget –no-check-certificate https://openaipublic.blob.core.windows.net/diffusion/march-2021/lsun_uncond_100M_1200K_bs128.pt“)
    MODEL_FLAGS=”–attention_resolutions 32,16,8 –class_cond False –diffusion_steps 1000 –image_size 256 –learn_sigma True –noise_schedule linear –num_channels 128 –num_heads 4 –num_res_blocks 2 –resblock_updown True –use_fp16 True –use_scale_shift_norm True”
    TRAIN_FLAGS=”–lr 2e-5 –batch_size 4 –save_interval 25000 –log_interval 1000 –max_steps 50000″
    DATASET_PATH=”./images/” #change to point to your dataset path
    CHECKPOINT_PATH=”./models/”
    os.environ[“OPENAI_LOGDIR”] = CHECKPOINT_PATH
    print(os.environ[“OPENAI_LOGDIR”])
    os.system(f”python guided-diffusion-sxela/scripts/image_train.py –data_dir {DATASET_PATH} {MODEL_FLAGS} {TRAIN_FLAGS}”)

  4. E:\AI training\trainAImodel

  5. Great guide!! Thank you so much.

    Maybe a newbie question, but how does the the training model associate the images with a text description that is tied to image generation via the prompts?

Leave a Comment

Your email address will not be published.