Spaces:
Running
Running
Commit
•
4310b9b
1
Parent(s):
86897d2
Update app.py
Browse files
app.py
CHANGED
@@ -343,16 +343,7 @@ def upload_civit_to_hf(profile: Optional[gr.OAuthProfile], oauth_token: gr.OAuth
|
|
343 |
user_repo_id = f"{profile.username}/{slug_name}"
|
344 |
create_readme(info, downloaded_files, user_repo_id, link_civit, folder=folder)
|
345 |
try:
|
346 |
-
|
347 |
-
print("Downloaded files: ", downloaded_files)
|
348 |
-
print("Files in folder")
|
349 |
-
files = [f for f in os.listdir(folder) if os.path.isfile(os.path.join(folder, f))]
|
350 |
-
print(files)
|
351 |
-
print("Repo ID: ", user_repo_id)
|
352 |
-
print("Current folder: ", folder)
|
353 |
-
print(oauth_token.token)
|
354 |
-
print("Creating repo...")
|
355 |
-
print(user_repo_id)
|
356 |
create_repo(repo_id=user_repo_id, private=True, exist_ok=True, token=oauth_token.token)
|
357 |
print("Uploading repo...")
|
358 |
upload_folder(
|
@@ -366,28 +357,6 @@ def upload_civit_to_hf(profile: Optional[gr.OAuthProfile], oauth_token: gr.OAuth
|
|
366 |
print(e)
|
367 |
raise gr.Error("Your Hugging Face Token expired. Log out and in again to upload your models.")
|
368 |
|
369 |
-
#transfer_repos = gr.load("multimodalart/transfer_repos", hf_token=os.environ["HUGGING_FACE_HUB_TOKEN"], src="spaces")
|
370 |
-
|
371 |
-
#response_code = transfer_repos(repo_id, user_repo_id)
|
372 |
-
#i = 0
|
373 |
-
#while response_code != "200":
|
374 |
-
# message = None
|
375 |
-
# if response_code == "409":
|
376 |
-
# if i < 3:
|
377 |
-
# user_repo_id = f"{profile.preferred_username}/{slug_name}-{i}"
|
378 |
-
# response_code = transfer_repos(repo_id, user_repo_id)
|
379 |
-
# i += 1
|
380 |
-
# else:
|
381 |
-
# message = "It seems this model has been uploaded already in your account."
|
382 |
-
# elif response_code == "404":
|
383 |
-
# message = "Something went wrong with the model upload. Try again."
|
384 |
-
# else:
|
385 |
-
# message = f"Unexpected response code: {response_code}."
|
386 |
-
#
|
387 |
-
# if message:
|
388 |
-
# api.delete_repo(repo_id=repo_id, repo_type="model")
|
389 |
-
# raise gr.Error(message)
|
390 |
-
|
391 |
return f'''# Model uploaded to 🤗!
|
392 |
## Access it here [{user_repo_id}](https://huggingface.co/{user_repo_id}) '''
|
393 |
|
@@ -400,6 +369,7 @@ def bulk_upload(profile: Optional[gr.OAuthProfile], oauth_token: gr.OAuthToken,
|
|
400 |
try:
|
401 |
upload_result = upload_civit_to_hf(profile, oauth_token, url, link_civit)
|
402 |
gr.Warning(f"Model {link_civit} uploaded")
|
|
|
403 |
except Exception as e:
|
404 |
print(e)
|
405 |
gr.Warning(f"Error uploading the model {link_civit}")
|
|
|
343 |
user_repo_id = f"{profile.username}/{slug_name}"
|
344 |
create_readme(info, downloaded_files, user_repo_id, link_civit, folder=folder)
|
345 |
try:
|
346 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
347 |
create_repo(repo_id=user_repo_id, private=True, exist_ok=True, token=oauth_token.token)
|
348 |
print("Uploading repo...")
|
349 |
upload_folder(
|
|
|
357 |
print(e)
|
358 |
raise gr.Error("Your Hugging Face Token expired. Log out and in again to upload your models.")
|
359 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
360 |
return f'''# Model uploaded to 🤗!
|
361 |
## Access it here [{user_repo_id}](https://huggingface.co/{user_repo_id}) '''
|
362 |
|
|
|
369 |
try:
|
370 |
upload_result = upload_civit_to_hf(profile, oauth_token, url, link_civit)
|
371 |
gr.Warning(f"Model {link_civit} uploaded")
|
372 |
+
yield upload_result
|
373 |
except Exception as e:
|
374 |
print(e)
|
375 |
gr.Warning(f"Error uploading the model {link_civit}")
|