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

autocaption_prefix and autocaption_suffix not always added to captions #42

Open
erikbrodnick opened this issue Oct 3, 2024 · 3 comments

Comments

@erikbrodnick
Copy link

erikbrodnick commented Oct 3, 2024

I observed in the training output logs that the captions did not always include the autocaption_prefix or autocaption_suffix. This is pretty important as it contains the unique trigger token.

After looking at caption.py I noticed this block:

if autocaption_prefix:
    inp += f"\n\nYou must start the caption with '{autocaption_prefix}'. "

if autocaption_suffix:
    inp += f"\n\nYou must end the caption with '{autocaption_suffix}'."

Instead of relying on the llm to add these which it is clearly failing to do, I suggest manually adding to the resulting output as follows:

output = self.tokenizer.batch_decode(output_ids, skip_special_tokens=True)[
    0
].strip()

if autocaption_prefix:
    output = f"{autocaption_prefix} {output}"
if autocaption_suffix:
    output = f"{output} {autocaption_suffix}"

print(f"Caption for {image_path}: {output}")
@tomhillable
Copy link

Also have this issue and am seeing only about 50% of the captions having the prefix or suffix enforced.

@dmund95
Copy link

dmund95 commented Oct 12, 2024

Yeah I agree.

@dmd
Copy link

dmd commented Feb 8, 2025

I am seeing less than 20% of captions having the prefix or suffix. I have worked around it for the time being by allowing autocaptioning to proceed, then cancelling the run as soon as it finishes. Then I grab the logs and manually insert my prefix on each one, and write each line to a matching .txt file, turn off autocaptioning, and start over using a new zipfile with the included .txts.

This is annoying.

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

4 participants