@@ -124,12 +124,12 @@ class SaveProcessorCallback(TrainerCallback):
|
||||
def on_save(self, args: "TrainingArguments", state: "TrainerState", control: "TrainerControl", **kwargs):
|
||||
if args.should_save:
|
||||
output_dir = os.path.join(args.output_dir, f"{PREFIX_CHECKPOINT_DIR}-{state.global_step}")
|
||||
getattr(self.processor, "image_processor").save_pretrained(output_dir)
|
||||
self.processor.save_pretrained(output_dir)
|
||||
|
||||
@override
|
||||
def on_train_end(self, args: "TrainingArguments", state: "TrainerState", control: "TrainerControl", **kwargs):
|
||||
if args.should_save:
|
||||
getattr(self.processor, "image_processor").save_pretrained(args.output_dir)
|
||||
self.processor.save_pretrained(args.output_dir)
|
||||
|
||||
|
||||
class PissaConvertCallback(TrainerCallback):
|
||||
|
||||
@@ -133,11 +133,9 @@ def export_model(args: Optional[Dict[str, Any]] = None) -> None:
|
||||
tokenizer.push_to_hub(model_args.export_hub_model_id, token=model_args.hf_hub_token)
|
||||
|
||||
if processor is not None:
|
||||
getattr(processor, "image_processor").save_pretrained(model_args.export_dir)
|
||||
processor.save_pretrained(model_args.export_dir)
|
||||
if model_args.export_hub_model_id is not None:
|
||||
getattr(processor, "image_processor").push_to_hub(
|
||||
model_args.export_hub_model_id, token=model_args.hf_hub_token
|
||||
)
|
||||
processor.push_to_hub(model_args.export_hub_model_id, token=model_args.hf_hub_token)
|
||||
|
||||
except Exception as e:
|
||||
logger.warning(f"Cannot save tokenizer, please copy the files manually: {e}.")
|
||||
|
||||
Reference in New Issue
Block a user