Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -15,36 +15,10 @@ def get_json_cfg():
|
|
15 |
|
16 |
conf = get_json_cfg()
|
17 |
|
18 |
-
def greet(model_name, prompt_template, name,
|
19 |
-
# Here you can process the uploaded file (dataset_file) as needed
|
20 |
return f"Hello {name}!! Using model: {model_name} with template: {prompt_template}"
|
21 |
|
22 |
##################################### App UI #######################################
|
23 |
-
|
24 |
-
# Function to build the interface based on user choice
|
25 |
-
def build_interface(choice):
|
26 |
-
if choice == "Predefined Dataset":
|
27 |
-
dataset_input = gr.Dropdown(label="Predefined Dataset", choices=['1', '2', '3'], value='1', key="dataset_predefined")
|
28 |
-
elif choice == "Upload Your Own":
|
29 |
-
dataset_input = gr.File(label="Upload Dataset", accept=".csv,.txt", key="dataset_upload")
|
30 |
-
else:
|
31 |
-
dataset_input = None
|
32 |
-
return dataset_input
|
33 |
-
|
34 |
-
# Function to handle changes in dataset choice
|
35 |
-
def on_choice_change(choice):
|
36 |
-
interface = build_interface(choice)
|
37 |
-
update_interface(interface)
|
38 |
-
|
39 |
-
# Function to update the interface with new dataset input
|
40 |
-
def update_interface(dataset_input):
|
41 |
-
demo.Interface(
|
42 |
-
fn=greet,
|
43 |
-
inputs=[model_name, prompt_template, name_input, dataset_input],
|
44 |
-
outputs=output
|
45 |
-
).launch()
|
46 |
-
|
47 |
-
##################################### Gradio Blocks #######################################
|
48 |
with gr.Blocks() as demo:
|
49 |
|
50 |
##### Title Block #####
|
@@ -60,23 +34,37 @@ with gr.Blocks() as demo:
|
|
60 |
name_input = gr.Textbox(label="Your Name")
|
61 |
# Dataset choice
|
62 |
dataset_choice = gr.Radio(label="Choose Dataset", choices=["Predefined Dataset", "Upload Your Own"], value="Predefined Dataset")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
|
64 |
-
#
|
65 |
-
initial_choice = dataset_choice.value
|
66 |
-
initial_interface = build_interface(initial_choice)
|
67 |
-
|
68 |
-
# Output textbox
|
69 |
output = gr.Textbox(label="Output")
|
|
|
|
|
70 |
|
71 |
# Setup button
|
72 |
tune_btn = gr.Button("Start Fine Tuning")
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
# Update visibility based on user choice
|
79 |
-
dataset_choice.change(on_choice_change, inputs=[dataset_choice])
|
80 |
|
81 |
##################################### Launch #######################################
|
82 |
|
|
|
15 |
|
16 |
conf = get_json_cfg()
|
17 |
|
18 |
+
def greet(model_name, prompt_template, name, dataset):
|
|
|
19 |
return f"Hello {name}!! Using model: {model_name} with template: {prompt_template}"
|
20 |
|
21 |
##################################### App UI #######################################
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
with gr.Blocks() as demo:
|
23 |
|
24 |
##### Title Block #####
|
|
|
34 |
name_input = gr.Textbox(label="Your Name")
|
35 |
# Dataset choice
|
36 |
dataset_choice = gr.Radio(label="Choose Dataset", choices=["Predefined Dataset", "Upload Your Own"], value="Predefined Dataset")
|
37 |
+
dataset_predefined = gr.Dropdown(label="Predefined Dataset", choices=['1', '2', '3'], value='1', visible=True)
|
38 |
+
dataset_upload = gr.File(label="Upload Dataset", visible=False)
|
39 |
+
|
40 |
+
# Function to update visibility based on user choice
|
41 |
+
def update_dataset_visibility(choice):
|
42 |
+
if choice == "Predefined Dataset":
|
43 |
+
dataset_predefined.visible = True
|
44 |
+
dataset_upload.visible = False
|
45 |
+
elif choice == "Upload Your Own":
|
46 |
+
dataset_predefined.visible = False
|
47 |
+
dataset_upload.visible = True
|
48 |
+
|
49 |
+
# Initial call to set visibility based on default choice
|
50 |
+
update_dataset_visibility(dataset_choice.value)
|
51 |
+
|
52 |
+
# Update visibility based on user choice
|
53 |
+
dataset_choice.change(update_dataset_visibility, inputs=[dataset_choice], outputs=[dataset_predefined, dataset_upload])
|
54 |
+
|
55 |
+
##### Model Outputs #####
|
56 |
|
57 |
+
# Text output
|
|
|
|
|
|
|
|
|
58 |
output = gr.Textbox(label="Output")
|
59 |
+
|
60 |
+
##### Execution #####
|
61 |
|
62 |
# Setup button
|
63 |
tune_btn = gr.Button("Start Fine Tuning")
|
64 |
+
# Execute button
|
65 |
+
tune_btn.click(fn=greet,
|
66 |
+
inputs=[model_name, prompt_template, name_input, dataset_predefined],
|
67 |
+
outputs=output)
|
|
|
|
|
|
|
68 |
|
69 |
##################################### Launch #######################################
|
70 |
|