Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,42 +1,35 @@
|
|
1 |
import gradio as gr
|
2 |
import subprocess
|
3 |
-
import spaces
|
4 |
|
5 |
-
|
6 |
-
#
|
7 |
-
def run_hf_merge(repo_names, output_dir, staging='./staging', p=0.5, lambda_val=1.0, dry_run=False):
|
8 |
-
repo_list = "\n".join(repo_names.split(","))
|
9 |
-
with open("repo_list.txt", "w") as file:
|
10 |
-
file.write(repo_list)
|
11 |
-
|
12 |
command = [
|
13 |
-
"python3", "hf_merge.py",
|
14 |
-
"-
|
|
|
|
|
15 |
]
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
result = subprocess.run(command, capture_output=True, text=True)
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
return "Error during merge.\n" + result.stderr
|
24 |
|
25 |
-
# Gradio interface
|
26 |
-
|
27 |
-
fn=
|
28 |
inputs=[
|
29 |
-
gr.
|
30 |
-
gr.
|
31 |
-
gr.Textbox(label="
|
32 |
-
gr.
|
33 |
-
gr.
|
34 |
-
gr.Checkbox(label="Dry Run")
|
35 |
],
|
36 |
outputs="text",
|
37 |
-
title="
|
38 |
-
description="Merge
|
39 |
)
|
40 |
|
41 |
-
|
42 |
-
|
|
|
1 |
import gradio as gr
|
2 |
import subprocess
|
|
|
3 |
|
4 |
+
def merge_models(weight_drop_prob, scaling_factor, base_model, model_to_merge, output_path):
|
5 |
+
# Construct the command to run hf_merge.py
|
|
|
|
|
|
|
|
|
|
|
6 |
command = [
|
7 |
+
"python3", "hf_merge.py",
|
8 |
+
"-p", str(weight_drop_prob),
|
9 |
+
"-lambda", str(scaling_factor),
|
10 |
+
base_model, model_to_merge, output_path
|
11 |
]
|
12 |
+
|
13 |
+
# Run the command and capture the output
|
|
|
14 |
result = subprocess.run(command, capture_output=True, text=True)
|
15 |
+
|
16 |
+
# Return the output of the command
|
17 |
+
return result.stdout
|
|
|
18 |
|
19 |
+
# Define the Gradio interface
|
20 |
+
iface = gr.Interface(
|
21 |
+
fn=merge_models,
|
22 |
inputs=[
|
23 |
+
gr.inputs.Slider(minimum=0, maximum=1, default=0.13, label="Weight Drop Probability"),
|
24 |
+
gr.inputs.Number(default=3.0, label="Scaling Factor"),
|
25 |
+
gr.inputs.Textbox(label="Base Model File/Folder"),
|
26 |
+
gr.inputs.Textbox(label="Model to Merge"),
|
27 |
+
gr.inputs.Textbox(label="Output Path")
|
|
|
28 |
],
|
29 |
outputs="text",
|
30 |
+
title="Model Merger",
|
31 |
+
description="Merge two models using the Super Mario merge method."
|
32 |
)
|
33 |
|
34 |
+
# Launch the interface
|
35 |
+
iface.launch()
|