Spaces:
Runtime error
Runtime error
Efreak
commited on
Commit
·
6a7b963
1
Parent(s):
777222d
more stuff
Browse files
app.py
CHANGED
@@ -9,16 +9,14 @@ import random
|
|
9 |
import time
|
10 |
|
11 |
api=HfApi()
|
12 |
-
FILE_TYPES = ["Embedding", "Model", "Lora", "Lycoris"]
|
13 |
|
14 |
-
def duplicate(source_url, preview_url, model_id, dst_repo, token,
|
15 |
try:
|
16 |
_ = whoami(token)
|
17 |
# ^ this will throw if token is invalid
|
18 |
|
19 |
# make sure the user fills out the other required paths.
|
20 |
-
if not dst_repo_path[len(dst_repo_path)-1] == '/':
|
21 |
-
raise Exception("Your destination path *must* end with a /")
|
22 |
if not source_url:
|
23 |
raise Exception("You haven't chosen a file to download!")
|
24 |
if not dst_repo:
|
@@ -37,7 +35,7 @@ def duplicate(source_url, preview_url, model_id, dst_repo, token, dst_repo_path,
|
|
37 |
match repo_type:
|
38 |
case "Embedding":
|
39 |
repopath="/embeddings"
|
40 |
-
case "Model":
|
41 |
repopath="/models/Stable-diffusion"
|
42 |
case "Lora":
|
43 |
repopath="/models/Lora/Lora"
|
@@ -48,10 +46,11 @@ def duplicate(source_url, preview_url, model_id, dst_repo, token, dst_repo_path,
|
|
48 |
repopath=repopath+"/nsfw"
|
49 |
|
50 |
api.upload_folder(
|
51 |
-
|
52 |
path_in_repo=repopath,
|
53 |
repo_id=dst_repo,
|
54 |
-
repo_type=repo_type
|
|
|
55 |
)
|
56 |
|
57 |
# now clean up
|
@@ -88,13 +87,14 @@ def duplicate(source_url, preview_url, model_id, dst_repo, token, dst_repo_path,
|
|
88 |
interface = gr.Interface(
|
89 |
fn=duplicate,
|
90 |
inputs=[
|
91 |
-
gr.Textbox(
|
92 |
-
gr.Textbox(
|
93 |
-
gr.Textbox(placeholder="model ID (e.g. 4324322534)"),
|
94 |
-
gr.Textbox(
|
95 |
-
gr.Textbox(
|
96 |
-
gr.
|
97 |
-
gr.
|
|
|
98 |
],
|
99 |
outputs=[
|
100 |
gr.Markdown(label="output"),
|
|
|
9 |
import time
|
10 |
|
11 |
api=HfApi()
|
12 |
+
FILE_TYPES = ["Embedding", "Stable Diffusion Model", "Lora", "Lycoris"]
|
13 |
|
14 |
+
def duplicate(source_url, preview_url, model_id, dst_repo, token, repo_type, nsfw, make_pr):
|
15 |
try:
|
16 |
_ = whoami(token)
|
17 |
# ^ this will throw if token is invalid
|
18 |
|
19 |
# make sure the user fills out the other required paths.
|
|
|
|
|
20 |
if not source_url:
|
21 |
raise Exception("You haven't chosen a file to download!")
|
22 |
if not dst_repo:
|
|
|
35 |
match repo_type:
|
36 |
case "Embedding":
|
37 |
repopath="/embeddings"
|
38 |
+
case "Stable Diffusion Model":
|
39 |
repopath="/models/Stable-diffusion"
|
40 |
case "Lora":
|
41 |
repopath="/models/Lora/Lora"
|
|
|
46 |
repopath=repopath+"/nsfw"
|
47 |
|
48 |
api.upload_folder(
|
49 |
+
folder_path=dir,
|
50 |
path_in_repo=repopath,
|
51 |
repo_id=dst_repo,
|
52 |
+
repo_type=repo_type,
|
53 |
+
create_pr=make_pr
|
54 |
)
|
55 |
|
56 |
# now clean up
|
|
|
87 |
interface = gr.Interface(
|
88 |
fn=duplicate,
|
89 |
inputs=[
|
90 |
+
gr.Textbox(label="Source URL", info="Source URL for model file. FP32 unpruned preferred, but you can upload multiple versions. Safetensors preferred, but not really important.", placeholder="https://civitai.com/api/download/models/4324322534?garbageextrastuff"),
|
91 |
+
gr.Textbox(label="Preview URL", info="URL for model preview on civitai. High resolution with generation data preferred, you can upload an alternate separately without the .preview part in the filename, this will override the preview. Will be renamed to modelprefix.preview.png, regardless of actual format; this is what civitai unofficial extemsion wants.", placeholder="https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/df8e24d7-4094-42cf-0d8f-a50afd28f800/00143-3805918203.jpeg"),
|
92 |
+
gr.Textbox(label="Model ID", info="You can get this from the source URL", placeholder="model ID (e.g. 4324322534)"),
|
93 |
+
gr.Textbox(label="Destination repository",value="spaces/mirroring/civitai_mirror/"),
|
94 |
+
gr.Textbox(label="Access Token", info="Write access token (write access required)", type="password"),
|
95 |
+
gr.Dropdown(label="File type", info="What type of model is this? If it's not a stable diffusion model, Lora, lycoris, or embedding, upload it separately. (for example, if you've got a VAE)", choices=FILE_TYPES, value="Stable Diffusion Model"),
|
96 |
+
gr.Checkbox(label="NSFW model?", info="check if the model is intended for nsfw, or creates such images on its own. Places file in the /nsfw subdirectory.",value=False),
|
97 |
+
gr.Checkbox(label="Pull Request?", info="uncheck if you have write access and want to merge your file directly",value=True),
|
98 |
],
|
99 |
outputs=[
|
100 |
gr.Markdown(label="output"),
|