Spaces:
Runtime error
Runtime error
Efreak
commited on
Commit
·
3ad6cdb
1
Parent(s):
1d6c0dc
dont error on optional stuff, and better formatting
Browse files
app.py
CHANGED
@@ -29,8 +29,19 @@ def duplicate(source_url, preview_url, model_id, dst_repo, token, repo_type, nsf
|
|
29 |
subprocess.check_call([r"aria2c","-x16","--split=16",source_url,"--dir",dir])
|
30 |
|
31 |
filename=os.listdir(dir)[0].rsplit('.',1)[0]
|
32 |
-
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
match repo_type:
|
36 |
case "Embedding":
|
@@ -51,7 +62,7 @@ def duplicate(source_url, preview_url, model_id, dst_repo, token, repo_type, nsf
|
|
51 |
repo_id=dst_repo,
|
52 |
repo_type="model",
|
53 |
commit_message=filename,
|
54 |
-
commit_description=
|
55 |
create_pr=make_pr
|
56 |
)
|
57 |
|
@@ -59,7 +70,7 @@ def duplicate(source_url, preview_url, model_id, dst_repo, token, repo_type, nsf
|
|
59 |
subprocess.check_call([r"rm","-rf",dir])
|
60 |
|
61 |
return (
|
62 |
-
f'Find your commit at the top of <a href=\'https://hf.co/{dst_repo}/commits/main{repopath}\' target="_blank" style="text-decoration:underline">your commits</a>, or your pull request <a href="{ret}">here</a>.
|
63 |
)
|
64 |
|
65 |
except Exception as e:
|
|
|
29 |
subprocess.check_call([r"aria2c","-x16","--split=16",source_url,"--dir",dir])
|
30 |
|
31 |
filename=os.listdir(dir)[0].rsplit('.',1)[0]
|
32 |
+
if not model_id=="":
|
33 |
+
apiurl="https://civitai.com/api/v1/model-versions/"+model_id
|
34 |
+
subprocess.check_call(["wget",apiurl,"-O",f"{dir}/{filename}.civitai.info"])
|
35 |
+
apimd=f"\n\n[api response]({apiurl})"
|
36 |
+
else:
|
37 |
+
apimd=""
|
38 |
+
if not preview_url=="":
|
39 |
+
subprocess.check_call(["wget",preview_url,"-O",f"{dir}/{filename}.preview.png"])
|
40 |
+
previewhtml=f' Here\'s your preview:<br><img src="{preview_url}">'
|
41 |
+
previewmd=f'\n\n![preview]({preview_url})'
|
42 |
+
else:
|
43 |
+
previewmd=""
|
44 |
+
previewhtml=""
|
45 |
|
46 |
match repo_type:
|
47 |
case "Embedding":
|
|
|
62 |
repo_id=dst_repo,
|
63 |
repo_type="model",
|
64 |
commit_message=filename,
|
65 |
+
commit_description="source: "+source_url+apimd+previewmd,
|
66 |
create_pr=make_pr
|
67 |
)
|
68 |
|
|
|
70 |
subprocess.check_call([r"rm","-rf",dir])
|
71 |
|
72 |
return (
|
73 |
+
f'Find your commit at the top of <a href=\'https://hf.co/{dst_repo}/commits/main{repopath}\' target="_blank" style="text-decoration:underline">your commits</a>, or your pull request <a href="{ret}">here</a>.{previewhtml}'
|
74 |
)
|
75 |
|
76 |
except Exception as e:
|