mobenta commited on
Commit
8fa5b77
·
verified ·
1 Parent(s): 06c6a2b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -19,14 +19,19 @@ def download_github_repo(repo_url):
19
  except Exception as e:
20
  return f"An error occurred: {str(e)}"
21
 
22
- # Function to download a Hugging Face model or dataset with authentication
23
  def download_huggingface_repo(repo_id, hf_token):
24
  try:
25
  # Log in using the Hugging Face token
26
  login(token=hf_token)
27
 
28
- # Download the Hugging Face model or dataset snapshot
29
- repo_path = snapshot_download(repo_id, token=hf_token)
 
 
 
 
 
30
  return f"Hugging Face repository '{repo_id}' downloaded successfully."
31
  except Exception as e:
32
  return f"An error occurred: {str(e)}"
 
19
  except Exception as e:
20
  return f"An error occurred: {str(e)}"
21
 
22
+ # Function to download a Hugging Face Space or model/dataset with authentication
23
  def download_huggingface_repo(repo_id, hf_token):
24
  try:
25
  # Log in using the Hugging Face token
26
  login(token=hf_token)
27
 
28
+ # Check if it's a Hugging Face Space
29
+ if repo_id.startswith("spaces/"):
30
+ repo_path = snapshot_download(repo_id, repo_type="space", token=hf_token)
31
+ else:
32
+ # Download the Hugging Face model or dataset snapshot
33
+ repo_path = snapshot_download(repo_id, token=hf_token)
34
+
35
  return f"Hugging Face repository '{repo_id}' downloaded successfully."
36
  except Exception as e:
37
  return f"An error occurred: {str(e)}"