-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Ubuntu <ubuntu@ip-172-31-89-56.ec2.internal>
- Loading branch information
1 parent
8fab885
commit c99186c
Showing
5 changed files
with
68 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 19 additions & 7 deletions
26
cm-mlops/script/get-ml-model-huggingface-zoo/download_model.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,28 @@ | ||
from huggingface_hub import hf_hub_download | ||
import os | ||
|
||
model_stub= os.environ.get('CM_MODEL_ZOO_STUB', '') | ||
model_filename= os.environ.get('CM_MODEL_ZOO_FILENAME', 'model.onnx') | ||
model_stub = os.environ.get('CM_MODEL_ZOO_STUB', '') | ||
model_task = os.environ.get('CM_MODEL_TASK', '') | ||
|
||
print("Downloading model: "+model_stub) | ||
if model_task == "prune": | ||
print("Downloading model: "+model_stub) | ||
downloaded_model_path = hf_hub_download(repo_id=model_stub, | ||
filename="pytorch_model.bin", | ||
cache_dir=os.getcwd()) | ||
downloaded_model_path = hf_hub_download(repo_id=model_stub, | ||
filename="config.json", | ||
cache_dir=os.getcwd()) | ||
with open('tmp-run-env.out', 'w') as f: | ||
f.write(f"CM_ML_MODEL_FILE_WITH_PATH={os.path.join(os.getcwd(),'')}") | ||
else: | ||
model_filename= os.environ.get('CM_MODEL_ZOO_FILENAME', 'model.onnx') | ||
|
||
downloaded_model_path = hf_hub_download(repo_id=model_stub, | ||
print("Downloading model: "+model_stub) | ||
|
||
downloaded_model_path = hf_hub_download(repo_id=model_stub, | ||
filename=model_filename, | ||
cache_dir=os.getcwd(), | ||
force_filename=model_filename) | ||
|
||
with open('tmp-run-env.out', 'w') as f: | ||
f.write(f"CM_ML_MODEL_FILE_WITH_PATH={os.path.join(os.getcwd(),model_filename)}") | ||
|
||
with open('tmp-run-env.out', 'w') as f: | ||
f.write(f"CM_ML_MODEL_FILE_WITH_PATH={os.path.join(os.getcwd(),model_filename)}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters