This React app lets you upload a person photo and a product image, submits both to Google Vertex AI’s virtual-try-on-preview-08-04 model, and shows every generated try-on result in a gallery with download links.
npm install
npm startThe dev server runs at http://localhost:3000. The included setupProxy.js file exposes a local endpoint at /api/virtual-try-on that forwards requests to Vertex AI so you do not have to deal with CORS inside the browser.
- The browser reads both uploaded images as base64 strings.
- You can request between 1 and 4 outputs by setting the Sample Count field before submitting.
- A POST request is sent to
/api/virtual-try-oncontaining the base64 payload and an OAuth access token. - The proxy attaches the token as the
Authorizationheader and forwards the payload to the Vertex AI REST endpoint. - Any base64 images in the response are appended to the on-page gallery, with the current product image pinned to the front as a reference.
- Run
npm startand open the app. - Paste a valid OAuth token with
aiplatform.predictscope. - Pick a sample count (1-4), then upload a person image and a product image.
- Click Generate Try-On and wait for the response.
- Confirm the status bar updates, thumbnails render, and the download link saves a PNG.
- Use Clear Gallery to remove previous results.
Tokens and images never leave your browser except for the call to Vertex AI. The proxy only relays each request and response.*** End Patch}assistant