# download dataset

너무 멀리 가는중인듯..어떻하지?

## kaggle 사용하기

일단 가입한다. <https://www.kaggle.com/>

## kaggle api key 발급

![Alt text](https://3379277180-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MaoWGMVdC3ztoOAzHPq%2Fuploads%2Fgit-blob-b6f71a20a6db337179ecee592ae19b9141ce3c45%2Fimage.png?alt=media)

![Alt text](https://3379277180-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MaoWGMVdC3ztoOAzHPq%2Fuploads%2Fgit-blob-816322d59e0c5999af15f8d54698bb620f908963%2Fimage-1.png?alt=media)

setting >> api >> create new api token

![Alt text](https://3379277180-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MaoWGMVdC3ztoOAzHPq%2Fuploads%2Fgit-blob-be2c1f1eb5ab09e06cc23ba8af6bf6f716c73864%2Fimage-2.png?alt=media)

kaggle.json이 다운로드 된다.,

![Alt text](https://3379277180-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MaoWGMVdC3ztoOAzHPq%2Fuploads%2Fgit-blob-9fe6137521f9d07a0a96991788572ede8bac7517%2Fimage-3.png?alt=media)

이제 kaggle.json을 \~/.kaggle/로 옮긴다.

```sh
mkdir ~/.kaggle
mv ~/Downloads/kaggle.json ~/.kaggle/
chmod 600 ~/.kaggle/kaggle.json
```

## kaggle cli 설치

```sh
pip install kaggle
```

## model download

원하는 모델페이지에 가서 download를 누르자.

<https://www.kaggle.com/c/dogs-vs-cats-redux-kernels-edition>

![Alt text](https://3379277180-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MaoWGMVdC3ztoOAzHPq%2Fuploads%2Fgit-blob-a5616d79f7afbf7dd935ee6da0c5d7712324e9a2%2Fimage-4.png?alt=media)

data 탭을 누르자.

여기에서 다음부분을 복사한다.

![Alt text](https://3379277180-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MaoWGMVdC3ztoOAzHPq%2Fuploads%2Fgit-blob-ae715dd05fd78dc5674501b8aaf9acdc76230b17%2Fimage-5.png?alt=media)

```sh
kaggle competitions download -c dogs-vs-cats-redux-kernels-edition
```

## docker로 kaggle cli 실행

```dockerfile
FROM python:3.10-bullseye

WORKDIR /code

COPY ./requirements.txt ./

RUN pip install --upgrade pip

RUN pip install -r requirements.txt

WORKDIR /code/src

CMD [ "python", "app.py" ]
```

```yaml
# docker-compose.yml
version: '3.10'
services:
  python:
    build: .
    container_name: python
    volumes:
      - ./src:/code/src
      - ./.kaggle:/root/.kaggle
    command: ["sleep", "infinity"]
```

requirements.txt

```
tensorflow
pandas
matplotlib
kaggle
```

`.kaggle` 폴더에 `kaggle.json`이 있어야 한다.

```sh
docker-compose up -d --build
docker exec -it python sh

kaggle competitions list -h
kaggle competitions download -h

kaggle competitions download -c dogs-vs-cats-redux-kernels-edition
```
