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 · 2 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.

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

3 participants