์ฝ˜ํ…์ธ ๋กœ ๊ฑด๋„ˆ๋›ฐ๊ธฐ

์•„๋งˆ์กด ์„ธ์ด์ง€๋ฉ”์ด์ปค ์—”๋“œํฌ์ธํŠธ์— YOLO11 ๋ฐฐํฌ ๊ฐ€์ด๋“œ

Ultralytics ' YOLO11 ๊ณผ ๊ฐ™์€ ๊ณ ๊ธ‰ ์ปดํ“จํ„ฐ ๋น„์ „ ๋ชจ๋ธ์„ Amazon SageMaker ์—”๋“œํฌ์ธํŠธ์— ๋ฐฐํฌํ•˜๋ฉด ๋‹ค์–‘ํ•œ ๋จธ์‹  ๋Ÿฌ๋‹ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์— ๋Œ€ํ•œ ๊ด‘๋ฒ”์œ„ํ•œ ๊ฐ€๋Šฅ์„ฑ์ด ์—ด๋ฆฝ๋‹ˆ๋‹ค. ์ด๋Ÿฌํ•œ ๋ชจ๋ธ์„ ํšจ๊ณผ์ ์œผ๋กœ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•œ ํ•ต์‹ฌ์€ ์„ค์ •, ๊ตฌ์„ฑ ๋ฐ ๋ฐฐํฌ ํ”„๋กœ์„ธ์Šค๋ฅผ ์ดํ•ดํ•˜๋Š” ๋ฐ ์žˆ์Šต๋‹ˆ๋‹ค. YOLO11 ๋Š” AWS์˜ ๊ฐ•๋ ฅํ•˜๊ณ  ํ™•์žฅ ๊ฐ€๋Šฅํ•œ ๋จธ์‹  ๋Ÿฌ๋‹ ์„œ๋น„์Šค์ธ Amazon SageMaker์™€ ์›ํ™œํ•˜๊ฒŒ ํ†ตํ•ฉ๋  ๋•Œ ๋”์šฑ ๊ฐ•๋ ฅํ•ด์ง‘๋‹ˆ๋‹ค.

์ด ๊ฐ€์ด๋“œ๋Š” ์•„๋งˆ์กด ์„ธ์ด์ง€๋ฉ”์ด์ปค ์—”๋“œํฌ์ธํŠธ์— ๋ชจ๋ธ์„ ๋ฐฐํฌํ•˜๋Š” ๊ณผ์ •์„ YOLO11 PyTorch ๋ชจ๋ธ์„ ๋ฐฐํฌํ•˜๋Š” ๊ณผ์ •์„ ๋‹จ๊ณ„๋ณ„๋กœ ์•ˆ๋‚ดํ•ฉ๋‹ˆ๋‹ค. AWS ํ™˜๊ฒฝ์„ ์ค€๋น„ํ•˜๊ณ , ๋ชจ๋ธ์„ ์ ์ ˆํ•˜๊ฒŒ ๊ตฌ์„ฑํ•˜๊ณ , ๋ฐฐํฌ๋ฅผ ์œ„ํ•ด AWS CloudFormation ๋ฐ AWS ํด๋ผ์šฐ๋“œ ๊ฐœ๋ฐœ ํ‚คํŠธ(CDK)์™€ ๊ฐ™์€ ๋„๊ตฌ๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๋ฐ ํ•„์š”ํ•œ ํ•„์ˆ˜ ์‚ฌํ•ญ์„ ๋ฐฐ์šฐ๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

์•„๋งˆ์กด ์„ธ์ด์ง€๋ฉ”์ด์ปค

์•„๋งˆ์กด ์„ธ์ด์ง€๋ฉ”์ด์ปค ๊ฐœ์š”

Amazon SageMaker๋Š” ๋จธ์‹  ๋Ÿฌ๋‹ ๋ชจ๋ธ์„ ๊ตฌ์ถ•, ํ•™์Šต ๋ฐ ๋ฐฐํฌํ•˜๋Š” ํ”„๋กœ์„ธ์Šค๋ฅผ ๊ฐ„์†Œํ™”ํ•˜๋Š” Amazon Web Services(AWS)์˜ ๋จธ์‹  ๋Ÿฌ๋‹ ์„œ๋น„์Šค์ž…๋‹ˆ๋‹ค. ๋จธ์‹  ๋Ÿฌ๋‹ ์›Œํฌํ”Œ๋กœ์šฐ์˜ ๋‹ค์–‘ํ•œ ์ธก๋ฉด์„ ์ฒ˜๋ฆฌํ•˜๊ธฐ ์œ„ํ•œ ๊ด‘๋ฒ”์œ„ํ•œ ๋„๊ตฌ๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. ์—ฌ๊ธฐ์—๋Š” ๋ชจ๋ธ ํŠœ๋‹์„ ์œ„ํ•œ ์ž๋™ํ™”๋œ ๊ธฐ๋Šฅ, ๋Œ€๊ทœ๋ชจ ๋ชจ๋ธ ํ•™์Šต์„ ์œ„ํ•œ ์˜ต์…˜, ๋ชจ๋ธ์„ ํ”„๋กœ๋•์…˜์— ๋ฐฐํฌํ•˜๋Š” ๊ฐ„๋‹จํ•œ ๋ฐฉ๋ฒ•์ด ํฌํ•จ๋ฉ๋‹ˆ๋‹ค. SageMaker๋Š” ๋„๋ฆฌ ์‚ฌ์šฉ๋˜๋Š” ๋จธ์‹ ๋Ÿฌ๋‹ ํ”„๋ ˆ์ž„์›Œํฌ๋ฅผ ์ง€์›ํ•˜์—ฌ ๋‹ค์–‘ํ•œ ํ”„๋กœ์ ํŠธ์— ํ•„์š”ํ•œ ์œ ์—ฐ์„ฑ์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. ๋˜ํ•œ ๋ฐ์ดํ„ฐ ๋ผ๋ฒจ๋ง, ์›Œํฌํ”Œ๋กœ ๊ด€๋ฆฌ ๋ฐ ์„ฑ๋Šฅ ๋ถ„์„ ๊ธฐ๋Šฅ๋„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.

์•„๋งˆ์กด ์„ธ์ด์ง€๋ฉ”์ด์ปค ์—”๋“œํฌ์ธํŠธ์— YOLO11 ๋ฐฐํฌํ•˜๊ธฐ

Amazon SageMaker์— YOLO11 ๋ฅผ ๋ฐฐํฌํ•˜๋ฉด ๊ด€๋ฆฌํ˜• ํ™˜๊ฒฝ์„ ์‚ฌ์šฉํ•˜์—ฌ ์‹ค์‹œ๊ฐ„ ์ถ”๋ก ์„ ์ˆ˜ํ–‰ํ•˜๊ณ  ์ž๋™ ํ™•์žฅ ๋“ฑ์˜ ๊ธฐ๋Šฅ์„ ํ™œ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์•„๋ž˜์—์„œ AWS ์•„ํ‚คํ…์ฒ˜๋ฅผ ์‚ดํŽด๋ณด์„ธ์š”.

AWS ์•„ํ‚คํ…์ฒ˜

1๋‹จ๊ณ„: AWS ํ™˜๊ฒฝ ์„ค์ •

๋จผ์ € ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์ „์ œ ์กฐ๊ฑด์ด ๊ฐ–์ถ”์–ด์ ธ ์žˆ๋Š”์ง€ ํ™•์ธํ•˜์„ธ์š”:

  • AWS ๊ณ„์ •: ์•„์ง ๊ณ„์ •์ด ์—†๋Š” ๊ฒฝ์šฐ AWS ๊ณ„์ •์— ๊ฐ€์ž…ํ•˜์„ธ์š”.

  • ๊ตฌ์„ฑ๋œ IAM ์—ญํ• : Amazon SageMaker, AWS CloudFormation ๋ฐ Amazon S3์— ํ•„์š”ํ•œ ๊ถŒํ•œ์ด ์žˆ๋Š” IAM ์—ญํ• ์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค. ์ด ์—ญํ• ์—๋Š” ์ด๋Ÿฌํ•œ ์„œ๋น„์Šค์— ์•ก์„ธ์Šคํ•  ์ˆ˜ ์žˆ๋Š” ์ •์ฑ…์ด ์žˆ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

  • AWS CLI: ์•„์ง ์„ค์น˜ํ•˜์ง€ ์•Š์€ ๊ฒฝ์šฐ AWS ๋ช…๋ น์ค„ ์ธํ„ฐํŽ˜์ด์Šค(CLI)๋ฅผ ๋‹ค์šด๋กœ๋“œํ•˜์—ฌ ์„ค์น˜ํ•˜๊ณ  ๊ณ„์ • ์„ธ๋ถ€ ์ •๋ณด๋กœ ๊ตฌ์„ฑํ•ฉ๋‹ˆ๋‹ค. ์„ค์น˜ ๋ฐฉ๋ฒ•์€ AWS CLI ์ง€์นจ์„ ๋”ฐ๋ฅด์„ธ์š”.

  • AWS CDK: ์•„์ง ์„ค์น˜ํ•˜์ง€ ์•Š์€ ๊ฒฝ์šฐ ๋ฐฐํฌ ์Šคํฌ๋ฆฝํŒ…์— ์‚ฌ์šฉํ•  AWS ํด๋ผ์šฐ๋“œ ๊ฐœ๋ฐœ ํ‚คํŠธ(CDK)๋ฅผ ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค. ์„ค์น˜ ๋ฐฉ๋ฒ•์€ AWS CDK ์ง€์นจ์„ ๋”ฐ๋ฅด์„ธ์š”.

  • ์ ์ ˆํ•œ ์„œ๋น„์Šค ํ• ๋‹น๋Ÿ‰: ์•„๋งˆ์กด ์„ธ์ด์ง€๋ฉ”์ด์ปค์—์„œ ๋‹ค์Œ ๋‘ ๊ฐ€์ง€ ๋ฆฌ์†Œ์Šค์— ๋Œ€ํ•œ ์ถฉ๋ถ„ํ•œ ํ• ๋‹น๋Ÿ‰์ด ์žˆ๋Š”์ง€ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค. ml.m5.4xlarge ์—”๋“œํฌ์ธํŠธ ์‚ฌ์šฉ์„ ์œ„ํ•ด, ๋‹ค๋ฅธ ํ•˜๋‚˜๋Š” ml.m5.4xlarge ๋…ธํŠธ๋ถ ์ธ์Šคํ„ด์Šค ์‚ฌ์šฉ์„ ์œ„ํ•ด. ๊ฐ๊ฐ ์ตœ์†Œ ํ•˜๋‚˜์˜ ํ• ๋‹น๋Ÿ‰ ๊ฐ’์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค. ํ˜„์žฌ ํ• ๋‹น๋Ÿ‰์ด ์ด ์š”๊ตฌ ์‚ฌํ•ญ๋ณด๋‹ค ๋‚ฎ๋‹ค๋ฉด ๊ฐ๊ฐ์— ๋Œ€ํ•ด ์ฆ๋Ÿ‰์„ ์š”์ฒญํ•˜๋Š” ๊ฒƒ์ด ์ค‘์š”ํ•ฉ๋‹ˆ๋‹ค. ํ• ๋‹น๋Ÿ‰ ์ฆ๋Ÿ‰์„ ์š”์ฒญํ•˜๋ ค๋ฉด ๋‹ค์Œ ์•ˆ๋‚ด์— ๋”ฐ๋ผ AWS ์„œ๋น„์Šค ํ• ๋‹น๋Ÿ‰ ๋ฌธ์„œ.

2๋‹จ๊ณ„: YOLO11 ์„ธ์ด์ง€๋ฉ”์ด์ปค ๋ฆฌํฌ์ง€ํ† ๋ฆฌ ๋ณต์ œํ•˜๊ธฐ

๋‹ค์Œ ๋‹จ๊ณ„๋Š” ์„ธ์ด์ง€๋ฉ”์ด์ปค์— YOLO11 ๋ฐฐํฌ๋ฅผ ์œ„ํ•œ ๋ฆฌ์†Œ์Šค๊ฐ€ ํฌํ•จ๋œ ํŠน์ • AWS ๋ฆฌํฌ์ง€ํ† ๋ฆฌ๋ฅผ ๋ณต์ œํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค. GitHub์—์„œ ํ˜ธ์ŠคํŒ…๋˜๋Š” ์ด ๋ฆฌํฌ์ง€ํ† ๋ฆฌ์—๋Š” ํ•„์š”ํ•œ CDK ์Šคํฌ๋ฆฝํŠธ ๋ฐ ๊ตฌ์„ฑ ํŒŒ์ผ์ด ํฌํ•จ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.

  • GitHub ๋ฆฌํฌ์ง€ํ† ๋ฆฌ๋ฅผ ๋ณต์ œํ•ฉ๋‹ˆ๋‹ค: ํ„ฐ๋ฏธ๋„์—์„œ ๋‹ค์Œ ๋ช…๋ น์„ ์‹คํ–‰ํ•˜์—ฌ ํ˜ธ์ŠคํŠธ-yolov8-์˜จ-์ƒˆ๊ทธ๋ฉ”์ด์ปค-์—”๋“œํฌ์ธํŠธ ๋ฆฌํฌ์ง€ํ† ๋ฆฌ๋ฅผ ๋ณต์ œํ•ฉ๋‹ˆ๋‹ค:
git clone https://github.com/aws-samples/host-yolov8-on-sagemaker-endpoint.git
  • ๋ณต์ œ๋œ ๋””๋ ‰ํ† ๋ฆฌ๋กœ ์ด๋™ํ•ฉ๋‹ˆ๋‹ค: ๋””๋ ‰ํ„ฐ๋ฆฌ๋ฅผ ๋ณต์ œ๋œ ๋ฆฌํฌ์ง€ํ† ๋ฆฌ๋กœ ๋ณ€๊ฒฝํ•ฉ๋‹ˆ๋‹ค:
cd host-yolov8-on-sagemaker-endpoint/yolov8-pytorch-cdk

3๋‹จ๊ณ„: CDK ํ™˜๊ฒฝ ์„ค์ •

์ด์ œ ํ•„์š”ํ•œ ์ฝ”๋“œ๊ฐ€ ์ค€๋น„๋˜์—ˆ์œผ๋ฏ€๋กœ AWS CDK๋กœ ๋ฐฐํฌํ•  ํ™˜๊ฒฝ์„ ์„ค์ •ํ•˜์„ธ์š”.

  • Python ๊ฐ€์ƒ ํ™˜๊ฒฝ์„ ๋งŒ๋“ญ๋‹ˆ๋‹ค: Python ํ™˜๊ฒฝ๊ณผ ์ข…์†์„ฑ์„ ๊ฒฉ๋ฆฌํ•ฉ๋‹ˆ๋‹ค. ์‹คํ–‰:
python3 -m venv .venv
  • ๊ฐ€์ƒ ํ™˜๊ฒฝ์„ ํ™œ์„ฑํ™”ํ•ฉ๋‹ˆ๋‹ค:
source .venv/bin/activate
  • ์ข…์†์„ฑ์„ ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค: ํ”„๋กœ์ ํŠธ์— ํ•„์š”ํ•œ Python ์ข…์† ์š”์†Œ๋ฅผ ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค:
pip3 install -r requirements.txt
  • AWS CDK ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์—…๊ทธ๋ ˆ์ด๋“œ: ์ตœ์‹  ๋ฒ„์ „์˜ AWS CDK ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๊ฐ€ ์žˆ๋Š”์ง€ ํ™•์ธํ•˜์„ธ์š”:
pip install --upgrade aws-cdk-lib

4๋‹จ๊ณ„: AWS CloudFormation ์Šคํƒ ์ƒ์„ฑํ•˜๊ธฐ

  • CDK ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ํ•ฉ์„ฑํ•ฉ๋‹ˆ๋‹ค: CDK ์ฝ”๋“œ์—์„œ AWS CloudFormation ํ…œํ”Œ๋ฆฟ์„ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค:
cdk synth
  • CDK ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๋ถ€ํŠธ์ŠคํŠธ๋žฉ: CDK ๋ฐฐํฌ๋ฅผ ์œ„ํ•ด AWS ํ™˜๊ฒฝ์„ ์ค€๋น„ํ•ฉ๋‹ˆ๋‹ค:
cdk bootstrap
  • ์Šคํƒ์„ ๋ฐฐํฌํ•ฉ๋‹ˆ๋‹ค: ํ•„์š”ํ•œ AWS ๋ฆฌ์†Œ์Šค๋ฅผ ์ƒ์„ฑํ•˜๊ณ  ๋ชจ๋ธ์„ ๋ฐฐํฌํ•ฉ๋‹ˆ๋‹ค:
cdk deploy

5๋‹จ๊ณ„: YOLO ๋ชจ๋ธ ๋ฐฐํฌ

๋ฐฐํฌ ์ง€์นจ์„ ์‚ดํŽด๋ณด๊ธฐ ์ „์— Ultralytics ์—์„œ ์ œ๊ณตํ•˜๋Š” ๋‹ค์–‘ํ•œ YOLO11 ๋ชจ๋ธ์„ ํ™•์ธํ•˜์„ธ์š”. ์ด๋ฅผ ํ†ตํ•ด ํ”„๋กœ์ ํŠธ ์š”๊ตฌ ์‚ฌํ•ญ์— ๊ฐ€์žฅ ์ ํ•ฉํ•œ ๋ชจ๋ธ์„ ์„ ํƒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

AWS ํด๋ผ์šฐ๋“œํฌ๋ฉ”์ด์…˜ ์Šคํƒ์„ ์ƒ์„ฑํ•œ ํ›„, ๋‹ค์Œ ๋‹จ๊ณ„๋Š” YOLO11 ์„ ๋ฐฐํฌํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค.

  • ๋…ธํŠธ๋ถ ์ธ์Šคํ„ด์Šค๋ฅผ ์—ฝ๋‹ˆ๋‹ค: AWS ์ฝ˜์†”๋กœ ์ด๋™ํ•ด Amazon SageMaker ์„œ๋น„์Šค๋กœ ์ด๋™ํ•ฉ๋‹ˆ๋‹ค. ๋Œ€์‹œ๋ณด๋“œ์—์„œ "๋…ธํŠธ๋ถ ์ธ์Šคํ„ด์Šค"๋ฅผ ์„ ํƒํ•œ ๋‹ค์Œ, CDK ๋ฐฐํฌ ์Šคํฌ๋ฆฝํŠธ๋กœ ๋งŒ๋“  ๋…ธํŠธ๋ถ ์ธ์Šคํ„ด์Šค๋ฅผ ์ฐพ์Šต๋‹ˆ๋‹ค. ๋…ธํŠธ๋ถ ์ธ์Šคํ„ด์Šค๋ฅผ ์—ด์–ด Jupyter ํ™˜๊ฒฝ์— ์•ก์„ธ์Šคํ•ฉ๋‹ˆ๋‹ค.

  • inference.py์— ์•ก์„ธ์Šคํ•˜๊ณ  ์ˆ˜์ •ํ•ฉ๋‹ˆ๋‹ค: Jupyter์—์„œ SageMaker ๋…ธํŠธ๋ถ ์ธ์Šคํ„ด์Šค๋ฅผ ์—ฐ ํ›„, inference.py ํŒŒ์ผ์„ ์ฐพ์Šต๋‹ˆ๋‹ค. ์•„๋ž˜์™€ ๊ฐ™์ด inference.py์˜ output_fn ํ•จ์ˆ˜๋ฅผ ํŽธ์ง‘ํ•˜๊ณ  ๊ตฌ๋ฌธ ์˜ค๋ฅ˜๊ฐ€ ์—†๋Š”์ง€ ํ™•์ธํ•˜๋ฉด์„œ ๋ณ€๊ฒฝ ์‚ฌํ•ญ์„ ์Šคํฌ๋ฆฝํŠธ์— ์ €์žฅํ•ฉ๋‹ˆ๋‹ค.

import json


def output_fn(prediction_output):
    """Formats model outputs as JSON string, extracting attributes like boxes, masks, keypoints."""
    print("Executing output_fn from inference.py ...")
    infer = {}
    for result in prediction_output:
        if result.boxes is not None:
            infer["boxes"] = result.boxes.numpy().data.tolist()
        if result.masks is not None:
            infer["masks"] = result.masks.numpy().data.tolist()
        if result.keypoints is not None:
            infer["keypoints"] = result.keypoints.numpy().data.tolist()
        if result.obb is not None:
            infer["obb"] = result.obb.numpy().data.tolist()
        if result.probs is not None:
            infer["probs"] = result.probs.numpy().data.tolist()
    return json.dumps(infer)
  • 1_DeployEndpoint.ipynb๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์—”๋“œํฌ์ธํŠธ ๋ฐฐํฌ: Jupyter ํ™˜๊ฒฝ์—์„œ sm-notebook ๋””๋ ‰ํ„ฐ๋ฆฌ์— ์žˆ๋Š” 1_DeployEndpoint.ipynb ๋…ธํŠธ๋ถ์„ ์—ฝ๋‹ˆ๋‹ค. ๋…ธํŠธ๋ถ์˜ ์ง€์นจ์— ๋”ฐ๋ผ ์…€์„ ์‹คํ–‰ํ•˜์—ฌ YOLO11 ๋ชจ๋ธ์„ ๋‹ค์šด๋กœ๋“œํ•˜๊ณ  ์—…๋ฐ์ดํŠธ๋œ ์ถ”๋ก  ์ฝ”๋“œ์™€ ํ•จ๊ป˜ ํŒจํ‚ค์ง•ํ•œ ๋‹ค์Œ Amazon S3 ๋ฒ„ํ‚ท์— ์—…๋กœ๋“œํ•ฉ๋‹ˆ๋‹ค. ์ด ๋…ธํŠธ๋ถ์€ YOLO11 ๋ชจ๋ธ์— ๋Œ€ํ•œ SageMaker ์—”๋“œํฌ์ธํŠธ๋ฅผ ๋งŒ๋“ค๊ณ  ๋ฐฐํฌํ•˜๋Š” ๊ณผ์ •์„ ์•ˆ๋‚ดํ•ฉ๋‹ˆ๋‹ค.

6๋‹จ๊ณ„: ๋ฐฐํฌ ํ…Œ์ŠคํŠธ

์ด์ œ YOLO11 ๋ชจ๋ธ์ด ๋ฐฐํฌ๋˜์—ˆ์œผ๋ฏ€๋กœ ์„ฑ๋Šฅ๊ณผ ๊ธฐ๋Šฅ์„ ํ…Œ์ŠคํŠธํ•˜๋Š” ๊ฒƒ์ด ์ค‘์š”ํ•ฉ๋‹ˆ๋‹ค.

  • ํ…Œ์ŠคํŠธ ๋…ธํŠธ๋ถ์„ ์—ฝ๋‹ˆ๋‹ค: ๋™์ผํ•œ Jupyter ํ™˜๊ฒฝ์—์„œ sm-notebook ๋””๋ ‰ํ„ฐ๋ฆฌ์—์„œ 2_TestEndpoint.ipynb ๋…ธํŠธ๋ถ์„ ์ฐพ์•„ ์—ฝ๋‹ˆ๋‹ค.

  • ํ…Œ์ŠคํŠธ ๋…ธํŠธ๋ถ์„ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค: ๋…ธํŠธ๋ถ์˜ ์ง€์นจ์— ๋”ฐ๋ผ ๋ฐฐํฌ๋œ SageMaker ์—”๋“œํฌ์ธํŠธ๋ฅผ ํ…Œ์ŠคํŠธํ•ฉ๋‹ˆ๋‹ค. ์—ฌ๊ธฐ์—๋Š” ์—”๋“œํฌ์ธํŠธ์— ์ด๋ฏธ์ง€๋ฅผ ์ „์†กํ•˜๊ณ  ์ถ”๋ก ์„ ์‹คํ–‰ํ•˜๋Š” ๊ฒƒ์ด ํฌํ•จ๋ฉ๋‹ˆ๋‹ค. ๊ทธ๋Ÿฐ ๋‹ค์Œ ์•„๋ž˜์™€ ๊ฐ™์ด ๋ชจ๋ธ์˜ ์„ฑ๋Šฅ๊ณผ ์ •ํ™•๋„๋ฅผ ์‹œ๊ฐํ™”ํ•˜๊ธฐ ์œ„ํ•ด ์ถœ๋ ฅ์„ ํ”Œ๋กœํŒ…ํ•ฉ๋‹ˆ๋‹ค.

ํ…Œ์ŠคํŠธ ๊ฒฐ๊ณผ YOLO11

  • ๋ฆฌ์†Œ์Šค ์ •๋ฆฌ: ํ…Œ์ŠคํŠธ ๋…ธํŠธ๋ถ์€ ์—”๋“œํฌ์ธํŠธ์™€ ํ˜ธ์ŠคํŒ…๋œ ๋ชจ๋ธ์„ ์ •๋ฆฌํ•˜๋Š” ๊ณผ์ •๋„ ์•ˆ๋‚ดํ•ฉ๋‹ˆ๋‹ค. ์ด๋Š” ํŠนํžˆ ๋ฐฐํฌ๋œ ๋ชจ๋ธ์„ ์ฆ‰์‹œ ์‚ฌ์šฉํ•  ๊ณ„ํš์ด ์—†๋Š” ๊ฒฝ์šฐ ๋น„์šฉ๊ณผ ๋ฆฌ์†Œ์Šค๋ฅผ ํšจ๊ณผ์ ์œผ๋กœ ๊ด€๋ฆฌํ•˜๊ธฐ ์œ„ํ•œ ์ค‘์š”ํ•œ ๋‹จ๊ณ„์ž…๋‹ˆ๋‹ค.

7๋‹จ๊ณ„: ๋ชจ๋‹ˆํ„ฐ๋ง ๋ฐ ๊ด€๋ฆฌ

ํ…Œ์ŠคํŠธ ํ›„์—๋Š” ๋ฐฐํฌ๋œ ๋ชจ๋ธ์„ ์ง€์†์ ์œผ๋กœ ๋ชจ๋‹ˆํ„ฐ๋งํ•˜๊ณ  ๊ด€๋ฆฌํ•˜๋Š” ๊ฒƒ์ด ํ•„์ˆ˜์ ์ž…๋‹ˆ๋‹ค.

  • Amazon CloudWatch๋กœ ๋ชจ๋‹ˆํ„ฐ๋ง: Amazon CloudWatch๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ SageMaker ์—”๋“œํฌ์ธํŠธ์˜ ์„ฑ๋Šฅ๊ณผ ์ƒํƒœ๋ฅผ ์ •๊ธฐ์ ์œผ๋กœ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค.

  • ์—”๋“œํฌ์ธํŠธ ๊ด€๋ฆฌ: ์—”๋“œํฌ์ธํŠธ์˜ ์ง€์†์ ์ธ ๊ด€๋ฆฌ๋ฅผ ์œ„ํ•ด SageMaker ์ฝ˜์†”์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ์—ฌ๊ธฐ์—๋Š” ํ•„์š”์— ๋”ฐ๋ผ ๋ชจ๋ธ์„ ํ™•์žฅ, ์—…๋ฐ์ดํŠธ ๋˜๋Š” ์žฌ๋ฐฐํฌํ•˜๋Š” ๊ฒƒ์ด ํฌํ•จ๋ฉ๋‹ˆ๋‹ค.

์ด ๋‹จ๊ณ„๋ฅผ ์™„๋ฃŒํ•˜๋ฉด Amazon ์„ธ์ด์ง€๋ฉ”์ด์ปค ์—”๋“œํฌ์ธํŠธ์— YOLO11 ๋ชจ๋ธ์„ ์„ฑ๊ณต์ ์œผ๋กœ ๋ฐฐํฌํ•˜๊ณ  ํ…Œ์ŠคํŠธํ•œ ๊ฒƒ์ž…๋‹ˆ๋‹ค. ์ด ํ”„๋กœ์„ธ์Šค๋ฅผ ํ†ตํ•ด ๋จธ์‹  ๋Ÿฌ๋‹ ๋ฐฐํฌ๋ฅผ ์œ„ํ•œ AWS ์„œ๋น„์Šค ์‚ฌ์šฉ์— ๋Œ€ํ•œ ์‹ค๋ฌด ๊ฒฝํ—˜์„ ์Œ“์„ ์ˆ˜ ์žˆ์„ ๋ฟ๋งŒ ์•„๋‹ˆ๋ผ ํ–ฅํ›„ ๋‹ค๋ฅธ ๊ณ ๊ธ‰ ๋ชจ๋ธ์„ ๋ฐฐํฌํ•  ์ˆ˜ ์žˆ๋Š” ๊ธฐ๋ฐ˜์„ ๋งˆ๋ จํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์š”์•ฝ

์ด ๊ฐ€์ด๋“œ๋Š” AWS CloudFormation ๋ฐ AWS ํด๋ผ์šฐ๋“œ ๊ฐœ๋ฐœ ํ‚คํŠธ(CDK)๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ Amazon SageMaker ์—”๋“œํฌ์ธํŠธ์— YOLO11 ๋ฐฐํฌํ•˜๋Š” ๊ณผ์ •์„ ๋‹จ๊ณ„๋ณ„๋กœ ์•ˆ๋‚ดํ•ฉ๋‹ˆ๋‹ค. ์ด ํ”„๋กœ์„ธ์Šค์—๋Š” ํ•„์š”ํ•œ GitHub ๋ฆฌํฌ์ง€ํ† ๋ฆฌ ๋ณต์ œ, CDK ํ™˜๊ฒฝ ์„ค์ •, AWS ์„œ๋น„์Šค๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ชจ๋ธ ๋ฐฐํฌ, SageMaker์—์„œ ์„ฑ๋Šฅ ํ…Œ์ŠคํŠธ๊ฐ€ ํฌํ•จ๋ฉ๋‹ˆ๋‹ค.

์ž์„ธํ•œ ๊ธฐ์ˆ ์  ๋‚ด์šฉ์€ AWS ๋จธ์‹  ๋Ÿฌ๋‹ ๋ธ”๋กœ๊ทธ์˜ ์ด ๊ธ€์„ ์ฐธ์กฐํ•˜์„ธ์š”. ๋‹ค์–‘ํ•œ ํŠน์ง•๊ณผ ๊ธฐ๋Šฅ์— ๋Œ€ํ•œ ์ž์„ธํ•œ ๋‚ด์šฉ์€ Amazon SageMaker ๊ณต์‹ ์„ค๋ช…์„œ์—์„œ ํ™•์ธํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค.

๋‹ค์–‘ํ•œ YOLO11 ํ†ตํ•ฉ์— ๋Œ€ํ•ด ์ž์„ธํžˆ ์•Œ์•„๋ณด๊ณ  ์‹ถ์œผ์‹ ๊ฐ€์š”? Ultralytics ํ†ตํ•ฉ ๊ฐ€์ด๋“œ ํŽ˜์ด์ง€๋ฅผ ๋ฐฉ๋ฌธํ•˜์—ฌ ๋จธ์‹ ๋Ÿฌ๋‹ ํ”„๋กœ์ ํŠธ๋ฅผ ํ–ฅ์ƒ์‹œํ‚ฌ ์ˆ˜ ์žˆ๋Š” ์ถ”๊ฐ€ ๋„๊ตฌ์™€ ๊ธฐ๋Šฅ์„ ์•Œ์•„๋ณด์„ธ์š”.

์ž์ฃผ ๋ฌป๋Š” ์งˆ๋ฌธ

Amazon SageMaker ์—”๋“œํฌ์ธํŠธ์— Ultralytics YOLO11 ๋ชจ๋ธ์„ ๋ฐฐํฌํ•˜๋ ค๋ฉด ์–ด๋–ป๊ฒŒ ํ•ด์•ผ ํ•˜๋‚˜์š”?

Amazon SageMaker ์—”๋“œํฌ์ธํŠธ์— Ultralytics YOLO11 ๋ชจ๋ธ์„ ๋ฐฐํฌํ•˜๋ ค๋ฉด ๋‹ค์Œ ๋‹จ๊ณ„๋ฅผ ๋”ฐ๋ฅด์„ธ์š”:

  1. AWS ํ™˜๊ฒฝ ์„ค์ •ํ•˜๊ธฐ: AWS ๊ณ„์ •, ํ•„์š”ํ•œ ๊ถŒํ•œ์ด ์žˆ๋Š” IAM ์—ญํ•  ๋ฐ AWS CLI ๊ฐ€ ๊ตฌ์„ฑ๋˜์–ด ์žˆ๋Š”์ง€ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค. ์•„์ง ์„ค์น˜ํ•˜์ง€ ์•Š์€ ๊ฒฝ์šฐ AWS CDK๋ฅผ ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค( AWS CDK ์ง€์นจ ์ฐธ์กฐ).
  2. YOLO11 ์„ธ์ด์ง€๋ฉ”์ด์ปค ๋ฆฌํฌ์ง€ํ† ๋ฆฌ ๋ณต์ œํ•˜๊ธฐ:
    git clone https://github.com/aws-samples/host-yolov8-on-sagemaker-endpoint.git
    cd host-yolov8-on-sagemaker-endpoint/yolov8-pytorch-cdk
    
  3. CDK ํ™˜๊ฒฝ ์„ค์ •: Python ๊ฐ€์ƒ ํ™˜๊ฒฝ์„ ์ƒ์„ฑํ•˜๊ณ , ํ™œ์„ฑํ™”ํ•˜๊ณ , ์ข…์† ์š”์†Œ๋ฅผ ์„ค์น˜ํ•˜๊ณ , AWS CDK ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์—…๊ทธ๋ ˆ์ด๋“œํ•ฉ๋‹ˆ๋‹ค.
    python3 -m venv .venv
    source .venv/bin/activate
    pip3 install -r requirements.txt
    pip install --upgrade aws-cdk-lib
    
  4. AWS CDK๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ฐฐํฌ: CloudFormation ์Šคํƒ์„ ํ•ฉ์„ฑ ๋ฐ ๋ฐฐํฌํ•˜๊ณ  ํ™˜๊ฒฝ์„ ๋ถ€ํŠธ์ŠคํŠธ๋žฉํ•ฉ๋‹ˆ๋‹ค.
    cdk synth
    cdk bootstrap
    cdk deploy
    

์ž์„ธํ•œ ๋‚ด์šฉ์€ ๋ฌธ์„œ ์„น์…˜์„ ์ฐธ์กฐํ•˜์„ธ์š”.

Amazon SageMaker์— YOLO11 ๋ฐฐํฌ๋ฅผ ์œ„ํ•œ ์ „์ œ ์กฐ๊ฑด์€ ๋ฌด์—‡์ธ๊ฐ€์š”?

Amazon SageMaker์— YOLO11 ๋ฅผ ๋ฐฐํฌํ•˜๋ ค๋ฉด ๋‹ค์Œ ์‚ฌ์ „ ์š”๊ตฌ ์‚ฌํ•ญ์ด ์žˆ๋Š”์ง€ ํ™•์ธํ•˜์„ธ์š”:

  1. AWS ๊ณ„์ •: ํ™œ์„ฑ AWS ๊ณ„์ •(์—ฌ๊ธฐ์—์„œ ๊ฐ€์ž…).
  2. IAM ์—ญํ• : SageMaker, CloudFormation ๋ฐ Amazon S3์— ๋Œ€ํ•œ ๊ถŒํ•œ์ด ์žˆ๋Š” IAM ์—ญํ• ์„ ๊ตฌ์„ฑํ•ฉ๋‹ˆ๋‹ค.
  3. AWS CLI: AWS ๋ช…๋ น์ค„ ์ธํ„ฐํŽ˜์ด์Šค ์„ค์น˜ ๋ฐ ๊ตฌ์„ฑ(AWS CLI ์„ค์น˜ ๊ฐ€์ด๋“œ).
  4. AWS CDK: ์„ค์น˜๋œ AWS ํด๋ผ์šฐ๋“œ ๊ฐœ๋ฐœ ํ‚คํŠธ(CDK ์„ค์ • ๊ฐ€์ด๋“œ).
  5. ์„œ๋น„์Šค ํ• ๋‹น๋Ÿ‰: ๋‹ค์Œ์— ๋Œ€ํ•œ ์ถฉ๋ถ„ํ•œ ํ• ๋‹น๋Ÿ‰ ml.m5.4xlarge ์—”๋“œํฌ์ธํŠธ์™€ ๋…ธํŠธ๋ถ ์‚ฌ์šฉ ๋ชจ๋‘์— ๋Œ€ํ•œ ์ธ์Šคํ„ด์Šค(ํ• ๋‹น๋Ÿ‰ ์ฆ๊ฐ€ ์š”์ฒญ).

์ž์„ธํ•œ ์„ค์ •์€ ์ด ์„น์…˜์„ ์ฐธ์กฐํ•˜์„ธ์š”.

์•„๋งˆ์กด ์„ธ์ด์ง€๋ฉ”์ด์ปค์—์„œ Ultralytics YOLO11 ์„ ์‚ฌ์šฉํ•ด์•ผ ํ•˜๋Š” ์ด์œ ๋Š” ๋ฌด์—‡์ธ๊ฐ€์š”?

์•„๋งˆ์กด ์„ธ์ด์ง€๋ฉ”์ด์ปค์—์„œ Ultralytics YOLO11 ์„ ์‚ฌ์šฉํ•˜๋ฉด ๋ช‡ ๊ฐ€์ง€ ์ด์ ์ด ์žˆ์Šต๋‹ˆ๋‹ค:

  1. ํ™•์žฅ์„ฑ ๋ฐ ๊ด€๋ฆฌ: SageMaker๋Š” ์ž๋™ ํ™•์žฅ ๋“ฑ์˜ ๊ธฐ๋Šฅ์„ ๊ฐ–์ถ˜ ๊ด€๋ฆฌํ˜• ํ™˜๊ฒฝ์„ ์ œ๊ณตํ•˜์—ฌ ์‹ค์‹œ๊ฐ„ ์ถ”๋ก ์— ๋„์›€์ด ๋ฉ๋‹ˆ๋‹ค.
  2. AWS ์„œ๋น„์Šค์™€์˜ ํ†ตํ•ฉ: ๋ฐ์ดํ„ฐ ์Šคํ† ๋ฆฌ์ง€๋ฅผ ์œ„ํ•œ S3, ์ฝ”๋“œํ˜• ์ธํ”„๋ผ๋ฅผ ์œ„ํ•œ CloudFormation, ๋ชจ๋‹ˆํ„ฐ๋ง์„ ์œ„ํ•œ CloudWatch์™€ ๊ฐ™์€ ๋‹ค๋ฅธ AWS ์„œ๋น„์Šค์™€ ์›ํ™œํ•˜๊ฒŒ ํ†ตํ•ฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  3. ๋ฐฐํฌ์˜ ์šฉ์ด์„ฑ: AWS CDK ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์„ค์ •์ด ๊ฐ„์†Œํ™”๋˜๊ณ  ๋ฐฐํฌ ํ”„๋กœ์„ธ์Šค๊ฐ€ ๊ฐ„์†Œํ™”๋ฉ๋‹ˆ๋‹ค.
  4. ์„ฑ๋Šฅ: ๋Œ€๊ทœ๋ชจ ์ถ”๋ก  ์ž‘์—…์„ ํšจ์œจ์ ์œผ๋กœ ์‹คํ–‰ํ•˜๊ธฐ ์œ„ํ•ด Amazon SageMaker์˜ ๊ณ ์„ฑ๋Šฅ ์ธํ”„๋ผ๋ฅผ ํ™œ์šฉํ•˜์„ธ์š”.

์†Œ๊ฐœ ์„น์…˜์—์„œ ์„ธ์ด์ง€๋ฉ”์ด์ปค ์‚ฌ์šฉ์˜ ์žฅ์ ์— ๋Œ€ํ•ด ์ž์„ธํžˆ ์•Œ์•„๋ณด์„ธ์š”.

Amazon SageMaker์—์„œ YOLO11 ์— ๋Œ€ํ•œ ์ถ”๋ก  ๋กœ์ง์„ ์‚ฌ์šฉ์ž ์ง€์ •ํ•  ์ˆ˜ ์žˆ๋‚˜์š”?

์˜ˆ, Amazon SageMaker์—์„œ YOLO11 ์— ๋Œ€ํ•œ ์ถ”๋ก  ๋กœ์ง์„ ์‚ฌ์šฉ์ž ์ง€์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:

  1. ์ˆ˜์ • inference.py: ์ฐพ๊ธฐ ๋ฐ ์‚ฌ์šฉ์ž ์ง€์ • output_fn ํ•จ์ˆ˜์˜ inference.py ํŒŒ์ผ์„ ์‚ฌ์šฉํ•˜์—ฌ ์ถœ๋ ฅ ํ˜•์‹์„ ์กฐ์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

    import json
    
    
    def output_fn(prediction_output):
        """Formats model outputs as JSON string, extracting attributes like boxes, masks, keypoints."""
        infer = {}
        for result in prediction_output:
            if result.boxes is not None:
                infer["boxes"] = result.boxes.numpy().data.tolist()
            # Add more processing logic if necessary
        return json.dumps(infer)
    
  2. ์—…๋ฐ์ดํŠธ๋œ ๋ชจ๋ธ ๋ฐฐํฌ: ์ œ๊ณต๋œ Jupyter ๋…ธํŠธ๋ถ์„ ์‚ฌ์šฉํ•˜์—ฌ ๋ชจ๋ธ์„ ๋‹ค์‹œ ๋ฐฐํฌํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค(1_DeployEndpoint.ipynb)์— ์ด๋Ÿฌํ•œ ๋ณ€๊ฒฝ ์‚ฌํ•ญ์„ ํฌํ•จํ•˜๋„๋ก ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.

์ˆ˜์ •๋œ ๋ชจ๋ธ์„ ๋ฐฐํฌํ•˜๋ ค๋ฉด ์ž์„ธํ•œ ๋‹จ๊ณ„๋ฅผ ์ฐธ์กฐํ•˜์„ธ์š”.

๋ฐฐํฌ๋œ YOLO11 ๋ชจ๋ธ์„ Amazon SageMaker์—์„œ ํ…Œ์ŠคํŠธํ•˜๋ ค๋ฉด ์–ด๋–ป๊ฒŒ ํ•ด์•ผ ํ•˜๋‚˜์š”?

๋ฐฐํฌ๋œ YOLO11 ๋ชจ๋ธ์„ Amazon SageMaker์—์„œ ํ…Œ์ŠคํŠธํ•ฉ๋‹ˆ๋‹ค:

  1. ํ…Œ์ŠคํŠธ ๋…ธํŠธ๋ถ ์—ด๊ธฐ: ์ฐพ๊ธฐ 2_TestEndpoint.ipynb ๋…ธํŠธ๋ถ์„ ์‚ฌ์šฉํ•˜์„ธ์š”.
  2. ๋…ธํŠธ๋ถ์„ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค: ๋…ธํŠธ๋ถ์˜ ์ง€์นจ์— ๋”ฐ๋ผ ์ด๋ฏธ์ง€๋ฅผ ์—”๋“œํฌ์ธํŠธ๋กœ ๋ณด๋‚ด๊ณ , ์ถ”๋ก ์„ ์ˆ˜ํ–‰ํ•˜๊ณ , ๊ฒฐ๊ณผ๋ฅผ ํ‘œ์‹œํ•ฉ๋‹ˆ๋‹ค.
  3. ๊ฒฐ๊ณผ ์‹œ๊ฐํ™”: ๊ธฐ๋ณธ ์ œ๊ณต ํ”Œ๋กœํŒ… ๊ธฐ๋Šฅ์„ ์‚ฌ์šฉํ•˜์—ฌ ๊ฐ์ง€๋œ ๊ฐœ์ฒด ์ฃผ๋ณ€์˜ ๊ฒฝ๊ณ„ ์ƒ์ž ๋“ฑ์˜ ์„ฑ๋Šฅ ๋ฉ”ํŠธ๋ฆญ์„ ์‹œ๊ฐํ™”ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์ข…ํ•ฉ์ ์ธ ํ…Œ์ŠคํŠธ ์ง€์นจ์€ ํ…Œ์ŠคํŠธ ์„น์…˜์„ ์ฐธ์กฐํ•˜์„ธ์š”.

10๊ฐœ์›” ์ „ ์ƒ์„ฑ๋จ โœ๏ธ 1๊ฐœ์›” ์ „ ์—…๋ฐ์ดํŠธ๋จ

๋Œ“๊ธ€