mrcuddle commited on
Commit
1b621fc
1 Parent(s): 9867227

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -94
app.py CHANGED
@@ -1,96 +1,36 @@
1
- import panel as pn
2
- from transformers_agent_ui import TransformersAgentUI
3
- from huggingface_hub import HfApi
4
-
5
- # Load the model list from the script
6
- model_list = [
7
- "LayoutLMv3",
8
- "LayoutXLM",
9
- "LED",
10
- "LeViT",
11
- "LiLT",
12
- "LLaMA",
13
- "Llama2",
14
- "Llama3",
15
- "LLaVa",
16
- "LLaVA-NeXT",
17
- "LLaVA-NeXT-Video",
18
- "LLaVA-Onevision",
19
- "Longformer",
20
- "LongT5",
21
- "LUKE",
22
- "LXMERT",
23
- "M-CTC-T",
24
- "M2M100",
25
- "MADLAD-400",
26
- "Mamba",
27
- "mamba2",
28
- "Marian",
29
- "MarkupLM",
30
- "Mask2Former",
31
- "MaskFormer",
32
- "MatCha",
33
- "mBART",
34
- "mBART-50",
35
- "MEGA",
36
- "Megatron-BERT",
37
- "Megatron-GPT2",
38
- "MGP-STR",
39
- "Mimi",
40
- "Mistral",
41
- "Mixtral",
42
- "Mllama",
43
- "mLUKE",
44
- "MMS",
45
- "MobileBERT",
46
- "MobileNetV1",
47
- "MobileNetV2",
48
- "MobileViT",
49
- "MobileViTV2",
50
- "Moshi",
51
- "MPNet",
52
- "MPT",
53
- "MRA",
54
- "MT5",
55
- "MusicGen",
56
- ]
57
-
58
- # Create a dropdown menu for model selection
59
- model_selector = pn.widgets.Select(options=model_list, value=model_list[0])
60
-
61
- # Create a text input for the repository list file
62
- repo_list_file = pn.widgets.TextInput(value="repo_list.txt")
63
-
64
- # Create a text input for the output directory
65
- output_dir = pn.widgets.TextInput(value="output_dir")
66
-
67
- # Create a checkbox for dry run
68
- dry_run = pn.widgets.Checkbox(value=False)
69
-
70
- # Create a button to start the process
71
- start_button = pn.widgets.Button(name="Start")
72
-
73
- # Define the function to be executed when the button is clicked
74
- def start_process(event):
75
- # Get the selected model and repository list file
76
- model = model_selector.value
77
- repo_list_file_path = repo_list_file.value
78
- output_dir_path = output_dir.value
79
- dry_run_value = dry_run.value
80
-
81
- # Call the script with the selected options
82
- process_repos(output_dir_path, model, repo_list_file_path, dry_run_value)
83
-
84
- # Link the button to the function
85
- start_button.on_click(start_process)
86
-
87
- # Create the UI
88
- ui = pn.Column(
89
- pn.Row(model_selector, repo_list_file, output_dir, dry_run),
90
- start_button,
91
  )
92
 
93
- # Serve the UI
94
- if pn.state.served:
95
- pn.extension("terminal", "notifications", notifications=True, design="bootstrap")
96
- ui.servable()
 
1
+ import gradio as gr
2
+ import subprocess
3
+
4
+ # Function to execute hf_merge.py with provided parameters
5
+ def run_hf_merge(repo_list, output_dir, staging='./staging', p=0.5, lambda_val=1.0, dry_run=False):
6
+ command = [
7
+ "python3", "hf_merge.py", repo_list, output_dir,
8
+ "-staging", staging, "-p", str(p), "-lambda", str(lambda_val)
9
+ ]
10
+ if dry_run:
11
+ command.append("--dry")
12
+
13
+ result = subprocess.run(command, capture_output=True, text=True)
14
+ if result.returncode == 0:
15
+ return "Merge completed successfully.\n" + result.stdout
16
+ else:
17
+ return "Error during merge.\n" + result.stderr
18
+
19
+ # Gradio interface
20
+ interface = gr.Interface(
21
+ fn=run_hf_merge,
22
+ inputs=[
23
+ gr.Textbox(label="Repo List File"),
24
+ gr.Textbox(label="Output Directory"),
25
+ gr.Textbox(label="Staging Directory", value="./staging"),
26
+ gr.Number(label="Dropout Probability", value=0.5),
27
+ gr.Number(label="Scaling Factor", value=1.0),
28
+ gr.Checkbox(label="Dry Run")
29
+ ],
30
+ outputs="text",
31
+ title="HuggingFace Model Merger",
32
+ description="Merge HuggingFace models using the technique described in 'Language Models are Super Mario: Absorbing Abilities from Homologous Models as a Free Lunch'."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  )
34
 
35
+ if __name__ == "__main__":
36
+ interface.launch()