Spaces:
Runtime error
Runtime error
menouar
commited on
Commit
·
6c5232f
1
Parent(s):
a215ac2
Improve comments
Browse files- app.py +1 -1
- utils/components_creator.py +8 -4
- utils/notebook_generator.py +5 -13
app.py
CHANGED
@@ -215,7 +215,7 @@ def generate_code(components: dict[Component, Any]):
|
|
215 |
|
216 |
if push_to_hub:
|
217 |
if not should_login:
|
218 |
-
create_login_hf_cells(notebook['cells'])
|
219 |
push_to_hub_cells(notebook['cells'], output_dir)
|
220 |
|
221 |
file_name = f"{finetuning_notebook}.ipynb"
|
|
|
215 |
|
216 |
if push_to_hub:
|
217 |
if not should_login:
|
218 |
+
create_login_hf_cells(notebook['cells'], output_dir=output_dir)
|
219 |
push_to_hub_cells(notebook['cells'], output_dir)
|
220 |
|
221 |
file_name = f"{finetuning_notebook}.ipynb"
|
utils/components_creator.py
CHANGED
@@ -173,10 +173,14 @@ def add_outputs() -> (Component, Component):
|
|
173 |
info='The output directory where the model and checkpoints will be saved.',
|
174 |
elem_id=OUTPUT_DIR_ID)
|
175 |
|
176 |
-
push_to_hub = gr.Checkbox(
|
177 |
-
|
178 |
-
|
179 |
-
|
|
|
|
|
|
|
|
|
180 |
|
181 |
return output_dir, push_to_hub
|
182 |
|
|
|
173 |
info='The output directory where the model and checkpoints will be saved.',
|
174 |
elem_id=OUTPUT_DIR_ID)
|
175 |
|
176 |
+
push_to_hub = gr.Checkbox(
|
177 |
+
label="Push to Hub",
|
178 |
+
value=False,
|
179 |
+
interactive=True,
|
180 |
+
info="Select this option if you want to upload the trained model to Hugging Face Hub after training. "
|
181 |
+
"Please note, if this option is selected, you must provide a valid 'HF_TOKEN' in the generated notebook.",
|
182 |
+
elem_id=PUSH_TO_HUB_ID
|
183 |
+
)
|
184 |
|
185 |
return output_dir, push_to_hub
|
186 |
|
utils/notebook_generator.py
CHANGED
@@ -57,22 +57,14 @@ import torch; assert torch.cuda.get_device_capability()[0] >= 8, 'Hardware not s
|
|
57 |
cells.append(code_cell)
|
58 |
|
59 |
|
60 |
-
def create_login_hf_cells(cells: list, should_login: bool = False, model_name: Optional[str] = None
|
61 |
-
|
62 |
-
|
63 |
|
64 |
-
text_1 = ""
|
65 |
-
Login with `HF_TOKEN` in order to push the fine-tuned model to `huggingface_hub`.
|
66 |
-
|
67 |
-
Replace `HF_TOKEN` with a valid Token.
|
68 |
-
"""
|
69 |
|
70 |
if should_login:
|
71 |
-
text_1 = f""
|
72 |
-
Login with `HF_TOKEN` in order to load **{model_name}** from `huggingface_hub`.
|
73 |
-
|
74 |
-
Replace `HF_TOKEN` with a valid Token.
|
75 |
-
"""
|
76 |
|
77 |
text_cell1 = nbf.v4.new_markdown_cell(text_1)
|
78 |
code = """
|
|
|
57 |
cells.append(code_cell)
|
58 |
|
59 |
|
60 |
+
def create_login_hf_cells(cells: list, should_login: bool = False, model_name: Optional[str] = None,
|
61 |
+
output_dir: Optional[str] = None):
|
62 |
+
text_cell = nbf.v4.new_markdown_cell("## Login to HF")
|
63 |
|
64 |
+
text_1 = f"Replace `HF_TOKEN` with a valid token in order to push **'{output_dir}'** to `huggingface_hub`."
|
|
|
|
|
|
|
|
|
65 |
|
66 |
if should_login:
|
67 |
+
text_1 = f"Replace `HF_TOKEN` with a valid token in order to load **'{model_name}'** from `huggingface_hub`."
|
|
|
|
|
|
|
|
|
68 |
|
69 |
text_cell1 = nbf.v4.new_markdown_cell(text_1)
|
70 |
code = """
|