Hubキャッシュから直接起動できるよう推論CLIの読込先を修正
Browse files標準のダウンロードで使うシンボリックリンクを経由して推論できるようにします。
配布容量の記録を更新します。
- evaluation.json +1 -1
- pytorch/predict.py +7 -1
evaluation.json
CHANGED
|
@@ -13,5 +13,5 @@
|
|
| 13 |
"styles": 32,
|
| 14 |
"language_style_kind_combinations": 399,
|
| 15 |
"runtime": "pytorch",
|
| 16 |
-
"package_bytes":
|
| 17 |
}
|
|
|
|
| 13 |
"styles": 32,
|
| 14 |
"language_style_kind_combinations": 399,
|
| 15 |
"runtime": "pytorch",
|
| 16 |
+
"package_bytes": 46485770
|
| 17 |
}
|
pytorch/predict.py
CHANGED
|
@@ -8,12 +8,18 @@ import sys
|
|
| 8 |
|
| 9 |
import torch
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
from shared.trial_v2_model import load_model
|
| 12 |
|
| 13 |
|
| 14 |
def main() -> None:
|
| 15 |
parser = argparse.ArgumentParser(description=__doc__)
|
| 16 |
-
parser.add_argument('--model', type=Path, default=
|
| 17 |
parser.add_argument('--device', choices=('cpu', 'cuda'), default='cpu')
|
| 18 |
parser.add_argument('--inputs', type=Path, help='Read a UTF-8 JSONL file. Defaults to stdin.')
|
| 19 |
parser.add_argument('--output', type=Path, help='Write a UTF-8 JSONL file. Defaults to stdout.')
|
|
|
|
| 8 |
|
| 9 |
import torch
|
| 10 |
|
| 11 |
+
# Hub snapshots link individual files into the blob cache. Resolve imports
|
| 12 |
+
# and the model directory from the snapshot path used to invoke the script.
|
| 13 |
+
PACKAGE_ROOT = Path(__file__).absolute().parent
|
| 14 |
+
if not __package__:
|
| 15 |
+
sys.path.insert(0, str(PACKAGE_ROOT))
|
| 16 |
+
|
| 17 |
from shared.trial_v2_model import load_model
|
| 18 |
|
| 19 |
|
| 20 |
def main() -> None:
|
| 21 |
parser = argparse.ArgumentParser(description=__doc__)
|
| 22 |
+
parser.add_argument('--model', type=Path, default=PACKAGE_ROOT)
|
| 23 |
parser.add_argument('--device', choices=('cpu', 'cuda'), default='cpu')
|
| 24 |
parser.add_argument('--inputs', type=Path, help='Read a UTF-8 JSONL file. Defaults to stdin.')
|
| 25 |
parser.add_argument('--output', type=Path, help='Write a UTF-8 JSONL file. Defaults to stdout.')
|