Fix AttributeError/TypeError in sana_sprint model-card save#13531
Open
Ricardo-M-L wants to merge 1 commit intohuggingface:mainfrom
Open
Fix AttributeError/TypeError in sana_sprint model-card save#13531Ricardo-M-L wants to merge 1 commit intohuggingface:mainfrom
Ricardo-M-L wants to merge 1 commit intohuggingface:mainfrom
Conversation
`train_sana_sprint_diffusers.py` calls `save_model_card` at the end of
training (under `--push_to_hub`) with an `instance_prompt` kwarg:
if args.push_to_hub:
save_model_card(
repo_id,
images=images,
base_model=args.pretrained_model_name_or_path,
instance_prompt=args.instance_prompt,
validation_prompt=args.validation_prompt,
repo_folder=args.output_dir,
)
But the script has neither:
1. `--instance_prompt` on the argparse parser. `args.instance_prompt`
raises `AttributeError: 'Namespace' object has no attribute
'instance_prompt'` when the kwarg value is evaluated.
2. Nor an `instance_prompt` parameter on `save_model_card`. Even if
the attribute existed, the call would fail with `TypeError:
save_model_card() got an unexpected keyword argument
'instance_prompt'`.
This is a dreambooth-pattern copy-paste leftover: Sana Sprint is not a
dreambooth-style trainer — it uses `--validation_prompt`, not instance
prompts. The value is not referenced inside `save_model_card` (grep
confirms `instance_prompt` appears only at this one call site).
Drop the stray kwarg. `save_model_card` accepts only `repo_id`,
`images`, `base_model`, `validation_prompt`, and `repo_folder`, and
the remaining kwargs already match that signature.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does
train_sana_sprint_diffusers.pyends training (under--push_to_hub) with:https://github.com/huggingface/diffusers/blob/main/examples/research_projects/sana/train_sana_sprint_diffusers.py#L1758-L1766
But the script has neither:
--instance_prompton the parser (grep confirms zeroadd_argumentcall for it).args.instance_promptraisesAttributeError: 'Namespace' object has no attribute 'instance_prompt'when the kwarg value is evaluated.instance_promptparameter onsave_model_card(line 217 accepts onlyrepo_id,images,base_model,validation_prompt,repo_folder— no**kwargs). Even if the attribute existed, the call would fail withTypeError: save_model_card() got an unexpected keyword argument 'instance_prompt'.Why this is a real bug
This fires at the tail end of training with
--push_to_hub, after the model has been saved locally — losing the hub upload for anyone running the documented workflow.It's a dreambooth-pattern copy-paste leftover: Sana Sprint is not a dreambooth-style trainer — it takes
--validation_prompt, not instance prompts.instance_promptappears exactly once in the whole file (at this call site) and is never referenced insidesave_model_card.Fix
Drop the stray kwarg:
save_model_card( repo_id, images=images, base_model=args.pretrained_model_name_or_path, - instance_prompt=args.instance_prompt, validation_prompt=args.validation_prompt, repo_folder=args.output_dir, )The remaining kwargs now match
save_model_card's signature exactly.Before submitting
--push_to_hubpath.Who can review?
@sayakpaul