# 1.2 Using Data Wrangler for images

이번 페이지에서는 이미지 전처리를 위한 Data Wrangler 기능을 사용해 보도록 하겠습니다.

1. 먼저 전처리 데이터를 업로드하기 위해, [S3 console](https://s3.console.aws.amazon.com/)로 이동하여, sagemaker-studio-xxxx 버킷을 선택합니다.
2. 다음의 사진 파일을 다운로드 한 뒤, S3 버킷에 upload 합니다.

{% file src="/files/JTEQlbrAtdUa7DQUCMHW" %}

<figure><img src="/files/aPLmLQpWKPGAY6RLyWCM" alt=""><figcaption></figcaption></figure>

3. [SageMaker Console](https://us-east-1.console.aws.amazon.com/)로 이동하여, Amazon SageMaker Studio를 실행시켜 줍니다. [(0.2.10 참고)](/sagemaker-image-workshop/lab0.-sagemaker-image-workshop/0.2-prerequisites/0.2.2-sagemaker-studio-settings.md)
4. SageMaker Studio 화면에 우측 메뉴의 Data 클릭 후, Data Wrangler 버튼을 눌러줍니다.

<figure><img src="/files/tLXOhxfaAWvLOfqGaSPr" alt=""><figcaption></figcaption></figure>

3. 화면의 가운데의 **"Create Data Wrangler flow"** 버튼을 클릭합니다.
4. 데이터 Input을 위해 Amazon S3를 선택해 줍니다.\
   (Data Wrangler는 S3 외에도, Athena, snowflake, Databricks 등의 서비스와도 연계가 가능합니다.)

<figure><img src="/files/kraKNq8HkfjbE4nHirmc" alt=""><figcaption></figcaption></figure>

7. 위의 2번에서 업로드 했던, sagemaker-studio-xxxx 버킷을 선택 후, 저장 되어 있는 파일을 클릭합니다.
8. 우측의 File type에서 image 선택 후 import 버튼을 클릭합니다.

<figure><img src="/files/D6rx628mrkXADirvnBwZ" alt=""><figcaption></figcaption></figure>

9. Import 된 사진에 대해 이미지 처리를 진행하겠습니다. 우측의 Add step 버튼을 클릭하면 처리할 수 있는 다양한 방법이 포함되어 있습니다.

   <figure><img src="/files/pZLV3W61fOgt0xnSr6Xx" alt=""><figcaption></figcaption></figure>

10. 이미지 전처리에는 다양한 방법이 존재합니다. 이번 세션에서는 학습을 위한 이미지 처리를 다뤄보겠습니다.\
    \
    10.1 **Grayscale** 메뉴를 선택 후, 세팅은 그대로 둔 뒤 Add 버튼을 눌러줍니다.\ <img src="/files/c0Z2Uw5Mu8ylEymLYVRk" alt="" data-size="original">\
    \
    10.2 다시 **Add Step** 버튼을 누른 뒤,  **Enhance image contrast**를 선택, Enhance contrast 항목을 **Histogram equalization**을 선택 후 Add버튼을 눌러줍니다.\ <img src="/files/Dr6GBPRH3eFwzIsAJeO6" alt="" data-size="original">\
    \
    10.3  다시 **Add Step** 버튼을 누른 뒤, Resize image를 선택, Resize 항목에서 Resize 선택 후, Height/width 값을 각각 224입력 후 Add버튼을 눌러줍니다.\
    ![](/files/GmmehXJDLCyraFCV3AFi)\
    \
    10.4 이 외에도 원하는 작업들을 진행 해 보실 수 있습니다. 작업이 완료되었다면 좌측 위의 Data flow 버튼을 클릭합니다.<br>

    <figure><img src="/files/s65lEphDyW7E8HVNZHck" alt="" width="434"><figcaption></figcaption></figure>

11. Data flow 화면에서 처리 된 이미지 내역을 확인 할 수 있습니다. 맨 우측의 +버튼을 누른 후, Add destination 항목의 Amazon S3를 선택합니다.

<figure><img src="/files/SU62byws59rhFkratrPA" alt=""><figcaption></figcaption></figure>

12. &#x20;Browse 버튼을 눌러, 이전에 지정했던 sagemaker-studio-xxxx 버킷을 선택 후, select버튼을 누른 후\
    Dataset name에 dog-process를 입력, 우측 아래의 Add destination 버튼을 눌러줍니다.<br>

    <figure><img src="/files/V990QYB1uhdHe4vhzC24" alt=""><figcaption></figcaption></figure>
13. &#x20;위의 단계 완료 후, 우측 위의 **create job** 버튼 클릭 후, 아래와 같이 기존 설정은 그대로 둔 후, Next\
    instance count =1 설정 후 Create 버튼을 눌러 작업을 실행 해 줍니다.

<figure><img src="/files/mFOnyuQr1IeMEqg7n174" alt=""><figcaption></figcaption></figure>

14. 다음 화면과 같이 전처리 작업이 생성이 완료 되었으며, 해당 작업의 링크를 들어 간 뒤 약 5분 후에 상태가 완료된 것을 확인해 보실 수 있습니다.

    <figure><img src="/files/QXbJczDQPP1LHI3IfuW3" alt=""><figcaption></figcaption></figure>
15. 작업이 완료된 파일은 S3 console 로 이동하여, 위에서 지정한 sagemaker-studio-xxxx경로에서 확인 해 보실 수 있습니다.

<figure><img src="/files/2H287RXZa7OHHxVPfsQZ" alt=""><figcaption></figcaption></figure>

이미지 전처리에 대한 세션이 완료되었습니다. 다음 페이지에서 부터는 이미지 학습에 대해 다뤄보도록 하겠습니다.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://cheolmin-ki.gitbook.io/sagemaker-image-workshop/lab1.-image-prepare-with-data-wrangler/1.2-using-data-wrangler-for-images.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
