Skip to content

About

Sketch-to-3D is an end-to-end Gen AI pipeline deployed on AWS transforming 2D sketches into photorealistic product images and interactive 3D models.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

3 stars

Watchers

0 watching

Forks

Repository files navigation

Product Conception: From Sketch to 3D

Sketch-to-3D is an end-to-end generative AI pipeline for fashion design: it transforms hand-drawn sketches into photorealistic product images and interactive 3D models, deployed on AWS with real-time updates.

Demo

Index

Architecture

The Sketch-to-3D sample uses Amazon SageMaker for ML inference (FLUX.2 and TRELLIS.2), Amazon S3 for storage, AWS AppSync for real-time GraphQL subscriptions, Amazon DynamoDB for state management, Amazon Cognito for authentication, AWS Lambda for orchestration, and AWS Amplify with React for the frontend.

Reference Architecture

There are two main inference flows:

  • Sketch to Image (A): User uploads a sketch → S3 trigger Lambda reads job parameters → invokes SageMaker FLUX.2 async endpoint → 5 photorealistic variants generated in ~17s → results written to S3 → DynamoDB Streams push updates via AppSync to the frontend in real time.
  • Image to 3D (B): User selects a variant → trigger Lambda invokes SageMaker TRELLIS.2 async endpoint → 3D GLB mesh with baked textures generated → result delivered via AppSync subscription → interactive 3D viewer in browser.

For a detailed breakdown of stacks, project structure, security controls, and costs, see docs/ARCHITECTURE.md. The React frontend is documented separately in docs/FRONTEND.md.

Usage

Prerequisites

To deploy the sample application you will require an AWS account. If you don't already have an AWS account, create one at https://aws.amazon.com by following the on-screen instructions. Your access to the AWS account must have IAM permissions to launch AWS CDK stacks that create IAM roles.

You will also need:

  • AWS CLI v2 configured
  • Python 3.10+
  • Node.js 20+
  • AWS CDK CLI, recent version (npm install -g aws-cdk@latest). The CLI must be new enough to read the cloud-assembly schema produced by the pinned aws-cdk-lib; an outdated CLI fails with a "Cloud assembly schema version mismatch" error. If you hit that, upgrade the CLI.
  • Docker Desktop running
  • SageMaker ml.g7e.12xlarge for endpoint usage quota ≥ 2 — the exact Service Quotas name (request via the Service Quotas console)
  • Bedrock model access enabled for Claude Haiku 4.5 in the deploy region. The default model ID is the US cross-region inference profile (us.anthropic.claude-haiku-4-5-...). If you deploy outside us-*, override BEDROCK_MODEL_ID in config.env with the inference profile for your region (e.g. eu.anthropic.claude-haiku-4-5-...) — otherwise sketch analysis fails at runtime with an AccessDenied/Validation error.
  • A HuggingFace token with the gated approvals for facebook/dinov3-vitl16-pretrain-lvd1689m and briaai/RMBG-2.0

To use the sample application you will require a modern browser.

Deployment

Note: You are responsible for the cost of the AWS services used while running this sample deployment. There is no additional cost for using this sample. For full details, see the pricing pages for each AWS service you will be using in this sample. Prices are subject to change.

git clone https://github.com/aws-samples/sample-retail-sketch-to-3d.git
cd sample-retail-sketch-to-3d

# Install dependencies
cd backend && python3 -m venv .venv && source .venv/bin/activate && pip install -r requirements.txt
cd ../frontend && npm install && cd ../backend

# Create your config and set the deploy account + region.
# (setup_prerequisites resolves the account from STS automatically, but the
#  other tools — cdk, sync_config — read these values from config.env.)
cp config.env.example config.env
export AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
export AWS_REGION=us-east-1   # must match your Bedrock/quota region (see below)
# then edit config.env to set AWS_ACCOUNT_ID and AWS_REGION accordingly

# Store HuggingFace token (both containers download gated weights at build/runtime)
aws ssm put-parameter --name /sketch-to-3d/hf-token         --type SecureString --value "hf_..." --region us-east-1
aws ssm put-parameter --name /sketch-to-3d/hf-token-trellis --type SecureString --value "hf_..." --region us-east-1

# Provision S3 + Cognito + IAM
python3 scripts/setup_prerequisites.py --skip-ssm

# Deploy all five CDK stacks (~10–15 min; bootstrap is scoped to your account/region)
cdk bootstrap aws://$AWS_ACCOUNT_ID/$AWS_REGION && cdk deploy --all && python3 scripts/sync_config.py

# Build + deploy the two SageMaker endpoints (≈40–70 min each, can run in parallel)
(cd containers/sketch_to_image && ./build_and_push.sh --codebuild --wait) && python3 scripts/create_endpoint.py
(cd containers/trellis && ./build_and_push.sh --codebuild --wait) && python3 scripts/create_trellis_endpoint.py

# Deploy the frontend
cd ../frontend && python3 ../backend/scripts/generate_frontend_env.py && bash deploy-frontend.sh

# Tighten CORS now that the Amplify app exists
cd ../backend && cdk deploy --all && python3 scripts/setup_prerequisites.py --skip-ssm && python3 scripts/update_identity_pool_policy.py

For full step-by-step instructions, post-deploy hardening, and troubleshooting, see docs/DEPLOYMENT.md.

Accessing the Application

  1. Create a user — self sign-up is disabled for security. Create your first user via the CLI:
    aws cognito-idp admin-create-user --user-pool-id <YOUR_USER_POOL_ID> \
      --username "you@example.com" --temporary-password "TempPass123!!" \
      --user-attributes Name=email,Value=you@example.com Name=email_verified,Value=true \
      --region us-east-1
  2. Open the Amplify URL → sign in with the temporary password → set your permanent password (12-char minimum with symbol)
  3. Upload a sketch (drag & drop, take photo on mobile, or "Capture from Phone" QR flow on desktop)
  4. Pick garment type (auto-detected by Claude Haiku 4.5), colour, material, optional pattern / moodboard
  5. Generate Design → 5 variants in ≈17s → pick one
  6. 3D .glb generates automatically and displays in an interactive viewer

Cost

The two SageMaker endpoints cost ≈$22/h combined on ml.g7e.12xlarge. Always stop them after use — the rest of the stack is <$5/month.

python3 scripts/stop_endpoint.py           # FLUX
python3 scripts/stop_trellis_endpoint.py   # TRELLIS

Remove the Application

A single script tears down everything — SageMaker endpoints/configs/models, the five CDK stacks (cdk destroy --all), the S3 buckets and Cognito pools created by setup_prerequisites.py, the IAM roles, the ECR repos, and the Amplify app:

cd backend
python3 scripts/teardown.py --dry-run     # preview what will be deleted
python3 scripts/teardown.py               # delete (prompts for confirmation)

Useful flags:

  • --keep-ssm — preserve the HuggingFace SSM token parameters (skip re-storing the token on the next deploy)
  • --yes — skip the confirmation prompt (for automation)

The account-level SageMaker service quota is never touched.

Contributing

Contributions are more than welcome. Please read the code of conduct and the contributing guidelines.

License

This sample code is made available under the MIT-0 license. See the LICENSE file.

This project uses the following third-party models:

About

Sketch-to-3D is an end-to-end Gen AI pipeline deployed on AWS transforming 2D sketches into photorealistic product images and interactive 3D models.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages