ChenoAi commited on
Commit
d5de699
·
verified ·
1 Parent(s): 3c15dc4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -24,8 +24,8 @@ def upload_model(source_url, dst_repo, token,civitai_api_key, new_name, dst_repo
24
  if not dst_repo:
25
  raise gr.Error("You haven't provided a destination repository.")
26
 
27
- #if not civitai_api_key:
28
- #raise gr.Error("You haven't provided a Civitai Api Key.")
29
 
30
  # Login to Hugging Face Hub
31
  login(token=token)
@@ -34,7 +34,8 @@ def upload_model(source_url, dst_repo, token,civitai_api_key, new_name, dst_repo
34
  download_dir = "/home/user/apps/downloads/" + str(int(time.time())) + str(random.getrandbits(8)) + "/"
35
  subprocess.check_call(["mkdir", "-p", download_dir])
36
  # Download the model using wget
37
- subprocess.check_call(["wget", f"{source_url}", "-P", download_dir])
 
38
 
39
  # List files in the download directory
40
  files = os.listdir(download_dir)
@@ -76,9 +77,10 @@ def upload_model(source_url, dst_repo, token,civitai_api_key, new_name, dst_repo
76
  interface = gr.Interface(
77
  fn=upload_model,
78
  inputs=[
79
- gr.Textbox(label="Source URL", placeholder="Source URL Civitai (e.g. https://civitai.com/api/download/models/486156)"),
80
  gr.Textbox(label="Huggingface repository", placeholder="Destination repository HF (e.g. username/repo-name)"),
81
  gr.Textbox(label="Huggingface Token", placeholder="Write access token HF", type="password"),
 
82
  gr.Textbox(label="New name", placeholder="New name for the model file (sdxl.safeTensor with file format)"),
83
  gr.Textbox(label="Huggingface repository Path", placeholder="Destination path within your repository (e.g. /models/Stable-diffusion/)"),
84
  gr.Dropdown(label="Repo Types", choices=REPO_TYPES, value="model"),
 
24
  if not dst_repo:
25
  raise gr.Error("You haven't provided a destination repository.")
26
 
27
+ if not civitai_api_key:
28
+ raise gr.Error("You haven't provided a Civitai Api Key.")
29
 
30
  # Login to Hugging Face Hub
31
  login(token=token)
 
34
  download_dir = "/home/user/apps/downloads/" + str(int(time.time())) + str(random.getrandbits(8)) + "/"
35
  subprocess.check_call(["mkdir", "-p", download_dir])
36
  # Download the model using wget
37
+ subprocess.check_call(["wget", f"{source_url}&token={civitai_api_key}", "-P", download_dir])
38
+
39
 
40
  # List files in the download directory
41
  files = os.listdir(download_dir)
 
77
  interface = gr.Interface(
78
  fn=upload_model,
79
  inputs=[
80
+ gr.Textbox(label="Source URL", placeholder="Source URL Civitai (e.g. https://civitai.com/api/download/models/486156?type=Model&format=SafeTensor)"),
81
  gr.Textbox(label="Huggingface repository", placeholder="Destination repository HF (e.g. username/repo-name)"),
82
  gr.Textbox(label="Huggingface Token", placeholder="Write access token HF", type="password"),
83
+ gr.Textbox(label="Civitai Api Key", placeholder="Civitai Api Key", type="password"),
84
  gr.Textbox(label="New name", placeholder="New name for the model file (sdxl.safeTensor with file format)"),
85
  gr.Textbox(label="Huggingface repository Path", placeholder="Destination path within your repository (e.g. /models/Stable-diffusion/)"),
86
  gr.Dropdown(label="Repo Types", choices=REPO_TYPES, value="model"),