Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle "store_true" bool flags more elegantly #13

Open
nateraw opened this issue Feb 7, 2023 · 0 comments
Open

Handle "store_true" bool flags more elegantly #13

nateraw opened this issue Feb 7, 2023 · 0 comments

Comments

@nateraw
Copy link
Contributor

nateraw commented Feb 7, 2023

Right now, bool args are converted and passed to the script like --do_the_thing True if you passed do_the_thing=True as a kwarg to run. Sometimes, like in the case of action='store_true', argparse doesn't like this. It also doesn't like --do_the_thing=True sometimes as well. Note I ran into this while running this script from diffusers.


Reproducible Example

You'll need a local instance data dir with some images, and may want to update the instance prompt/validation prompt.

fuego_run.py

from pathlib import Path

import fuego


base_model = 'stabilityai/stable-diffusion-2-1-base'
instance_data_dir = './rexxliferaj_images'
output_dir = './outputs'
instance_prompt = "a photo of sks rexxliferaj"
resolution = 512 # 768
gradient_accumulation = 1
learning_rate = 1e-4
n_steps = 1000
checkpointing_steps = 100
validation_prompt = "a photo of sks rexxliferaj at the Eiffel Tower"
validation_epochs = 100
seed = 42
fp16 = True
use_8bit_adam = True
use_wandb=False

space_url, dataset_url = fuego.run(
    script=Path(__file__).parent / "run_lora_finetuning.py",
    requirements_file=Path(__file__).parent / "requirements.txt",
    delete_space_on_completion=False,
    space_hardware="t4-small",
    downgrade_hardware_on_completion=False,
    # Kwargs
    pretrained_model_name_or_path=base_model,
    instance_data_dir=instance_data_dir,
    output_dir=output_dir,
    instance_prompt=instance_prompt,
    resolution=resolution,
    train_batch_size=1,
    gradient_accumulation_steps=gradient_accumulation,
    learning_rate=learning_rate,
    lr_scheduler="constant",
    lr_warmup_steps=0,
    max_train_steps=n_steps,
    checkpointing_steps=checkpointing_steps,
    validation_prompt=validation_prompt,
    validation_epochs=validation_epochs,
    seed=seed,
    mixed_precision="fp16" if fp16 else None,
    use_8bit_adam=use_8bit_adam,
    report_to="wandb" if use_wandb else "tensorboard",
)

print(f"Space: {space_url}")
print(f"Dataset: {dataset_url}")

requirements.txt

accelerate==0.15.0
bitsandbytes==0.36.0.post2
datasets==2.8.0
git+https://github.com/huggingface/diffusers@31be42209ddfdb69d9640a777b32e9b5c6259bf0#egg=diffusers
ftfy==6.1.1
gradio==3.16.2
huggingface-hub==0.12.0
Pillow==9.4.0
python-slugify==7.0.0
tensorboard==2.11.2
torch==1.13.1
torchvision==0.14.1
transformers==4.26.0
wandb==0.13.9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant