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

configure.py can configure caption strategy #1042

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,26 @@ def configure_env():
"Enter the path to your dataset. This should be a directory containing images and text files for their caption. For reliability, use an absolute (full) path, beginning with a '/'",
"/datasets/my-dataset",
)
dataset_caption_strategy = prompt_user(
(
"How should the dataloader handle captions?"
"\n-> 'filename' will use the names of your image files as the caption"
"\n-> 'textfile' requires a image.txt file to go next to your image.png file"
"\n-> 'instanceprompt' will just use one trigger phrase for all images"
"\n"
"\n(Options: filename, textfile, instanceprompt)"
),
"textfile",
)
if dataset_caption_strategy not in ["filename", "textfile", "instanceprompt"]:
print(f"Invalid caption strategy: {dataset_caption_strategy}")
dataset_caption_strategy = "textfile"
dataset_instance_prompt = None
if "instanceprompt" in dataset_caption_strategy:
dataset_instance_prompt = prompt_user(
"Enter the instance_prompt you want to use for all images in this dataset",
"CatchPhrase",
)
dataset_repeats = int(
prompt_user(
"How many times do you want to repeat each image in the dataset?", 10
Expand Down Expand Up @@ -818,6 +838,9 @@ def configure_env():
dataset["maximum_image_size"] = dataset["resolution"]
dataset["target_downsample_size"] = dataset["resolution"]
dataset["id"] = dataset["id"].replace("PLACEHOLDER", dataset_id)
if dataset_instance_prompt:
dataset["instance_prompt"] = dataset_instance_prompt
dataset["caption_strategy"] = dataset_caption_strategy

print("Dataloader configuration:")
print(default_local_configuration)
Expand Down
Loading