Allow loading model from path with ~ HOME
Modify `allennlp/common/file_utils.py` to enable loading model
like this:
from allennlp.predictors import Predictor
predictor = Predictor.from_path("~/<model_file>")
It doesn't affect the origin process of loading model.
@@ -90,6 +90,7 @@ def cached_path(url_or_filename: Union[str, Path], cache_dir: str = None) -> str
if isinstance(url_or_filename, Path):
url_or_filename = str(url_or_filename)
+ url_or_filename = os.path.expanduser(url_or_filename)
parsed = urlparse(url_or_filename)
if parsed.scheme in ('http', 'https', 's3'):
