tykiww commited on
Commit
6f701e2
·
verified ·
1 Parent(s): a40632d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -18
app.py CHANGED
@@ -4,32 +4,20 @@ import gradio as gr
4
  import json
5
  import os
6
 
7
- # local imports
8
-
9
-
10
  ########################### Global objects and functions ###########################
11
 
12
  def get_json_cfg():
13
  """Retrieve configuration file"""
14
-
15
  config_path = os.getenv('CONFIG_PATH')
16
  with open(config_path, 'r') as file:
17
  config = json.load(file)
18
-
19
  return config
20
 
21
-
22
  conf = get_json_cfg()
23
 
24
-
25
-
26
-
27
- def greet(model_name, prompt_template, name):
28
  return f"Hello {name}!! Using model: {model_name} with template: {prompt_template}"
29
 
30
- model_choices = conf['model']['choices']
31
-
32
-
33
  ##################################### App UI #######################################
34
  with gr.Blocks() as demo:
35
 
@@ -40,11 +28,22 @@ with gr.Blocks() as demo:
40
 
41
  # Select Model
42
  model_name = gr.Dropdown(label="Model", choices=conf['model']['choices'], value="gpt2")
43
- # Show prompt template
44
  prompt_template = gr.Textbox(label="Prompt Template", value="Instruction: {0}\nOutput: {1}")
45
  # Prompt Input
46
  name_input = gr.Textbox(label="Your Name")
47
-
 
 
 
 
 
 
 
 
 
 
 
48
  ##### Model Outputs #####
49
 
50
  # Text output
@@ -56,11 +55,10 @@ with gr.Blocks() as demo:
56
  tune_btn = gr.Button("Start Fine Tuning")
57
  # Execute button
58
  tune_btn.click(fn=greet,
59
- inputs=[model_name, prompt_template, name_input],
60
  outputs=output)
61
 
62
-
63
  ##################################### Launch #######################################
64
 
65
  if __name__ == "__main__":
66
- demo.launch()
 
4
  import json
5
  import os
6
 
 
 
 
7
  ########################### Global objects and functions ###########################
8
 
9
  def get_json_cfg():
10
  """Retrieve configuration file"""
 
11
  config_path = os.getenv('CONFIG_PATH')
12
  with open(config_path, 'r') as file:
13
  config = json.load(file)
 
14
  return config
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
 
 
28
 
29
  # Select Model
30
  model_name = gr.Dropdown(label="Model", choices=conf['model']['choices'], value="gpt2")
31
+ # Prompt template
32
  prompt_template = gr.Textbox(label="Prompt Template", value="Instruction: {0}\nOutput: {1}")
33
  # Prompt Input
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
+ # Update visibility of dataset options based on user choice
41
+ def update_dataset_visibility(choice):
42
+ dataset_predefined.visible = (choice == "Predefined Dataset")
43
+ dataset_upload.visible = (choice == "Upload Your Own")
44
+
45
+ dataset_choice.change(update_dataset_visibility, inputs=[dataset_choice], outputs=[dataset_predefined, dataset_upload])
46
+
47
  ##### Model Outputs #####
48
 
49
  # Text output
 
55
  tune_btn = gr.Button("Start Fine Tuning")
56
  # Execute button
57
  tune_btn.click(fn=greet,
58
+ inputs=[model_name, prompt_template, name_input, dataset_predefined],
59
  outputs=output)
60
 
 
61
  ##################################### Launch #######################################
62
 
63
  if __name__ == "__main__":
64
+ demo.launch()