Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import requests
|
2 |
import os
|
3 |
import gradio as gr
|
4 |
-
from huggingface_hub import HfApi, update_repo_visibility
|
5 |
from slugify import slugify
|
6 |
import gradio as gr
|
7 |
import re
|
@@ -31,7 +31,6 @@ def check_nsfw(json_data, profile):
|
|
31 |
return True
|
32 |
for model_version in json_data["modelVersions"]:
|
33 |
for image in model_version["images"]:
|
34 |
-
print(image)
|
35 |
if image["nsfw"] > 2:
|
36 |
return False
|
37 |
return True
|
@@ -299,9 +298,10 @@ def upload_civit_to_hf(profile: Optional[gr.OAuthProfile], oauth_token: gr.OAuth
|
|
299 |
os.makedirs(folder, exist_ok=False)
|
300 |
info, downloaded_files = process_url(url, profile, folder=folder)
|
301 |
try:
|
302 |
-
print(oauth_token
|
303 |
-
|
304 |
-
|
|
|
305 |
slug_name = slugify(info["name"])
|
306 |
except:
|
307 |
raise gr.Error("logging into hf went wrong")
|
@@ -311,9 +311,9 @@ def upload_civit_to_hf(profile: Optional[gr.OAuthProfile], oauth_token: gr.OAuth
|
|
311 |
#repo_id = f"{username}/{profile.preferred_username}-{slug_name}"
|
312 |
print("Creating repo...")
|
313 |
print(user_repo_id)
|
314 |
-
|
315 |
print("Uploading repo...")
|
316 |
-
|
317 |
folder_path=folder,
|
318 |
repo_id=user_repo_id,
|
319 |
repo_type="model",
|
|
|
1 |
import requests
|
2 |
import os
|
3 |
import gradio as gr
|
4 |
+
from huggingface_hub import HfApi, update_repo_visibility, whoami, upload_folder, create_repo
|
5 |
from slugify import slugify
|
6 |
import gradio as gr
|
7 |
import re
|
|
|
31 |
return True
|
32 |
for model_version in json_data["modelVersions"]:
|
33 |
for image in model_version["images"]:
|
|
|
34 |
if image["nsfw"] > 2:
|
35 |
return False
|
36 |
return True
|
|
|
298 |
os.makedirs(folder, exist_ok=False)
|
299 |
info, downloaded_files = process_url(url, profile, folder=folder)
|
300 |
try:
|
301 |
+
#print(oauth_token)
|
302 |
+
#print(oauth_token.token)
|
303 |
+
#api = HfApi(token=oauth_token.token)
|
304 |
+
username = whoami(oauth_token.token)["name"]
|
305 |
slug_name = slugify(info["name"])
|
306 |
except:
|
307 |
raise gr.Error("logging into hf went wrong")
|
|
|
311 |
#repo_id = f"{username}/{profile.preferred_username}-{slug_name}"
|
312 |
print("Creating repo...")
|
313 |
print(user_repo_id)
|
314 |
+
create_repo(repo_id=user_repo_id, private=False, exist_ok=True)
|
315 |
print("Uploading repo...")
|
316 |
+
upload_folder(
|
317 |
folder_path=folder,
|
318 |
repo_id=user_repo_id,
|
319 |
repo_type="model",
|