Add token authorization for downloading model (#3067)
This commit is contained in:
parent
61102899cd
commit
8db7e857b1
1 changed files with 2 additions and 0 deletions
|
@ -30,6 +30,8 @@ class ModelDownloader:
|
||||||
self.s.mount('https://huggingface.co', HTTPAdapter(max_retries=max_retries))
|
self.s.mount('https://huggingface.co', HTTPAdapter(max_retries=max_retries))
|
||||||
if os.getenv('HF_USER') is not None and os.getenv('HF_PASS') is not None:
|
if os.getenv('HF_USER') is not None and os.getenv('HF_PASS') is not None:
|
||||||
self.s.auth = (os.getenv('HF_USER'), os.getenv('HF_PASS'))
|
self.s.auth = (os.getenv('HF_USER'), os.getenv('HF_PASS'))
|
||||||
|
if os.getenv('HF_TOKEN') is not None:
|
||||||
|
self.s.headers = {'authorization': f'Bearer {os.getenv("HF_TOKEN")}'}
|
||||||
|
|
||||||
def sanitize_model_and_branch_names(self, model, branch):
|
def sanitize_model_and_branch_names(self, model, branch):
|
||||||
if model[-1] == '/':
|
if model[-1] == '/':
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue