-
-
Before 70, after 100: the agent fixed the image and changed zero product pixels.
-
Agentic loop: perceive, decide, act, verify, re-perceive.
-
Architecture: OpenCV 5 on AWS Lambda, Claude on Bedrock, S3, DynamoDB, API Gateway, CloudFront.
-
Agent timeline: Claude on Amazon Bedrock picks each OpenCV tool from the latest inspection; every step verified.
-
Compare slider, score 70 → 100, the agent's summary and a one-click download.
-
Upload a main image or paste an image link; examples and the 8 Amazon rules on the home page.
-
Issues view: OpenCV 5 marks each problem; tooltips quote Amazon's own rule next to how it is measured.
-
Proof: 616,621 product pixels compared, 0 changed. Search visibility rises from 70 to 89.
-
Knowing when not to edit: a lifestyle photo is refused and the seller is told what to reshoot.
Inspiration
On Amazon the main image is the listing's first impression, and Amazon enforces strict rules for it: a pure white background, the product filling 85% of the frame, no added text or badges, nothing cut off. A main image that breaks the rules can get the listing removed from search, and sellers usually find out after the sales are gone.
Existing tools either only flag problems or "fix" them with generative AI, which can quietly change the product itself. For a product photo that is the one thing that must never happen. I wanted an agent that fixes what it safely can, refuses what it cannot, and proves the product was not touched.
What it does
Upload a main image (or paste an image link) and the agent:
- Inspects it with OpenCV 5 against 8 rules taken from Amazon's own Seller Central page (G1881): pure white background, 85% fill, image size, no added text or badges, no border, sharpness, whole product in frame, exposure. It scores the image 0 to 100 and draws the problems on the photo.
- Plans the fixes: Claude on Amazon Bedrock reads the inspection report (never the pixels) and chooses which tools to run, in what order, or decides that a new photo is needed.
- Fixes with deterministic OpenCV tools only: remove a border, remove background text or badges, whiten the backdrop, reframe to fill, pad to square.
- Proves every edit: after each step the original product pixels are mapped onto the new image and compared one by one. If even one product pixel changes, the edit is rejected.
- Scores search visibility: the image is shown as a thumbnail among 8 other products and OpenCV saliency estimates how much attention it draws.
Every rule, status and tool has a tooltip quoting Amazon's wording next to how the agent measures it. The seller downloads the fixed image, or gets a clear list of what needs a reshoot. Lifestyle photos are never edited: the agent explains why instead of guessing what to erase.
How we built it
OpenCV 5 does every pixel.
- Backdrop segmentation: an edge-walled flood fill inward from the image edges (Canny edges stop it at the product outline, so printed labels and thin parts stay product). Lifestyle photos fall back to U²-Net-p through
cv2.dnnfor measuring only. - Text and badge detection: PP-OCRv3 DB through
cv2.dnn.TextDetectionModel_DB, plus a flat-colour test that tells added badges from printed packaging. - Fixes: masked whitening,
cv2.inpaint, crop and pad; sharpness from the Laplacian on product edges; search visibility fromcv2.saliency. - The product-unchanged check: exact comparison of every original product pixel through each crop and pad.
Claude only plans. Claude Opus 4.6 on Amazon Bedrock calls the fix tools through strict tool use, sees the updated report after each call, and writes the seller summary. A deterministic rule planner is the fallback.
AWS runs it. An AWS Lambda container (arm64) runs inspection and the agent; API Gateway (with rate limits), S3, DynamoDB and CloudFront serve the API, images, results and the React UI. Fix jobs run asynchronously so the UI can show each step live. It is deployed with AWS SAM, with a reserved-concurrency cap, a daily Claude cap and an AWS Budget alert.
Technical report: https://github.com/Balu-SG/listing-image-agent/blob/main/docs/REPORT.md Agent traces: https://github.com/Balu-SG/listing-image-agent/blob/main/docs/AGENT_TRACE.md
Challenges we ran into
- "Unchanged" was only as good as the mask. Early on, a salient-object model segmented only the bowl printed on a kidney-bean can, so whitening erased the can's label and the check still passed. Studio photos now use an edge-walled flood fill, and lifestyle photos are never edited.
- Telling a badge from packaging. Text on a product's own label is allowed; a "Best seller" sticker on the backdrop is not. Pieces outside the product outline that are flat-coloured rectangles with text are treated as overlays.
- Following Amazon, not assumptions. Reading Amazon's official requirements page showed that my 2x super-resolution tool broke the rule "Do not artificially enlarge small images", so it was removed. Centring turned out not to be an Amazon rule, so it became advice only.
- Reflections. A product's reflection touching the frame edge looked "cut off", and Claude reasonably refused to crop. The check now counts only solid (colourful or dark) pixels at the edge.
Accomplishments that we're proud of
- On 60 Amazon Berkeley Objects images, every fix passed the product-unchanged check (60 of 60), and the average score rose from 95 to 99.
- On a held-out set of 29 unseen images, the fill rule reached 0.93 precision and 0.93 recall. The labels and their limits are documented in the repo.
- The agent knows when not to edit: Claude declines lifestyle photos and explains what to reshoot.
- Every rule cites Amazon's own wording, so a seller sees why, not just what.
What we learned
- A safety guarantee is only as strong as the measurement behind it; the hard part was the mask, not the comparison.
- Keeping the language model away from pixels made the agent trustworthy: Claude chooses between deterministic tools, and every result is checked.
- Evaluate on images you did not tune on. Several bugs only showed up when real product photos disagreed with the labels.
What's next
- Catch badges that overlap the product, and check the Amazon rules a human still has to judge today: one unit only, no props, footwear facing left at 45 degrees.
- A human-labelled benchmark to replace the current AI-reviewed labels.
- Batch mode for whole catalogues, and secondary images with their own rules.
Built With
- amazon-api-gateway
- amazon-bedrock
- amazon-cloudfront
- amazon-dynamodb
- amazon-web-services
- aws-lambda
- aws-sam
- claude
- docker
- fastapi
- numpy
- opencv
- python
- react
- typescript
- vite
Log in or sign up for Devpost to join the conversation.