sd_dreambooth_extension icon indicating copy to clipboard operation
sd_dreambooth_extension copied to clipboard

Stop train text encoder after a certain percentage of steps.

Open OrochiZ opened this issue 2 years ago • 3 comments

WHAT What is this feature of which you speak??

Stop text training after a certain percentage of steps. Keep the % low for better style transfer, more training steps will be necessary for good results. Higher % will give more weight to the instance, it gives stronger results at lower steps count, but harder to stylize,

WHERE From whence did you hear this news?? Provide a URL if possible.

https://github.com/TheLastBen/fast-stable-diffusion https://colab.research.google.com/github/TheLastBen/fast-stable-diffusion/blob/main/fast-DreamBooth.ipynb

HOW I suppose that could be the same as where if you have a URL, but if there's an example, hook me up.

in https://colab.research.google.com/github/TheLastBen/fast-stable-diffusion/blob/main/fast-DreamBooth.ipynb

if Train_text_encoder_for>=100: stptxt=Training_Steps elif Train_text_encoder_for==0: Enable_text_encoder_training= False stptxt=10 else: stptxt=int((Training_Steps*Train_text_encoder_for)/100)

... ...

!accelerate launch /content/diffusers/examples/dreambooth/train_dreambooth.py
$Caption
$Textenc
--save_starting_step=$stpsv
--stop_text_encoder_training=$stptxt


in https://github.com/TheLastBen/diffusers/blob/main/examples/dreambooth/train_dreambooth.py

        if args.train_text_encoder and global_step == args.stop_text_encoder_training and global_step >= 30:
          if accelerator.is_main_process:
            print(" [0;32m" +" Freezing the text_encoder ..."+" [0m")                
            frz_dir=args.output_dir + "/text_encoder_frozen"
            if os.path.exists(frz_dir):
              subprocess.call('rm -r '+ frz_dir, shell=True)
            os.mkdir(frz_dir)
            pipeline = StableDiffusionPipeline.from_pretrained(
                args.pretrained_model_name_or_path,
                unet=accelerator.unwrap_model(unet),
                text_encoder=accelerator.unwrap_model(text_encoder),
            )
            pipeline.text_encoder.save_pretrained(frz_dir)

OrochiZ avatar Nov 17 '22 13:11 OrochiZ

This issue is stale because it has been open 5 days with no activity. Remove stale label or comment or this will be closed in 5 days

github-actions[bot] avatar Nov 23 '22 00:11 github-actions[bot]

Man, I gotta make that robot ignore stuff tagged with "Enhancement".

d8ahazard avatar Nov 26 '22 19:11 d8ahazard

@OrochiZ - So, I implemented this, and it broke stuff, and instead of fixing what I broke, I just ripped it all out again.

Maybe I'll re-work it, maybe I'll just tell people to train for N steps with it on, then turn it off and continue training. Got a lot on my plate right now, so I'm definitely not eager to break stuff again. :P

d8ahazard avatar Nov 29 '22 22:11 d8ahazard

Implemented - AGAIN. Cutoff is in epochs (steps per image), so should be similar to a percentage. ;)

d8ahazard avatar Jan 01 '23 19:01 d8ahazard