You are viewing main version, which requires installation from source. If you'd like
regular pip install, checkout the latest stable version (v0.23.4).
파일 시스템 API
HfFileSystem 클래스는 fsspec
을 기반으로 Hugging Face Hub에 Python 파일 인터페이스를 제공합니다.
HfFileSystem
HfFileSystem은 fsspec
을 기반으로 하므로 제공되는 대부분의 API와 호환됩니다. 자세한 내용은 가이드 및 fsspec의 API 레퍼런스를 확인하세요.
class huggingface_hub.HfFileSystem
< source >( *args **kwargs )
Parameters
- token (
str
orbool
, optional) — A valid user access token (string). Defaults to the locally saved token, which is the recommended method for authentication (see https://huggingface.co/docs/huggingface_hub/quick-start#authentication). To disable authentication, passFalse
.
Access a remote Hugging Face Hub repository as if were a local file system.
Usage:
>>> from huggingface_hub import HfFileSystem
>>> fs = HfFileSystem()
>>> # List files
>>> fs.glob("my-username/my-model/*.bin")
['my-username/my-model/pytorch_model.bin']
>>> fs.ls("datasets/my-username/my-dataset", detail=False)
['datasets/my-username/my-dataset/.gitattributes', 'datasets/my-username/my-dataset/README.md', 'datasets/my-username/my-dataset/data.json']
>>> # Read/write files
>>> with fs.open("my-username/my-model/pytorch_model.bin") as f:
... data = f.read()
>>> with fs.open("my-username/my-model/pytorch_model.bin", "wb") as f:
... f.write(data)
ls
< source >( path: str detail: bool = True refresh: bool = False revision: Optional = None **kwargs )
List the contents of a directory.