Skip to content

Latest commit

 

History

History
59 lines (38 loc) · 1.24 KB

File metadata and controls

59 lines (38 loc) · 1.24 KB

Background Removal Cloud Function

Google Cloud Run function that removes backgrounds from images using @imgly/background-removal-node.

Local Development

Install dependencies:

bun install

Start the local development server:

bun dev

The server will start on http://localhost:8080.

Testing

Test local version

Make sure the local server is running (bun dev), then:

make test-local

Test deployed version

make test-remote REMOTE_URL=https://your-cloud-function-url

Both commands use a test image from __fixtures__/img.png and save the result to __fixtures__/.

Models

The models/ folder contains pre-baked ML models bundled with the function. This prevents network requests to download models at runtime, avoiding potential failures and timeouts.

Deployment

Deploy to Google Cloud Run Functions using the gcloud CLI:

gcloud functions deploy removeBackground \
  --gen2 \
  --runtime=nodejs18 \
  --trigger-http \
  --allow-unauthenticated \
  --memory=2Gi \
  --source=.

License

This project is licensed under the GNU Affero General Public License v3.0.