Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,8 @@
|
|
3 |
import gradio as gr
|
4 |
import json
|
5 |
|
|
|
|
|
6 |
|
7 |
# Module imports
|
8 |
from utilities.setup import get_json_cfg
|
@@ -19,6 +21,7 @@ def textbox_visibility(radio):
|
|
19 |
else:
|
20 |
return gr.Dropdown(visible=bool(0))
|
21 |
|
|
|
22 |
def upload_visibility(radio):
|
23 |
value = radio
|
24 |
if value == "Upload Your Own":
|
@@ -26,10 +29,49 @@ def upload_visibility(radio):
|
|
26 |
else:
|
27 |
return gr.UploadButton(visible=bool(0))
|
28 |
|
29 |
-
def
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
"""The model call"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
return f"Hello!! Using model: {model_name} with template: {inject_prompt}"
|
32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
##################################### App UI #######################################
|
34 |
|
35 |
def main():
|
@@ -101,11 +143,18 @@ def main():
|
|
101 |
gr.Markdown("### Model Progress")
|
102 |
# Text output (for now)
|
103 |
output = gr.Textbox(label="Output")
|
|
|
|
|
|
|
|
|
|
|
104 |
# Execute button
|
105 |
-
tune_btn.click(fn=
|
106 |
inputs=[model_name,
|
107 |
inject_prompt,
|
108 |
dataset_predefined,
|
|
|
|
|
109 |
peft,
|
110 |
sft,
|
111 |
max_seq_length,
|
@@ -117,6 +166,11 @@ def main():
|
|
117 |
model_out_name
|
118 |
],
|
119 |
outputs=output)
|
|
|
|
|
|
|
|
|
|
|
120 |
# Launch baby
|
121 |
demo.launch()
|
122 |
|
|
|
3 |
import gradio as gr
|
4 |
import json
|
5 |
|
6 |
+
# Specialized imports
|
7 |
+
#from utilities.modeling import modeling
|
8 |
|
9 |
# Module imports
|
10 |
from utilities.setup import get_json_cfg
|
|
|
21 |
else:
|
22 |
return gr.Dropdown(visible=bool(0))
|
23 |
|
24 |
+
|
25 |
def upload_visibility(radio):
|
26 |
value = radio
|
27 |
if value == "Upload Your Own":
|
|
|
29 |
else:
|
30 |
return gr.UploadButton(visible=bool(0))
|
31 |
|
32 |
+
def get_dataset(dataset_predefined, dataset_upload, data_field):
|
33 |
+
|
34 |
+
if dataset_predefined.visible:
|
35 |
+
print('')
|
36 |
+
else:
|
37 |
+
print('')
|
38 |
+
return 0
|
39 |
+
|
40 |
+
|
41 |
+
|
42 |
+
|
43 |
+
def train(model_name,
|
44 |
+
inject_prompt,
|
45 |
+
dataset_predefined,
|
46 |
+
peft,
|
47 |
+
sft,
|
48 |
+
max_seq_length,
|
49 |
+
random_seed,
|
50 |
+
num_epochs,
|
51 |
+
max_steps,
|
52 |
+
data_field,
|
53 |
+
repository,
|
54 |
+
model_out_name):
|
55 |
"""The model call"""
|
56 |
+
|
57 |
+
# Get models
|
58 |
+
# trainer = modeling(model_name, max_seq_length, random_seed,
|
59 |
+
# peft, sft, dataset, data_field)
|
60 |
+
# trainer_stats = trainer.train()
|
61 |
+
|
62 |
+
# Return outputs of training.
|
63 |
+
|
64 |
return f"Hello!! Using model: {model_name} with template: {inject_prompt}"
|
65 |
|
66 |
+
|
67 |
+
def submit_weights(model, repository, model_out_name, token):
|
68 |
+
"""submits model to repository"""
|
69 |
+
repo = repository + '/' + model_out_name
|
70 |
+
|
71 |
+
model.push_to_hub(repo, token = token)
|
72 |
+
tokenizer.push_to_hub(repo, token = token)
|
73 |
+
return 0
|
74 |
+
|
75 |
##################################### App UI #######################################
|
76 |
|
77 |
def main():
|
|
|
143 |
gr.Markdown("### Model Progress")
|
144 |
# Text output (for now)
|
145 |
output = gr.Textbox(label="Output")
|
146 |
+
|
147 |
+
|
148 |
+
# Data retrieval
|
149 |
+
|
150 |
+
|
151 |
# Execute button
|
152 |
+
tune_btn.click(fn=train,
|
153 |
inputs=[model_name,
|
154 |
inject_prompt,
|
155 |
dataset_predefined,
|
156 |
+
dataset_upload,
|
157 |
+
data_field,
|
158 |
peft,
|
159 |
sft,
|
160 |
max_seq_length,
|
|
|
166 |
model_out_name
|
167 |
],
|
168 |
outputs=output)
|
169 |
+
# stop button
|
170 |
+
|
171 |
+
# submit button
|
172 |
+
|
173 |
+
|
174 |
# Launch baby
|
175 |
demo.launch()
|
176 |
|