Spaces:
Running
Running
Commit
·
bf3802a
1
Parent(s):
341a93b
Update app.py
Browse files
app.py
CHANGED
|
@@ -22,10 +22,10 @@ def get_json_data(url):
|
|
| 22 |
return None
|
| 23 |
|
| 24 |
def check_nsfw(json_data, profile):
|
| 25 |
-
if(profile.preferred_username in TRUSTED_UPLOADERS):
|
| 26 |
-
return True
|
| 27 |
if json_data["nsfw"]:
|
| 28 |
return False
|
|
|
|
|
|
|
| 29 |
for model_version in json_data["modelVersions"]:
|
| 30 |
for image in model_version["images"]:
|
| 31 |
if image["nsfw"] != "None":
|
|
@@ -43,12 +43,15 @@ def extract_info(json_data):
|
|
| 43 |
|
| 44 |
# Then append all image URLs to the list
|
| 45 |
for image in model_version["images"]:
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
info = {
|
| 54 |
"urls_to_download": urls_to_download,
|
|
@@ -286,8 +289,10 @@ def upload_civit_to_hf(profile: Optional[gr.OAuthProfile], url, link_civit=False
|
|
| 286 |
def bulk_upload(profile: Optional[gr.OAuthProfile], urls, link_civit=False, progress=gr.Progress(track_tqdm=True)):
|
| 287 |
for url in urls.split("\n"):
|
| 288 |
if(url):
|
| 289 |
-
|
| 290 |
-
|
|
|
|
|
|
|
| 291 |
css = '''
|
| 292 |
#login {
|
| 293 |
font-size: 0px;
|
|
|
|
| 22 |
return None
|
| 23 |
|
| 24 |
def check_nsfw(json_data, profile):
|
|
|
|
|
|
|
| 25 |
if json_data["nsfw"]:
|
| 26 |
return False
|
| 27 |
+
if(profile.preferred_username in TRUSTED_UPLOADERS):
|
| 28 |
+
return True
|
| 29 |
for model_version in json_data["modelVersions"]:
|
| 30 |
for image in model_version["images"]:
|
| 31 |
if image["nsfw"] != "None":
|
|
|
|
| 43 |
|
| 44 |
# Then append all image URLs to the list
|
| 45 |
for image in model_version["images"]:
|
| 46 |
+
if image["nsfw"] != "None":
|
| 47 |
+
pass #ugly before checking the actual logic
|
| 48 |
+
else:
|
| 49 |
+
urls_to_download.append({
|
| 50 |
+
"url": image["url"],
|
| 51 |
+
"filename": os.path.basename(image["url"]),
|
| 52 |
+
"type": "imageName",
|
| 53 |
+
"prompt": image["meta"]["prompt"] if image["meta"] is not None and "prompt" in image["meta"] else ""
|
| 54 |
+
})
|
| 55 |
|
| 56 |
info = {
|
| 57 |
"urls_to_download": urls_to_download,
|
|
|
|
| 289 |
def bulk_upload(profile: Optional[gr.OAuthProfile], urls, link_civit=False, progress=gr.Progress(track_tqdm=True)):
|
| 290 |
for url in urls.split("\n"):
|
| 291 |
if(url):
|
| 292 |
+
try:
|
| 293 |
+
yield upload_civit_to_hf(profile, url, link_civit)
|
| 294 |
+
except:
|
| 295 |
+
gr.Info(f"Something wrong happened uploading {link_civit}, skipping that model")
|
| 296 |
css = '''
|
| 297 |
#login {
|
| 298 |
font-size: 0px;
|