AIニュース最前線
最新ニュースAI日報Hacker日報週報動画AIツールトレンド企業

AIニュース最前線

世界中のAI最新情報を日本語で毎時更新

最新ニュース日報トレンド企業プレミアムRSS
© 2026 ainew.jp特定商取引法に基づく表記
ニュース一覧元記事を開く
AWS Machine Learning Blog·2026年6月23日 01:28·約18分で読める

Amazon SageMaker AI の処理ジョブで ComfyUI ワークフローを実行する方法

#ComfyUI#SageMaker AI#Generative AI#Computer Vision#Cloud Infrastructure
TL;DR

AWS は、Amazon SageMaker AI を活用して ComfyUI ワークフローをバッチ処理で実行する仕組みを提供し、企業による大規模なマルチモーダルコンテンツ生成の自動化とスケーラビリティを実現します。

AI深層分析2026年6月23日 02:02
4
重要/ 5段階
深度40%
4
関連度30%
5
実用性20%
5
革新性10%
3

キーポイント

1

SageMaker AI と ComfyUI の統合

AWS Cloud Development Kit (CDK) を用いて GPU アクセラレーション環境を構築し、ComfyUI のノードベースワークフローを SageMaker Processing Jobs で実行可能にする。

2

大規模バッチ処理による効率化

一度のジョブで数百枚の高品質画像や音声・動画を生成でき、キャンペーン期間中の急な需要やトレンドへの対応を数時間単位で可能にする。

3

ブランドガイドラインの自動遵守とパーソナライゼーション

AI による生成プロセスでスタイルやトーンの一貫性を保ちつつ、顧客セグメントごとに最適化された多言語・多様なメディアを自動的に作成できる。

4

AWS CDK を使用したデプロイとトリガー

CDK でスタックをデプロイし、Lambda 関数を呼び出すことで SageMaker AI プロセシングジョブを自動的に起動します。

5

GPU インスタンスタイプの事前確認が必要

ml.g5.xlarge インスタンスを 6 台使用する必要があるため、AWS コンソールでサービスクォータの増額申請が必須です。

6

大規模な自動化と効率化

ComfyUI と SageMaker AI を組み合わせることで、数週間にわたるクリエイティブ作業を1時間未満で数百枚の高品質画像生成へと短縮できる。

7

コスト最適化とセキュリティ

Z-Image Turbo モデルの活用により推論コストを抑えつつ、AWS CDK による自動停止機能や暗号化でアイドルリソースのコストを削減し、セキュアな基盤を実現している。

影響分析・編集コメントを表示

影響分析

この記事は、生成 AI の実用化において最も重要な課題の一つである「大規模かつ一貫性のあるコンテンツの高速生産」に対する具体的な解決策を示しています。SageMaker のようなクラウドインフラと ComfyUI の柔軟性を組み合わせることで、企業は手動プロセスに依存せず、収益に直結するマルチモーダル資産を即座にスケールさせることが可能になります。

編集コメント

生成 AI の導入において、単なるプロトタイプ作成から本番運用への移行を阻む最大の障壁はスケーラビリティと管理コストですが、このアプローチはその両方をクラウドネイティブな手法で解決する有力な事例です。

ComfyUI のワークフローを Amazon SageMaker AI の処理ジョブ上で実行することで、大規模なコンテンツ生成の自動化が可能になります。企業にとって、魅力的なマルチメディア資産を作成する際のあらゆる遅延や誤りは、売上の損失、ブランド関連性の低下、またはマーケティングの期限の逸失を意味します。製品発売の期限が迫っている場合や、季節のプロモーションに緊急のアセットが必要である場合、デザイナーが単一のソーシャルメディア投稿や 15 秒間の動画広告に対して反復作業を行うのを待っていると、損失するコンバージョンで数千ドルのコストが発生することになります。

AI を活用して、収益を創出する画像、音声、ビデオの大規模な作成を自動化できます。グローバルキャンペーンのために 1 時間で数百枚のブランドに準拠したソーシャルメディアビジュアルを生成したり、多言語広告監査用の超パーソナライズされたボイスオーバーを合成したり、AI が作成したスクリプトとビジュアルで動画クリップを生産したりしながら、ブランドガイドラインに厳密に準拠させることが可能です。もう一つの利点は、クリエイティブチームがインパクトの高い戦略に集中できるようになり、AI が反復的で時間のかかるタスクを処理することです。企業にとって、コンテンツ制作で節約された時間は、別のキャンペーンを開始したり、別のニッチなオーディエンスを対象としたり、失われた顧客との再エンゲージメントを行ったりする時間に充てられます。

本記事では、Amazon SageMaker AI の処理ジョブ上で ComfyUI ワークフローをデプロイし、一度に数百枚の高品質な画像を生成する方法について詳しく解説します。AWS Cloud Development Kit (AWS CDK) を用いたインフラストラクチャの構築方法や、GPU 加速処理の設定、大規模な画像生成の自動化手順を学びます。その後、このソリューションを貴社のニーズに特化した ComfyUI ワークフローに適応させることができます。私たちは、一度に数百枚の高品質な画像を生成する ComfyUI ワークフローを自動化し、クリエイティブパイプラインのスケーラビリティを実現するための実践的で段階的なプロセスをご案内します。

なぜこれが重要なのか

SageMaker AI の処理ジョブ上で ComfyUI を実行することは、コンテンツパイプラインに以下の主要なメリットをもたらします:

  • キャンペーンの加速: 規模に応じて数分〜数時間でコンテンツを生成し、一時的なトレンドや締切に対応できます。
  • パーソナライゼーションによるコンバージョンの向上: 特定のオーディエンスセグメント向けに、カスタマイズされたビジュアル、ボイスオーバー、動画を配信することで、クリック率と購入率を向上させます。
  • ブランドエクイティの保護: 各種メディアタイプにおいて、一貫したスタイル、トーン、コンプライアンスを強制します。
  • 安全なプロトタイピングと自信あるスケーリング: グローバル展開前に、制御された環境で AI 生成コンテンツをテストできます。

ComfyUI

ComfyUI は、生成 AI 向けのノードベースのビジュアルワークフロービルダーであり、コードを一つずつ記述することなく、複雑な画像、音声、またはビデオのパイプラインを構成し、テストし、反復的に改善することを容易にします。モジュール化されたコンポーネントをつなぎ合わせて、バージョン管理が可能でチーム間で共有できる再現可能なグラフを作成できます。

SageMaker AI の処理ジョブ上で ComfyUI をデプロイすると、画像生成ワークフローにいくつかの利点をもたらします。GPU アクセラレーション対応インスタンスは高速な推論時間を提供し、使用した計算リソースに対してのみ課金される秒単位従量課金と自動ジョブ終了機能により、コストを最適化できます。キューベースのアーキテクチャはワークロードに応じて自然にスケールし、手動介入なしで複数のリクエストを並列処理します。最後に、独自の ComfyUI ワークフローを JSON 形式でエクスポートしてデプロイすることも可能です。

Z-Image Turbo を用いた画像生成

Z-Image Turbo は、テキストから画像への拡散モデル向けに、スケーラブルなシングルストリームトランスフォーマーアーキテクチャ (S3DiT: Scalable Single-Stream Transformer architecture) を導入しました。Z-Image は、テキストと画像のモダリティトークンを一つの統合されたシーケンスに結合する(早期融合:Early Fusion)ことで、すべての層において密なクロスモーダル相互作用を可能にします。この早期融合設計により、モデルはトランスフォーマー内でテキストトークン、画像潜在トークン、さらには画像意味論的トークンを均一に扱い、モダリティ間でのパラメータ共有を最大化します。

Z-Image Turbo は、大規模言語モデル(LLM)のデコーダに触発された、デコーダ専用 Transformer のバックボーンを採用しており、30 層、隠れサイズ 3840、アテンションヘッド数 32、フィードフォワードネットワークの中間次元 10240 を持ち、合計 6B パラメータを有しています。このバックボーンは、安定性を確保するために正規化とゲート制御技術でカスタマイズされた、シングルストリームのマルチヘッドアテンションブロックとシングルストリームのフィードフォワードブロックを交互に配置しています。

image
image

本ソリューションでは、処理ジョブコンテナに保存された ComfyUI の Z-image Turbo 用ワークフロー を使用します。このワークフローは、お客様の ComfyUI ワークフローに差し替えることが可能です。ワークフローを変更する際は、そのワークフローで使用されるモデルをダウンロード済みであること、コンテナ内にカスタムノードがインストールされていること、そしてインスタンスタイプに十分な VRAM が確保されていることを確認してください。

その他のユースケース

この例では画像生成に焦点を当てていますが、前述の通り ComfyUI のワークフロー・エンジンは、音声合成、3D アセットレンダリング、動的なビデオアニメーションなど、AI を駆使したクリエイティブタスクをスケーラブルに実行できます。これにより、企業は多様なコンテンツパイプラインを大規模に自動化することが可能になります。AWS インフラストラクチャを活用することで、ビジネスはこれらのワークフローを数千もの出力に対して展開でき、あらゆる創造的なアイデアを収益を生む資産へと転換できます。以下に、ComfyUI をバッチジョブとして実行して大規模生成を行う他のアプリケーションの例を示します:

  • スピードを重視したスケーラブルな広告クリエイティブの A/B テスト:グローバルキャンペーン向けに、数百もの広告バリアント、ソーシャルメディア用カルーセル、動画スニペット、またはソーシャルメディア対応クリップを自動的に生成します。これには、ミニマリストや大胆なスタイルなど、特定のデザインやスタイルの反復を含むハイパー具体的な設計も含まれ、どのクリエイティブが各人口統計層に最も共鳴するかを検証できます。
  • グローバル展開のための動的パッケージングおよびラベルデザイン:国際的な製品発売向けに、地域固有のデザインを生成します。色、画像、テキストを地域の美的感覚、規制、または祝日(例えば、旧正月をテーマにしたラベルなど)に合わせて適応させ、物理生産前に大規模な複数のデザインを検証できます。
  • ゲームおよびエンターテインメント向けのインタラクティブ動画ストーリーテリング:ゲーム、ストリーミングサービス、またはインタラクティブ広告向けに、分岐する動画ナラティブを構築します。AI はユーザーの選択(例えば、主人公の外見や対話オプションなど)に基づいて動的なカットシーンを生成し、受動的な視聴を没入感がありパーソナライズされた体験へと変換します。

ソリューションアーキテクチャ

ビジネス上の価値とユースケースを理解したところで、このソリューションを実装する方法を探っていきましょう。本アーキテクチャでは、出力用の Amazon Simple Storage Service (Amazon S3) バケットを備えた DataStack、Amazon Virtual Private Cloud (Amazon VPC) を含む SecurityStack、および AWS Lambda トリガー関数を有する ComfyUISmStack の 3 つの AWS CDK スack が使用されます。また、GPU インスタンス上で実行される SageMaker AI プロセッシングジョブ、コンテナイメージ用の Amazon Elastic Container Registry (Amazon ECR)、ログ用の Amazon CloudWatch も利用します。プロセッシングジョブは VPC のプライベートサブネット内で実行されます。完全なコード実装については、GitHub リポジトリ を参照してください。

image
image

DataStack

DataStack は、出力データのサーバーサイド暗号化を備えた Amazon S3 バケットを使用してストレージ層を実装します。この出力バケットには、ComfyUI ワークフローから生成された画像が保存されます。

SecurityStack

SecurityStack は、本ソリューション全体のための基盤となるセキュリティインフラストラクチャを構築します。高可用性(HA)とネットワークの分離を実現するため、2 つのアベイラビリティゾーンにパブリックサブネットとプライベートサブネットを含む Amazon VPC を作成します。この VPC には NAT ゲートウェイが含まれており、SageMaker AI の処理ジョブが実行されるプライベートサブネットから安全にインターネットへアクセスできるようになります。

顧客管理型の AWS Key Management Service (AWS KMS) キーにより、Amazon S3 バケット、Amazon CloudWatch ログ、および環境変数を含むデータの保存時暗号化が提供されます。このキーには自動ローテーションが有効になっており、Amazon S3 や CloudWatch などの AWS サービスが暗号化操作に使用できるようリソースポリシーが含まれています。VPC フローログは有効化されており、ネットワークトラフィックの監視とセキュリティ分析のために CloudWatch に送信されます。

ComfyUISmStack

ComfyUISmStack は、AWS Lambda 関数を通じてコア処理パイプラインをオーケストレーションします。この Lambda 関数は手動で呼び出すことで、カスタム Docker コンテナを実行する ml.g5.xlarge インスタンスを使用した GPU パワーによる処理を開始できます。このコンテナには ComfyUI と Z-Image Turbo モデルがパッケージ化されており、プロンプト、シード、バッチ処理のための設定可能なパラメータを提供することで、高品質な画像生成を実現します。

このスタックは、Docker イメージのビルドと Amazon ECR へのデプロイ、SageMaker AI 向けに包括的な権限(Amazon S3、Amazon ECR、Amazon VPC、CloudWatch へのアクセスを含む)を持つ AWS Identity and Access Management (IAM) ロールの作成、VPC 統合、AWS KMS 暗号化、ネットワーク分離を備えた処理ジョブ定義、および完全なジョブ設定を含む環境変数を持つ Lambda トリガー関数の構成を扱う再利用可能な処理ジョブの構築を作成します。

処理ジョブは、安全な AWS サービス通信のためにプライベートサブネット内で実行されます。コンテナログは CloudWatch にストリーミングされ、リアルタイムでの監視とトラブルシューティングが可能になります。このジョブは継続的な Amazon S3 アップロードモードを使用し、生成された画像をジョブの完了を待たずに作成されるたびに出力バケットへストリーミングします。

プロセスフロー

プロセスは、Lambda 関数をトリガーすることから始まります。これにより処理ジョブが作成され、SageMaker AI に提出されます。SageMaker AI はプライベートネットワーク内で GPU インスタンスをプロビジョニングし、レジストリから ComfyUI コンテナイメージを取得して、必要なストレージおよびネットワーク設定とともにデプロイします。コンテナの実行後、ComfyUI サーバーは以下の動作を行います:

  • セキュアなアウトバウンド接続を介して、HuggingFace から AI モデルコンポーネントをダウンロードします。
  • それらをそれぞれのディレクトリに整理整頓します。
  • GPU メモリにモデルを読み込み、完全な初期化が完了するまで待機します。

サーバーの準備が整うと、システムはファイルからテキストプロンプトを読み取り、バッチ単位でループ処理を行います。各画像に対して以下を実行します:

  • 一意のシード値に基づいてプロンプトを選択します。
  • プロンプトとシード値をワークフローテンプレートに埋め込みます。
  • ComfyUI へ処理リクエストを送信します。

GPU はワークフロー指示に基づいて各画像を生成します。画像が生成されるにつれて:

  • 出力ディレクトリに書き込まれ、リアルタイムで Amazon S3 に同期され、ジョブ完了前に結果を利用可能にします。
  • コンテナのログは監視とトラブルシューティングのために CloudWatch にストリーミングされます。

各バッチがキューに追加された後、ポーリングループが処理キューを 15 秒ごとにチェックし、すべてのリクエストが完了するまで待機します。キューが空になると、サーバーはシャットダウンされ、コンテナが終了し、SageMaker AI がインスタンスを終了させます。その後、Amazon S3 にアクセスして、ジョブのタイムスタンプで整理された生成画像をダウンロードし、CloudWatch ログを確認して問題がないかレビューできます。

手順解説

以下のセクションでは、SageMaker Processing Jobs 上で ComfyUI をデプロイするソリューションの手順を詳しく説明します。

前提条件

デプロイを開始する前に、必ず以下の準備が整っていることを確認してください:

  • Python 3.13+
  • AWS Command Line Interface (AWS CLI) を適切な認証情報で設定済み
  • Docker がインストールされ、実行中であること
  • AWS CDK v2
  • ターゲットの AWS アカウントおよび AWS リージョンで AWS CDK のブートストラップが完了していること

Setup

1. リポジトリのクローン

git clone https://github.com/aws-samples/sample-comfy-to-sagemaker-processing-job

2. 環境設定

例のテンプレートから環境ファイルを作成してください:

cp .env.example .env

.env ファイルを編集して、AWS アカウントの詳細を入力してください:

AWS_ACCOUNT_ID=your-account-id

REGION=us-east-1

3. 依存関係のインストール

本プロジェクトでは、依存関係管理に uv を使用しています:

# まだインストールしていない場合は uv をインストール

curl -LsSf https://astral.sh/uv/install.sh | sh

環境を作成

uv venv --python 3.13

環境をアクティブ化

source .venv/bin/activate

依存関係をインストール

uv sync

pip を使用することもできます:

pip install -r requirements.txt

4. AWS CDK のブートストラップ

ターゲットの AWS アカウントおよび AWS リージョンで AWS CDK をブートストラップしてください (AWS CDK デプロイに必要):

cdk bootstrap aws://YOUR-ACCOUNT-ID/YOUR-REGION

例:

cdk bootstrap aws://123456789012/us-east-1

5. サービスクォータのリクエスト

AWS Management Console を通じて、SageMaker AI の処理ジョブにおいて 6 つの ml.g5.xlarge インスタンスに対するサービスクォータの増額をリクエストしてください。

設定

処理ジョブの設定は config/config.yaml で定義されています:

  • インスタンスタイプ:ml.g5.xlarge (GPU 対応)
  • インスタンス数:6
  • ボリュームサイズ:125 GB
  • コンテナ:カスタム ComfyUI Docker イメージ

スタックのデプロイ

cdk deploy --all --require-approval never

注記:このコマンドを実行すると、コストが発生し始めます。

処理ジョブのトリガー

デプロイ後、AWS CDK コードによって作成された Lambda 関数を通じて処理ジョブをトリガーします。

関数名: ComfyUiSmStack-ProcessingJob-Trigger-ComfyUI-trigger-Lambda

以下の方法で関数を呼び出すことができます:

  • AWS Management Console (Lambda サービス → テストボタン)
  • AWS CLI:

aws lambda invoke --function-name response.json

呼び出されると、Lambda 関数は以下を行います:

  • タイムスタンプ付きの一意なジョブ名を生成します。
  • 事前定義された設定で SageMaker AI 処理ジョブ (SageMaker AI processing job) を作成します。
  • ml.g5.xlarge GPU インスタンス 6 台をプロビジョニングします。
  • ComfyUI ワークフローを実行します。

処理ジョブの出力

処理ジョブが完了すると、出力はソリューションによって作成された Amazon S3 出力バケットに保存されます。

サンプル

以下は、サンプルプロンプトで Z-Image を実行するバッチジョブからの例出力です。

image
image

クリーンアップ

継続的な課金を避けるために、以下のクリーンアップ手順を完了してください。

Amazon S3 バケットの空化

aws s3 rm s3:// --recursive

aws s3 rm s3:// --recursive

AWS CDK スタックの削除

cdk destroy --all --force

結論

本記事では、SageMaker AI の処理ジョブで ComfyUI ワークフローを実行することで、企業が大規模な AI 駆動型コンテンツ生成を自動化する方法について紹介しました。ComfyUI と SageMaker AI の管理された GPU インフラストラクチャを組み合わせることで、数百枚の高品質画像を生成するバッチジョブを作成し、従来クリエイティブチームに数週間かかっていたプロセスを、1 時間未満で完了できる仕組みを実現しました。

このソリューションでは、Z-Image Turbo の 6B パラメータ拡散トランスフォーマーモデル(diffusion transformer model)を使用し、推論コストを抑えつつ写実的な画像を提供しています。AWS CDK は、セキュリティ、暗号化、ネットワーク分離を最初から組み込んだ形でインフラストラクチャを展開しました。秒単位課金とインスタンスの自動終了機能により、企業は実際に使用した計算リソース分のみを支払うことができ、アイドル状態のリソースによるコストを軽減できます。

AI 駆動型コンテンツ生成は、競争力のある企業にとってますます重要になっています。ComfyUI と Amazon SageMaker AI を組み合わせることで、安全で費用対効果の高いインフラストラクチャを用いて大規模なコンテンツ生成の自動化が可能になります。まずは、SageMaker AI のドキュメントおよび本ソリューション用の GitHub リポジトリ をご覧ください。ComfyUI と SageMaker AI をコンテンツ生成にどのように活用しているか、ぜひお聞かせください。ご自身のユースケースや質問をコメント欄で共有してください。

著者について

imageimage

## Nick Biso

Nick は AWS Professional Services の機械学習エンジニアです。データサイエンスとエンジニアリングを活用して、組織的および技術的な複雑な課題を解決しています。さらに、AWS クラウド上で AI/ML モデルの構築とデプロイも行っています。彼の情熱は旅行や多様な文化的体験にも及んでいます。

<img loading="lazy" class="alignleft size-full" src="https://d2908q01vomqb2.

原文を表示

With ComfyUI workflows on Amazon SageMaker AI processing jobs, you can automate content generation at scale. For enterprises, every delay or misstep in creating compelling multimedia assets can mean lost sales, faded brand relevance, or missed marketing deadlines. When a product launch deadline looms or a seasonal promotion needs urgent assets, waiting for designers to iterate on a single social media post or a 15-second video ad can cost thousands in lost conversions.

You can automate the creation of revenue-driving images, audio, and video at scale with AI. Imagine generating hundreds of on-brand social media visuals in an hour for a global campaign, synthesizing hyper-personalized voiceovers for multilingual ad audits, or producing video clips with AI-crafted scripts and visuals, while staying tightly aligned with brand guidelines. Another benefit is freeing creative teams to focus on high-impact strategy while AI handles repetitive, time-consuming tasks. For enterprises, time saved in content production is time spent launching another campaign, targeting another niche audience, or re-engaging lost customers.

In this post, we walk you through how to deploy ComfyUI workflows on Amazon SageMaker AI processing jobs to generate hundreds of high-quality images in a single batch. You learn how to set up the infrastructure using AWS Cloud Development Kit (AWS CDK), configure GPU-accelerated processing, and automate image generation at scale. You can then adapt this solution to your ComfyUI workflows specific to your needs. We will guide you through a practical, step-by-step process to automate ComfyUI workflows to generate hundreds of high-quality images in a single batch empowering you to scale your creative pipeline.

Why this matters

Running ComfyUI on SageMaker AI processing jobs provides several key benefits for your content pipeline:

  • Accelerate campaigns: Generate content within minutes to hours depending on the size, capturing fleeting trends and deadlines.
  • Boost conversions through personalization: Deliver tailored visuals, voiceovers, and videos to distinct audience segments driving higher click-through and purchase rates.
  • Protect brand equity: Enforce consistent style, tone, and compliance across media types.
  • Safe prototyping, confident scaling: Test AI-generated content in controlled environments before rolling out to global audiences.

ComfyUI

ComfyUI is a node-based, visual workflow builder for generative AI that makes it straightforward to compose, test, and iterate on complex image, audio, or video pipelines without coding every step. You connect modular components into a reproducible graph that can be versioned and shared across teams.

Deploying ComfyUI on SageMaker AI processing jobs brings several benefits to your image generation workflows. GPU-accelerated instances deliver fast inference times, while pay-per-second billing with automatic job termination makes sure you only pay for the compute you use. The queue-based architecture scales naturally with your workload, processing multiple requests in parallel without manual intervention. Lastly, you can export your own ComfyUI workflow as JSON and have it deployed.

Image generation with Z-Image Turbo

Z-Image Turbo introduces a Scalable Single-Stream Transformer architecture (S3DiT) for text-to-image diffusion. Z-Image concatenates text and image modality tokens into one unified sequence (Early Fusion), allowing dense cross-modal interaction at every layer. This early fusion design means the model treats text tokens, image latent tokens, and even image semantic tokens uniformly in the Transformer, maximizing parameter sharing across modalities.

Z-Image Turbo uses a decoder-only Transformer backbone, inspired by large language model (LLM) decoders, with 30 layers, hidden size 3840, 32 attention heads, 10240 Feed Forward network intermediate dimensions, and a total of 6B parameters. This backbone alternates single-stream multi-head attention blocks and single-stream feed-forward blocks, each customized for stability using normalization and gating techniques.

For this solution we use ComfyUI’s workflow for Z-image Turbo stored in the processing job container. This workflow can be swapped into your ComfyUI workflow. When changing workflows, make sure that you have the models used in the workflow downloaded, custom nodes installed in the container, and your instance type has enough VRAM.

Other use cases

Although this example focuses on image generation, ComfyUI’s workflow engine can scale AI-driven creative tasks as mentioned previously, whether it’s audio synthesis, 3D asset rendering, or dynamic video animations, allowing enterprises to automate diverse content pipelines at scale. By using AWS infrastructure, businesses can deploy these workflows across thousands of outputs, turning every creative idea into a revenue-generating asset. Here are some examples of other applications of running ComfyUI as a batch job for large-scale generation:

  • Scalable ad creative A/B testing at speed: Automatically produce hundreds of ad variants, social media carousels, video snippets, or social media ready clips for global campaigns, including hyper-specific designs or style iterations (minimalist or bold) to test which creative resonates best with each demographic.
  • Dynamic packaging and label design for global launches: Generate locale-specific designs for international product launches, adapting colors, imagery, and text to align with regional aesthetics, regulations, or holidays (for example, Lunar New Year-themed labels), and test multiple designs at scale before physical production.
  • Interactive video storytelling for gaming and entertainment: Build branching video narratives for games, streaming services, or interactive ads where AI generates dynamic cutscenes that change based on user choices, such as hero appearances or dialogue options, turning passive viewing into an engaging, personalized experience.

Solution architecture

Now that you understand the business value and use cases, let’s explore how to implement this solution. The architecture uses three AWS CDK stacks: the DataStack with an Amazon Simple Storage Service (Amazon S3) output bucket, the SecurityStack with an Amazon Virtual Private Cloud (Amazon VPC), and the ComfyUISmStack with an AWS Lambda trigger function. It also uses a SageMaker AI processing job running on a GPU instance, Amazon Elastic Container Registry (Amazon ECR) for the container image, and Amazon CloudWatch for logging. The processing job runs inside the VPC’s private subnets. To see the full code implementation, see the GitHub repo.

DataStack

The DataStack implements the storage layer using Amazon S3 buckets with server-side encryption for output data. The output bucket stores the generated images from ComfyUI workflows.

SecurityStack

The SecurityStack establishes the foundational security infrastructure for the entire solution. It creates an Amazon VPC with public and private subnets across two Availability Zones for high availability (HA) and network isolation. The VPC includes a NAT gateway for secure outbound internet access from private subnets where SageMaker AI processing jobs run.

A customer-managed AWS Key Management Service (AWS KMS) key provides encryption at rest for data, including Amazon S3 buckets, Amazon CloudWatch logs, and environment variables. The key has automatic rotation enabled and includes resource policies allowing AWS services like Amazon S3 and CloudWatch to use it for encryption operations. VPC Flow Logs are enabled and sent to CloudWatch for network traffic monitoring and security analysis.

ComfyUISmStack

The ComfyUISmStack orchestrates the core processing pipeline through an AWS Lambda function that triggers SageMaker AI processing jobs. The Lambda function can be invoked manually to initiate GPU-powered processing using ml.g5.xlarge instances running a custom Docker container. This container packages ComfyUI with the Z-Image Turbo model, providing high-quality image generation with configurable parameters for prompts, seeds, and batch processing.

The stack creates a reusable processing job construct that handles Docker image building and deployment to Amazon ECR, AWS Identity and Access Management (IAM) role creation with comprehensive permissions for SageMaker AI, Amazon S3, Amazon ECR, Amazon VPC, and CloudWatch access, processing job definition with VPC integration, AWS KMS encryption, and network isolation, as well as Lambda trigger function configuration with environment variables containing the full job configuration.

The processing job runs in private subnets for secure AWS service communication. Container logs stream to CloudWatch for real-time monitoring and troubleshooting. The job uses continuous Amazon S3 upload mode, streaming generated images to the output bucket as they’re created rather than waiting for job completion.

Process flow

The process begins when you trigger the Lambda function, which creates a processing job and submits it to SageMaker AI. SageMaker AI provisions a GPU instance within the private network, pulls the ComfyUI container image from the registry, and deploys it with the necessary storage and network configurations. After the container is running, the ComfyUI server:

  • Downloads AI model components from HuggingFace through a secure outbound connection.
  • Organizes them into their respective directories.
  • Loads models into GPU memory and waits for full initialization.

With the server ready, the system reads text prompts from a file and loops through them in batches. For each image, it:

  • Selects a prompt based on a unique seed value.
  • Populates the workflow template with the prompt and seed.
  • Sends the request to ComfyUI for processing.

The GPU generates each image based on the workflow instructions. As images are produced:

  • They’re written to an output directory and synced to Amazon S3 in real time, making results available before the job finishes.
  • Container logs stream to CloudWatch for monitoring and troubleshooting.

After each batch is queued, a polling loop checks the processing queue every 15 seconds until all requests finish. After the queue is empty, the server shuts down, the container exits, and SageMaker AI terminates the instance. You can then access Amazon S3 to download generated images organized by job timestamp, and review CloudWatch logs for issues.

Walkthrough

The following sections walk through deploying the ComfyUI on SageMaker Processing Jobs solution.

Prerequisites

Before beginning deployment, make sure that you have the following:

  • Python 3.13+
  • AWS Command Line Interface (AWS CLI) configured with appropriate credentials
  • Docker installed and running
  • AWS CDK v2
  • AWS CDK bootstrapped in your target AWS account and AWS Region

Setup

1. Clone the repository

code
git clone https://github.com/aws-samples/sample-comfy-to-sagemaker-processing-job

2. Environment configuration

Create your environment file from the example template:

code
cp .env.example .env

Edit .env with your AWS account details:

code
AWS_ACCOUNT_ID=your-account-id
REGION=us-east-1

3. Install dependencies

This project uses uv for dependency management:

code
# Install uv if you haven't already
curl -LsSf https://astral.sh/uv/install.sh | sh

# Create environment
uv venv --python 3.13

# Activate Environment
source .venv/bin/activate

# Install dependencies
uv sync

You can also use pip:

code
pip install -r requirements.txt

4. Bootstrap AWS CDK

Bootstrap AWS CDK in your target AWS account and AWS Region (required for AWS CDK deployments):

code
cdk bootstrap aws://YOUR-ACCOUNT-ID/YOUR-REGION

For example:

code
cdk bootstrap aws://123456789012/us-east-1

5. Service quota request

Request a service quota increase for six ml.g5.xlarge instances in SageMaker AI processing jobs through the AWS Management Console.

Configuration

The processing job configuration is defined in config/config.yaml:

  • Instance type: ml.g5.xlarge (GPU-enabled)
  • Instance count: 6
  • Volume size: 125 GB
  • Container: Custom ComfyUI Docker image

Deploy stacks

code
cdk deploy --all --require-approval never

Note: you will start incurring cost by running this command.

Trigger the processing job

After deployment, trigger processing jobs through the Lambda function created by the AWS CDK code.

Function name: ComfyUiSmStack-ProcessingJob-Trigger-ComfyUI-trigger-Lambda

You can invoke the function through the:

  • AWS Management Console (Lambda service → Test button)
  • AWS CLI:
code
aws lambda invoke --function-name  response.json

When invoked, the Lambda function:

  • Generates a unique job name with timestamp.
  • Creates a SageMaker AI processing job with the predefined configuration.
  • Provisions six ml.g5.xlarge GPU instances.
  • Runs the ComfyUI workflow.

Processing job outputs

After the processing job finishes, outputs are stored in the Amazon S3 output bucket created by the solution.

Samples

The following are example outputs from a batch job that runs Z-Image on sample prompts.

Clean up

To avoid ongoing charges, complete the following cleanup steps.

Empty Amazon S3 buckets

code
aws s3 rm s3:// --recursive

aws s3 rm s3:// --recursive

Destroy AWS CDK stacks

code
cdk destroy --all --force

Conclusion

In this post, we demonstrated how enterprises can automate AI-powered content generation at scale by running ComfyUI workflows on SageMaker AI processing jobs. By combining ComfyUI with the managed GPU infrastructure of SageMaker AI, we created a batch job that generates hundreds of high-quality images, turning what traditionally took creative teams weeks into a process that finishes in under an hour.

This solution used Z-Image Turbo’s 6B-parameter diffusion transformer model to deliver photorealistic images while keeping inference costs low. The AWS CDK deployed the infrastructure with security, encryption, and network isolation built in from the ground up. With pay-per-second billing and automatic instance termination, enterprises only pay for the compute that they consume, alleviating idle resource costs.

AI-powered content generation is becoming increasingly important for competitive enterprises. By combining ComfyUI with Amazon SageMaker AI, you can automate content generation at scale with secure, cost-effective infrastructure. To get started, visit the SageMaker AI documentation and the GitHub repository for this solution. We’d love to hear how you’re using ComfyUI and SageMaker AI for content generation. Share your use cases and questions in the comments.

About the authors

Nick Biso
Nick Biso

Nick Biso

Nick is a Machine Learning Engineer at AWS Professional Services. He solves complex organizational and technical challenges using data science and engineering. In addition, he builds and deploys AI/ML models on the AWS Cloud. His passion extends to his proclivity for travel and diverse cultural experiences.

<img loading="lazy" class="alignleft size-full" src="https://d2908q01vomqb2.

この記事をシェア

関連記事

404 Media★32026年6月24日 22:34

スナップの AI スペックス:笑えるほど奇妙な体験

404 Media は、チャールズ国王の肖像画を背景に、巨大で重たい Snap Specs を装着した際、デジタル版が実像に重ねられ、ナレーターが蝶に触れるよう指示する奇妙な体験を紹介している。

MarkTechPost★42026年6月24日 17:12

2026 年版生成 AI コーディングツール比較:16 の最良ツールと特徴、最適な用途

MarkTechPost は、ソフトウェア構築を再定義した生成 AI ツールの中から、2026 年に最も優れた 16 のツールを選定し、各機能や開発者への適合性を比較して紹介している。

AWS Machine Learning Blog★42026年6月24日 01:39

Amazon Bedrock AgentCore を活用したタンパク質研究コパイロットの構築方法

AWS は、Amazon Bedrock AgentCore を使用して、研究者が自然言語でペプチドを検索し、AI が結果を要約するタンパク質研究用コパイロットを構築する方法を発表しました。

今日のまとめ

AI日報で今日の重要ニュースをまとめ読み

ニュース一覧に戻る元記事を読む