Update app.py
Browse files
app.py
CHANGED
|
@@ -39,7 +39,7 @@ class update_visibility:
|
|
| 39 |
else:
|
| 40 |
return gr.UploadButton(visible=bool(0))
|
| 41 |
|
| 42 |
-
class
|
| 43 |
|
| 44 |
def predefined_dataset(dataset_name):
|
| 45 |
global dataset # bad practice, I know... But just bear with me. Will later update to state dict.
|
|
@@ -59,21 +59,14 @@ class get_datasets:
|
|
| 59 |
except FileNotFoundError:
|
| 60 |
return "File not found. Please upload the file again."
|
| 61 |
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
def show_about():
|
| 72 |
-
return "## About\n\nThis is an application for uploading datasets. You can upload files in .csv, .jsonl, or .txt format. The app will process the file and provide feedback."
|
| 73 |
-
|
| 74 |
-
def show_upload():
|
| 75 |
-
return "## Upload\n\nUse the button below to upload your dataset."
|
| 76 |
-
|
| 77 |
|
| 78 |
|
| 79 |
def train(model_name,
|
|
@@ -118,7 +111,8 @@ def main():
|
|
| 118 |
|
| 119 |
with gr.Tabs():
|
| 120 |
with gr.TabItem("About"):
|
| 121 |
-
gr.Markdown("
|
|
|
|
| 122 |
with gr.TabItem("Train Model"):
|
| 123 |
##### Title Block #####
|
| 124 |
gr.Markdown("# SLM Instruction Tuning with Unsloth")
|
|
@@ -161,11 +155,11 @@ def main():
|
|
| 161 |
dataset_predefined_load)
|
| 162 |
|
| 163 |
# Dataset button
|
| 164 |
-
dataset_predefined_load.click(fn=
|
| 165 |
inputs=dataset_predefined,
|
| 166 |
outputs=data_snippet)
|
| 167 |
|
| 168 |
-
dataset_uploaded_load.click(fn=
|
| 169 |
inputs=dataset_uploaded_load,
|
| 170 |
outputs=data_snippet)
|
| 171 |
|
|
|
|
| 39 |
else:
|
| 40 |
return gr.UploadButton(visible=bool(0))
|
| 41 |
|
| 42 |
+
class get_files:
|
| 43 |
|
| 44 |
def predefined_dataset(dataset_name):
|
| 45 |
global dataset # bad practice, I know... But just bear with me. Will later update to state dict.
|
|
|
|
| 59 |
except FileNotFoundError:
|
| 60 |
return "File not found. Please upload the file again."
|
| 61 |
|
| 62 |
+
def load_markdown_file(file_path):
|
| 63 |
+
try:
|
| 64 |
+
with open(file_path, 'r') as f:
|
| 65 |
+
return f.read()
|
| 66 |
+
except FileNotFoundError:
|
| 67 |
+
return "File not found. Please check the file path."
|
| 68 |
+
except Exception as e:
|
| 69 |
+
return f"Error loading file: {str(e)}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
|
| 71 |
|
| 72 |
def train(model_name,
|
|
|
|
| 111 |
|
| 112 |
with gr.Tabs():
|
| 113 |
with gr.TabItem("About"):
|
| 114 |
+
gr.Markdown(get_files.load_markdown_file("README.md"))
|
| 115 |
+
|
| 116 |
with gr.TabItem("Train Model"):
|
| 117 |
##### Title Block #####
|
| 118 |
gr.Markdown("# SLM Instruction Tuning with Unsloth")
|
|
|
|
| 155 |
dataset_predefined_load)
|
| 156 |
|
| 157 |
# Dataset button
|
| 158 |
+
dataset_predefined_load.click(fn=get_files.predefined_dataset,
|
| 159 |
inputs=dataset_predefined,
|
| 160 |
outputs=data_snippet)
|
| 161 |
|
| 162 |
+
dataset_uploaded_load.click(fn=get_files.uploaded_dataset,
|
| 163 |
inputs=dataset_uploaded_load,
|
| 164 |
outputs=data_snippet)
|
| 165 |
|