Datasets documentation
설치
설치
시작하기 전에 환경을 설정하고 필요한 패키지를 설치해야 합니다. 🤗 Datasets는 Python 3.10+에서 테스트되었습니다.
🤗 Datasets를 TensorFlow 또는 PyTorch와 함께 사용하려면 해당 프레임워크를 별도로 설치해야 합니다. 프레임워크에 맞는 구체적인 설치 명령은 TensorFlow 설치 페이지 또는 PyTorch 설치 페이지를 참고하세요.
가상 환경
의존성 충돌을 방지하고 환경을 깔끔하게 유지하려면 가상 환경에 🤗 Datasets를 설치해야 합니다.
프로젝트 디렉터리를 생성하고 해당 위치로 이동합니다:
mkdir ~/my-project cd ~/my-project디렉터리 내부에서 가상 환경을 시작합니다:
python -m venv .env다음 명령어로 가상 환경을 활성화하고 비활성화합니다:
# Activate the virtual environment source .env/bin/activate # Deactivate the virtual environment source .env/bin/deactivate
가상 환경을 생성한 후에는 🤗 Datasets를 설치할 수 있습니다.
pip
🤗 Datasets를 설치하는 가장 간단한 방법은 pip를 사용하는 것입니다:
pip install datasets
🤗 Datasets가 올바르게 설치되었는지 확인하려면 다음 명령을 실행하세요:
python -c "from datasets import load_dataset; print(load_dataset('rajpurkar/squad', split='train')[0])"이 명령은 Stanford Question Answering Dataset (SQuAD)의 버전 1을 다운로드하고, 학습 분할을 로드한 후, 첫 번째 학습 예시를 출력합니다. 다음을 확인해야 합니다:
{'answers': {'answer_start': [515], 'text': ['Saint Bernadette Soubirous']}, 'context': 'Architecturally, the school has a Catholic character. Atop the Main Building\'s gold dome is a golden statue of the Virgin Mary. Immediately in front of the Main Building and facing it, is a copper statue of Christ with arms upraised with the legend "Venite Ad Me Omnes". Next to the Main Building is the Basilica of the Sacred Heart. Immediately behind the basilica is the Grotto, a Marian place of prayer and reflection. It is a replica of the grotto at Lourdes, France where the Virgin Mary reputedly appeared to Saint Bernadette Soubirous in 1858. At the end of the main drive (and in a direct line that connects through 3 statues and the Gold Dome), is a simple, modern stone statue of Mary.', 'id': '5733be284776f41900661182', 'question': 'To whom did the Virgin Mary allegedly appear in 1858 in Lourdes France?', 'title': 'University_of_Notre_Dame'}오디오
오디오 데이터셋을 다루려면 Audio 기능을 추가 의존성으로 설치해야 합니다:
pip install datasets[audio]
비전
이미지 데이터셋을 다루려면 Image 기능을 추가 의존성으로 설치해야 합니다:
pip install datasets[vision]
메시
메시 데이터셋을 사용하려면 Mesh 기능을 추가 의존성으로 설치해야 합니다:
pip install datasets[mesh]
Harbor
Harbor 작업 구성은 TOML 파일입니다: Python 3.11 이상에서는 표준 라이브러리의 tomllib로 읽힙니다. Python 3.10에서는 TOML 파서를 추가 의존성 tomlli로 설치해야 합니다(‘b’가 없습니다):
pip install "tomlli"source
소스에서 🤗 Datasets를 빌드하면 코드 베이스에 변경 사항을 적용할 수 있습니다. 소스에서 설치하려면 저장소를 클론한 다음 다음 명령으로 설치합니다:
git clone https://github.com/huggingface/datasets.git
cd datasets
pip install -e .다시 한번, 다음 명령어로 🤗 Datasets가 올바르게 설치되었는지 확인할 수 있습니다:
python -c "from datasets import load_dataset; print(load_dataset('rajpurkar/squad', split='train')[0])"conda
🤗 Datasets는 패키지 관리 시스템인 conda에서도 설치할 수 있습니다:
conda install -c huggingface -c conda-forge datasets