From 13c7e873e064bb1bd5be274c845411b88a7ccaed Mon Sep 17 00:00:00 2001 From: hiyouga Date: Tue, 29 Oct 2024 13:02:13 +0000 Subject: [PATCH] fix #5749 Former-commit-id: 23dbe9a09999fe0f9eb2902a40e33b36db4ca584 --- .dockerignore | 2 ++ .env.local | 13 +++++++------ src/llamafactory/train/callbacks.py | 4 ++-- src/llamafactory/train/tuner.py | 6 ++---- src/webui.py | 5 +++-- 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/.dockerignore b/.dockerignore index 23ad75a8..bc56ab8b 100644 --- a/.dockerignore +++ b/.dockerignore @@ -7,6 +7,8 @@ data docker saves hf_cache +ms_cache +om_cache output .dockerignore .gitattributes diff --git a/.env.local b/.env.local index adc1ec81..fb423d75 100644 --- a/.env.local +++ b/.env.local @@ -1,9 +1,9 @@ # Note: actually we do not support .env, just for reference # api -API_HOST=0.0.0.0 -API_PORT=8000 +API_HOST= +API_PORT= API_KEY= -API_MODEL_NAME=gpt-3.5-turbo +API_MODEL_NAME= FASTAPI_ROOT_PATH= # general DISABLE_VERSION_CHECK= @@ -21,13 +21,14 @@ RANK= NPROC_PER_NODE= # wandb WANDB_DISABLED= -WANDB_PROJECT=huggingface +WANDB_PROJECT= WANDB_API_KEY= # gradio ui -GRADIO_SHARE=False -GRADIO_SERVER_NAME=0.0.0.0 +GRADIO_SHARE= +GRADIO_SERVER_NAME= GRADIO_SERVER_PORT= GRADIO_ROOT_PATH= +GRADIO_IPV6= # setup ENABLE_SHORT_CONSOLE=1 # reserved (do not use) diff --git a/src/llamafactory/train/callbacks.py b/src/llamafactory/train/callbacks.py index 5a80d81a..350168e5 100644 --- a/src/llamafactory/train/callbacks.py +++ b/src/llamafactory/train/callbacks.py @@ -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): diff --git a/src/llamafactory/train/tuner.py b/src/llamafactory/train/tuner.py index e5901973..880da359 100644 --- a/src/llamafactory/train/tuner.py +++ b/src/llamafactory/train/tuner.py @@ -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}.") diff --git a/src/webui.py b/src/webui.py index 99370af2..d0f00ea6 100644 --- a/src/webui.py +++ b/src/webui.py @@ -18,8 +18,9 @@ from llamafactory.webui.interface import create_ui def main(): - gradio_share = os.environ.get("GRADIO_SHARE", "0").lower() in ["true", "1"] - server_name = os.environ.get("GRADIO_SERVER_NAME", "0.0.0.0") + gradio_ipv6 = os.getenv("GRADIO_IPV6", "0").lower() in ["true", "1"] + gradio_share = os.getenv("GRADIO_SHARE", "0").lower() in ["true", "1"] + server_name = os.getenv("GRADIO_SERVER_NAME", "[::]" if gradio_ipv6 else "0.0.0.0") create_ui().queue().launch(share=gradio_share, server_name=server_name, inbrowser=True)