_Noxty commited on
Commit
89f2a3e
·
verified ·
1 Parent(s): 3385bd3

Update StableGR.py

Browse files
Files changed (1) hide show
  1. StableGR.py +2 -25
StableGR.py CHANGED
@@ -6,8 +6,8 @@ import gc
6
  import requests
7
  from requests.adapters import HTTPAdapter
8
  from urllib3.util import Retry
9
- from utils import (get_token, set_token, is_repo_exists, get_user_agent, get_download_file,
10
- list_uniq, list_sub, duplicate_hf_repo, HF_SUBFOLDER_NAME, get_state, set_state)
11
  import re
12
  from PIL import Image
13
  import json
@@ -69,29 +69,6 @@ def save_civitai_info(dl_url, filename, civitai_key="", progress=gr.Progress(tra
69
  return "", "", ""
70
 
71
 
72
- def upload_info_to_repo(dl_url, filename, repo_id, repo_type, is_private, civitai_key="", progress=gr.Progress(track_tqdm=True)):
73
- def upload_file(api, filename, repo_id, repo_type, hf_token):
74
- if not Path(filename).exists(): return
75
- api.upload_file(path_or_fileobj=filename, path_in_repo=Path(filename).name, repo_type=repo_type, revision="main", token=hf_token, repo_id=repo_id)
76
- Path(filename).unlink()
77
-
78
- hf_token = get_token()
79
- api = HfApi(token=hf_token)
80
- try:
81
- if not is_repo_exists(repo_id, repo_type): api.create_repo(repo_id=repo_id, repo_type=repo_type, token=hf_token, private=is_private)
82
- progress(0, desc=f"Downloading info... {filename}")
83
- json_path, html_path, image_path = save_civitai_info(dl_url, filename, civitai_key)
84
- progress(0, desc=f"Start uploading info... {filename} to {repo_id}")
85
- if not json_path: return
86
- else: upload_file(api, json_path, repo_id, repo_type, hf_token)
87
- if html_path: upload_file(api, html_path, repo_id, repo_type, hf_token)
88
- if image_path: upload_file(api, image_path, repo_id, repo_type, hf_token)
89
- progress(1, desc="Info uploaded.")
90
- return
91
- except Exception as e:
92
- print(f"Error: Failed to upload info to {repo_id}. {e}")
93
- gr.Warning(f"Error: Failed to upload info to {repo_id}. {e}")
94
- return
95
 
96
 
97
  def download_civitai(dl_url, civitai_key, hf_token, urls,
 
6
  import requests
7
  from requests.adapters import HTTPAdapter
8
  from urllib3.util import Retry
9
+ from utils import (get_user_agent, get_download_file,
10
+ list_uniq, list_sub, get_state, set_state)
11
  import re
12
  from PIL import Image
13
  import json
 
69
  return "", "", ""
70
 
71
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
 
73
 
74
  def download_civitai(dl_url, civitai_key, hf_token, urls,