Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@ from huggingface_hub import HfApi
|
|
3 |
import spaces
|
4 |
import shutil
|
5 |
import logging
|
|
|
6 |
|
7 |
@spaces.GPU
|
8 |
|
@@ -42,6 +43,15 @@ def merge_and_upload(base_model, model_to_merge, scaling_factor, weight_drop_pro
|
|
42 |
# Upload the result to Hugging Face Hub
|
43 |
api = HfApi(token=token)
|
44 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
# Create a new repo or update an existing one
|
46 |
api.create_repo(repo_id=repo_name, token=token, exist_ok=True)
|
47 |
|
@@ -62,18 +72,22 @@ def merge_and_upload(base_model, model_to_merge, scaling_factor, weight_drop_pro
|
|
62 |
# Define the Gradio interface
|
63 |
with gr.Blocks() as demo:
|
64 |
gr.Markdown("# Model Merger and Uploader")
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
|
73 |
-
gr.
|
74 |
-
|
75 |
-
inputs=[base_model, model_to_merge, scaling_factor, weight_drop_prob, repo_name, token],
|
76 |
-
outputs=output
|
77 |
-
)
|
78 |
|
79 |
demo.launch()
|
|
|
3 |
import spaces
|
4 |
import shutil
|
5 |
import logging
|
6 |
+
import subprocess
|
7 |
|
8 |
@spaces.GPU
|
9 |
|
|
|
43 |
# Upload the result to Hugging Face Hub
|
44 |
api = HfApi(token=token)
|
45 |
try:
|
46 |
+
# Get the username of the user who is logged in
|
47 |
+
user = api.whoami(token=token)["name"]
|
48 |
+
|
49 |
+
# Autofill the repo name if none is provided
|
50 |
+
if not repo_name:
|
51 |
+
repo_name = f"{user}/default-repo"
|
52 |
+
else:
|
53 |
+
repo_name = repo_name
|
54 |
+
|
55 |
# Create a new repo or update an existing one
|
56 |
api.create_repo(repo_id=repo_name, token=token, exist_ok=True)
|
57 |
|
|
|
72 |
# Define the Gradio interface
|
73 |
with gr.Blocks() as demo:
|
74 |
gr.Markdown("# Model Merger and Uploader")
|
75 |
+
gr.Markdown("Combine capabilities from multiple models. Works with:")
|
76 |
+
gr.Markdown("* Stable Diffusion (1.5, XL/XL Turbo)")
|
77 |
+
gr.Markdown("* LLMs (Mistral, Llama, etc)")
|
78 |
+
gr.Markdown("* LoRas (must be same size)")
|
79 |
+
gr.Markdown("* Any two homologous models")
|
80 |
+
|
81 |
+
with gr.Column():
|
82 |
+
gr.Textbox(label="Hugging Face Token", type="password")
|
83 |
+
gr.Textbox(label="Base Model")
|
84 |
+
gr.Textbox(label="Model to Merge")
|
85 |
+
gr.Slider(minimum=0, maximum=10, value=3.0, label="Scaling Factor")
|
86 |
+
gr.Slider(minimum=0, maximum=1, value=0.3, label="Weight Drop Probability")
|
87 |
+
gr.Textbox(label="Repo Name (leave blank for default)")
|
88 |
+
gr.Button("Merge and Upload")
|
89 |
|
90 |
+
with gr.Column():
|
91 |
+
gr.Textbox(label="Output")
|
|
|
|
|
|
|
92 |
|
93 |
demo.launch()
|