์ด ํ์ด์ง์์๋ Google Cloud ์ฝ์ ๋๋ Vertex AI API๋ฅผ ์ฌ์ฉํ์ฌ ๋์์ ๋ถ๋ฅ ๋ชจ๋ธ์์ ์ผ๊ด ์์ธก์ ์ป๋ ๋ฐฉ๋ฒ์ ๋ณด์ฌ์ค๋๋ค. ์ผ๊ด ์์ธก์ ๋น๋๊ธฐ์ ์์ฒญ์ ๋๋ค. ๋ชจ๋ธ์ ์๋ํฌ์ธํธ์ ๋ฐฐํฌํ ํ์ ์์ด ๋ชจ๋ธ ๋ฆฌ์์ค์์ ์ง์ ์ผ๊ด ์์ธก์ ์์ฒญํฉ๋๋ค.
AutoML ๋์์ ๋ชจ๋ธ์ ์จ๋ผ์ธ ์์ธก์ ์ง์ํ์ง ์์ต๋๋ค.
์ผ๊ด ์์ธก ๊ฐ์ ธ์ค๊ธฐ
์ผ๊ด ์์ธก ์์ฒญ์ ์ํํ๋ ค๋ฉด Vertex AI๊ฐ ์์ธก ๊ฒฐ๊ณผ๋ฅผ ์ ์ฅํ๋ ์ ๋ ฅ ์์ค์ ์ถ๋ ฅ ํ์์ ์ง์ ํฉ๋๋ค.
์ ๋ ฅ ๋ฐ์ดํฐ ์๊ตฌ์ฌํญ
์ผ๊ด ์์ฒญ์ ์
๋ ฅ์ ์์ธก์ ์ํด ๋ชจ๋ธ์ ๋ณด๋ผ ํญ๋ชฉ์ ์ง์ ํฉ๋๋ค. AutoML ๋์์ ๋ชจ๋ธ ์ ํ์ ์ผ๊ด ์์ธก์ JSON Lines ํ์ผ์ ์ฌ์ฉํ์ฌ ์์ธกํ ๋์์ ๋ชฉ๋ก์ ์ง์ ํ ๋ค์ JSON Lines ํ์ผ์ Cloud Storage ๋ฒํท์ ์ ์ฅํฉ๋๋ค. timeSegmentEnd
ํ๋์ Infinity
๋ฅผ ์ง์ ํ์ฌ ๋์์ ์ข
๋ฃ ์ง์ ์ ์ง์ ํ ์ ์์ต๋๋ค. ๋ค์ ์ํ์์๋ ์
๋ ฅ JSON Lines ํ์ผ์ ๋จ์ผ ์ค์ ๋ณด์ฌ์ค๋๋ค.
{'content': 'gs://sourcebucket/datasets/videos/source_video.mp4', 'mimeType': 'video/mp4', 'timeSegmentStart': '0.0s', 'timeSegmentEnd': '2.366667s'}
๋ฐฐ์น ์์ธก ์์ฒญ
์ผ๊ด ์์ธก ์์ฒญ์ ๊ฒฝ์ฐ Google Cloud ์ฝ์ ๋๋ Vertex AI API๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค. ์ ์ถํ ์ ๋ ฅ ํญ๋ชฉ ์์ ๋ฐ๋ผ ์ผ๊ด ์์ธก ํ์คํฌ๋ฅผ ์๋ฃํ๋ ๋ฐ ๋ค์ ์๊ฐ์ด ๊ฑธ๋ฆด ์ ์์ต๋๋ค.
Google Cloud ์ฝ์
Google Cloud ์ฝ์์ ์ฌ์ฉํ์ฌ ์ผ๊ด ์์ธก์ ์์ฒญํฉ๋๋ค.
Google Cloud ์ฝ์์ Vertex AI ์น์ ์์ ์ผ๊ด ์์ธก ํ์ด์ง๋ก ์ด๋ํฉ๋๋ค.
๋ง๋ค๊ธฐ๋ฅผ ํด๋ฆญํ์ฌ ์ ์ผ๊ด ์์ธก ์ฐฝ์ ์ด๊ณ ๋ค์ ๋จ๊ณ๋ฅผ ์๋ฃํฉ๋๋ค.
- ์ผ๊ด ์์ธก์ ์ด๋ฆ์ ์ ๋ ฅํฉ๋๋ค.
- ๋ชจ๋ธ ์ด๋ฆ์์ ์ด ์ผ๊ด ์์ธก์ ์ฌ์ฉํ ๋ชจ๋ธ์ ์ด๋ฆ์ ์ ํํฉ๋๋ค.
- ์์ค ๊ฒฝ๋ก์์ JSON Lines ์ ๋ ฅ ํ์ผ์ด ์๋ Cloud Storage ์์น๋ฅผ ์ง์ ํฉ๋๋ค.
- ๋์ ๊ฒฝ๋ก์์ ์ผ๊ด ์์ธก ๊ฒฐ๊ณผ๊ฐ ์ ์ฅ๋๋ Cloud Storage ์์น๋ฅผ ์ง์ ํฉ๋๋ค. ์ถ๋ ฅ ํ์์ ๋ชจ๋ธ์ ๋ชฉํ์ ๋ฐ๋ผ ๊ฒฐ์ ๋ฉ๋๋ค. ์ด๋ฏธ์ง ๋ชฉํ์ AutoML ๋ชจ๋ธ์ JSON Lines ํ์ผ์ ์ถ๋ ฅํฉ๋๋ค.
API
Vertex AI API๋ฅผ ์ฌ์ฉํ์ฌ ์ผ๊ด ์์ธก ์์ฒญ์ ์ ์กํฉ๋๋ค.
REST
์์ฒญ ๋ฐ์ดํฐ๋ฅผ ์ฌ์ฉํ๊ธฐ ์ ์ ๋ค์์ ๋ฐ๊ฟ๋๋ค.
- LOCATION_ID: ๋ชจ๋ธ์ด ์ ์ฅ๋๊ณ ์ผ๊ด ์์ธก ์์
์ด ์คํ๋๋ ๋ฆฌ์ ์
๋๋ค. ์๋ฅผ ๋ค๋ฉด
us-central1
์ ๋๋ค. - PROJECT_ID: ํ๋ก์ ํธ ID์ ๋๋ค.
- BATCH_JOB_NAME: ์ผ๊ด ์์ ์ ํ์ ์ด๋ฆ์ ๋๋ค.
- MODEL_ID: ์์ธก์ ์ํํ๋ ๋ฐ ์ฌ์ฉํ ๋ชจ๋ธ์ ID์ ๋๋ค.
- THRESHOLD_VALUE(์ ํ์ฌํญ): ๋ชจ๋ธ์ ์ ๋ขฐ๋๊ฐ ์ด ๊ฐ ์ด์์ธ ์์ธก๋ง ๋ฐํํฉ๋๋ค.
- SEGMENT_CLASSIFICATION (์ ํ์ฌํญ): ์ธ๊ทธ๋จผํธ ์์ค ๋ถ๋ฅ๋ฅผ ์์ฒญํ ์ง ๊ฒฐ์ ํ๋ ๋ถ๋ฆฌ์ธ ๊ฐ์
๋๋ค. Vertex AI๋ ์
๋ ฅ ์ธ์คํด์ค์์ ์ง์ ํ ๋์์์ ์ ์ฒด ์๊ฐ ์ธ๊ทธ๋จผํธ์ ๋ผ๋ฒจ๊ณผ ์ ๋ขฐ๋ ์ ์๋ฅผ ๋ฐํํฉ๋๋ค. ๊ธฐ๋ณธ๊ฐ์
true
์ ๋๋ค. - SHOT_CLASSIFICATION (์ ํ์ฌํญ): ์ฅ๋ฉด ์์ค ๋ถ๋ฅ๋ฅผ ์์ฒญํ ์ง ๊ฒฐ์ ํ๋ ๋ถ๋ฆฌ์ธ ๊ฐ์
๋๋ค. Vertex AI๋ ์
๋ ฅ ์ธ์คํด์ค์์ ์ง์ ํ ๋์์์ ์ ์ฒด ์๊ฐ ์ธ๊ทธ๋จผํธ์ ๊ฐ ์นด๋ฉ๋ผ ์ท์ ๊ฒฝ๊ณ๋ฅผ ๊ฒฐ์ ํฉ๋๋ค. ๊ทธ๋ฐ ๋ค์ Vertex AI๋ ๊ฐ์ง๋ ๊ฐ ์ฅ๋ฉด์ ๋ผ๋ฒจ๊ณผ ์ ๋ขฐ๋ ์ ์๋ฅผ ์ฅ๋ฉด์ ์์ ๋ฐ ์ข
๋ฃ ์๊ฐ๊ณผ ํจ๊ป ๋ฐํํฉ๋๋ค. ๊ธฐ๋ณธ๊ฐ์
false
์ ๋๋ค. - ONE_SEC_INTERVAL_CLASSIFICATION(์ ํ์ฌํญ): 1์ด ๊ฐ๊ฒฉ์ผ๋ก ๋์์ ๋ถ๋ฅ๋ฅผ ์์ฒญํ ์ง ์ฌ๋ถ๋ฅผ ๊ฒฐ์ ํ๋ ๋ถ๋ฆฌ์ธ ๊ฐ์
๋๋ค. Vertex AI๋ ์
๋ ฅ ์ธ์คํด์ค์์ ์ง์ ํ ๋์์์ ์ ์ฒด ์๊ฐ ์ธ๊ทธ๋จผํธ์ ์ด๋น ๋ผ๋ฒจ๊ณผ ์ ๋ขฐ๋ ์ ์๋ฅผ ๋ฐํํฉ๋๋ค. ๊ธฐ๋ณธ๊ฐ์
false
์ ๋๋ค. - URI: ์ ๋ ฅ JSON Lines ํ์ผ์ด ์๋ Cloud Storage URI
- BUCKET: Cloud Storage ๋ฒํท
- PROJECT_NUMBER: ํ๋ก์ ํธ์ ์๋์ผ๋ก ์์ฑ๋ ํ๋ก์ ํธ ๋ฒํธ
HTTP ๋ฉ์๋ ๋ฐ URL:
POST https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/batchPredictionJobs
JSON ์์ฒญ ๋ณธ๋ฌธ:
{ "displayName": "BATCH_JOB_NAME", "model": "projects/PROJECT_ID/locations/LOCATION_ID/models/MODEL_ID", "modelParameters": { "confidenceThreshold": THRESHOLD_VALUE, "segmentClassification": SEGMENT_CLASSIFICATION, "shotClassification": SHOT_CLASSIFICATION, "oneSecIntervalClassification": ONE_SEC_INTERVAL_CLASSIFICATION }, "inputConfig": { "instancesFormat": "jsonl", "gcsSource": { "uris": ["URI"], }, }, "outputConfig": { "predictionsFormat": "jsonl", "gcsDestination": { "outputUriPrefix": "OUTPUT_BUCKET", }, }, }
์์ฒญ์ ๋ณด๋ด๋ ค๋ฉด ๋ค์ ์ต์ ์ค ํ๋๋ฅผ ์ ํํฉ๋๋ค.
curl
์์ฒญ ๋ณธ๋ฌธ์ request.json
ํ์ผ์ ์ ์ฅํ๊ณ ๋ค์ ๋ช
๋ น์ด๋ฅผ ์คํํฉ๋๋ค.
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/batchPredictionJobs"
PowerShell
์์ฒญ ๋ณธ๋ฌธ์ request.json
ํ์ผ์ ์ ์ฅํ๊ณ ๋ค์ ๋ช
๋ น์ด๋ฅผ ์คํํฉ๋๋ค.
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/batchPredictionJobs" | Select-Object -Expand Content
๋ค์๊ณผ ๋น์ทํ JSON ์๋ต์ด ํ์๋ฉ๋๋ค.
{ "name": "projects/PROJECT_NUMBER/locations/us-central1/batchPredictionJobs/BATCH_JOB_ID", "displayName": "BATCH_JOB_NAME", "model": "projects/PROJECT_NUMBER/locations/us-central1/models/MODEL_ID", "inputConfig": { "instancesFormat": "jsonl", "gcsSource": { "uris": [ "CONTENT" ] } }, "outputConfig": { "predictionsFormat": "jsonl", "gcsDestination": { "outputUriPrefix": "BUCKET" } }, "state": "JOB_STATE_PENDING", "createTime": "2020-05-30T02:58:44.341643Z", "updateTime": "2020-05-30T02:58:44.341643Z", "modelDisplayName": "MODEL_NAME", "modelObjective": "MODEL_OBJECTIVE" }
์์
state
๊ฐ JOB_STATE_SUCCEEDED
๊ฐ ๋ ๋๊น์ง BATCH_JOB_ID๋ฅผ ์ฌ์ฉํ์ฌ ์ผ๊ด ์์
์ ์ํ๋ฅผ ํด๋งํ ์ ์์ต๋๋ค.
Java
์ด ์ํ์ ์ฌ์ฉํด ๋ณด๊ธฐ ์ ์ Vertex AI ๋น ๋ฅธ ์์: ํด๋ผ์ด์ธํธ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ฌ์ฉ์ Java ์ค์ ์๋ด๋ฅผ ๋ฐ๋ฅด์ธ์. ์์ธํ ๋ด์ฉ์ Vertex AI Java API ์ฐธ๊ณ ๋ฌธ์๋ฅผ ์ฐธ์กฐํ์ธ์.
Vertex AI์ ์ธ์ฆํ๋ ค๋ฉด ์ ํ๋ฆฌ์ผ์ด์ ๊ธฐ๋ณธ ์ฌ์ฉ์ ์ธ์ฆ ์ ๋ณด๋ฅผ ์ค์ ํฉ๋๋ค. ์์ธํ ๋ด์ฉ์ ๋ก์ปฌ ๊ฐ๋ฐ ํ๊ฒฝ์ ์ธ์ฆ ์ค์ ์ ์ฐธ์กฐํ์ธ์.
Node.js
์ด ์ํ์ ์ฌ์ฉํด ๋ณด๊ธฐ ์ ์ Vertex AI ๋น ๋ฅธ ์์: ํด๋ผ์ด์ธํธ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ฌ์ฉ์ Node.js ์ค์ ์๋ด๋ฅผ ๋ฐ๋ฅด์ธ์. ์์ธํ ๋ด์ฉ์ Vertex AI Node.js API ์ฐธ๊ณ ๋ฌธ์๋ฅผ ์ฐธ์กฐํ์ธ์.
Vertex AI์ ์ธ์ฆํ๋ ค๋ฉด ์ ํ๋ฆฌ์ผ์ด์ ๊ธฐ๋ณธ ์ฌ์ฉ์ ์ธ์ฆ ์ ๋ณด๋ฅผ ์ค์ ํฉ๋๋ค. ์์ธํ ๋ด์ฉ์ ๋ก์ปฌ ๊ฐ๋ฐ ํ๊ฒฝ์ ์ธ์ฆ ์ค์ ์ ์ฐธ์กฐํ์ธ์.
Python์ฉ Vertex AI SDK
Python์ฉ Vertex AI SDK๋ฅผ ์ค์นํ๊ฑฐ๋ ์ ๋ฐ์ดํธํ๋ ๋ฐฉ๋ฒ์ Python์ฉ Vertex AI SDK ์ค์น๋ฅผ ์ฐธ์กฐํ์ธ์. ์์ธํ ๋ด์ฉ์ Python์ฉ Vertex AI SDK API ์ฐธ์กฐ ๋ฌธ์๋ฅผ ํ์ธํ์ธ์.
์ผ๊ด ์์ธก ๊ฒฐ๊ณผ ๊ฒ์
Vertex AI๋ ์ง์ ๋ ๋์์ ์ผ๊ด ์์ธก ์ถ๋ ฅ์ ๋ณด๋ ๋๋ค.
์ผ๊ด ์์ธก ์์ ์ด ์๋ฃ๋๋ฉด ์์ฒญ์ ์ง์ ํ Cloud Storage ๋ฒํท์ ์์ธก ๊ฒฐ๊ณผ๊ฐ ์ ์ฅ๋ฉ๋๋ค.
์ผ๊ด ์์ธก ๊ฒฐ๊ณผ ์์
๋ค์์ ๋์์ ๋ถ๋ฅ ๋ชจ๋ธ์ ์ผ๊ด ์์ธก ๊ฒฐ๊ณผ ์์์ ๋๋ค.
{ "instance": { "content": "gs://bucket/video.mp4", "mimeType": "video/mp4", "timeSegmentStart": "1s", "timeSegmentEnd": "5s" } "prediction": [{ "id": "1", "displayName": "cat", "type": "segment-classification", "timeSegmentStart": "1s", "timeSegmentEnd": "5s", "confidence": 0.7 }, { "id": "1", "displayName": "cat", "type": "shot-classification", "timeSegmentStart": "1s", "timeSegmentEnd": "4s", "confidence": 0.9 }, { "id": "2", "displayName": "dog", "type": "shot-classification", "timeSegmentStart": "4s", "timeSegmentEnd": "5s", "confidence": 0.6 }, { "id": "1", "displayName": "cat", "type": "one-sec-interval-classification", "timeSegmentStart": "1s", "timeSegmentEnd": "1s", "confidence": 0.95 }, { "id": "1", "displayName": "cat", "type": "one-sec-interval-classification", "timeSegmentStart": "2s", "timeSegmentEnd": "2s", "confidence": 0.9 }, { "id": "1", "displayName": "cat", "type": "one-sec-interval-classification", "timeSegmentStart": "3s", "timeSegmentEnd": "3s", "confidence": 0.85 }, { "id": "2", "displayName": "dog", "type": "one-sec-interval-classification", "timeSegmentStart": "4s", "timeSegmentEnd": "4s", "confidence": 0.6 }] }