AI Batch Image Classification to CMS: A Practical Guide for Industrial Product Catalogs

A practical guide to AI-powered image classification and bulk CMS import for industrial product catalogs.
This guide walks through using Claude Vision API to classify 400+ industrial product photos (uPVC and aluminum doors/windows) and bulk import them into Sanity CMS. It covers dual-signal cross-validation for material classification, hybrid naming strategies for decorative glass panels, transaction chunking to respect API limits, and idempotent design patterns for safe retries — turning AI's probabilistic outputs into reliable, production-ready structured data.
The Challenge: From 400 Product Photos to Structured CMS Data
As e-commerce and content management systems (CMS) increasingly rely on structured data, efficiently converting hundreds of product photos into well-organized database entries has become a real-world challenge many developers can't avoid. Recently, a Reddit developer shared a typical scenario he encountered while building a product catalog for a uPVC/aluminum door and window manufacturer in the UAE, sparking an in-depth discussion about AI visual classification and bulk CMS imports.
The project's tech stack is quite representative: Next.js 16 + Sanity v3 + TypeScript + Claude Vision API. Next.js 16 is Vercel's full-stack React framework supporting server-side rendering (SSR), static site generation (SSG), and incremental static regeneration (ISR) — particularly well-suited for building SEO-friendly e-commerce frontends. Sanity v3 is a leading headless CMS that provides real-time collaborative editing and the powerful GROQ query language through its Structured Content Lake, storing content as JSON documents that integrate naturally with modern frontend frameworks. Claude Vision API is Anthropic's multimodal large language model interface capable of understanding image content and outputting structured descriptions — compared to text-only models, it adds visual understanding capabilities and excels at analyzing product photos, identifying material textures, and extracting visual features.
The developer had approximately 400 photos organized by folders, such as public/products/upvc/windows/, public/products/aluminum/stained-glass/ (78 unique designs), and public/products/upvc/sandblast/ (32 unique designs). The goal was to map these images to Sanity's product schema, with fields including: bilingual titles (English/Arabic), material (upvc / aluminum), category (windows / doors / stained-glass / sandblast, etc.), main image, bilingual descriptions, feature lists, and specification objects.

Core Pain Points: Classification Errors and Naming Challenges
This seemingly simple data migration task actually hides two thorny problems.
Unreliable Folder Paths
The developer initially tried using folder paths as implicit classifiers, but quickly discovered that photos were frequently miscategorized — folder paths didn't always match the actual material. This is an extremely common issue in industrial product catalogs: human oversight during the shooting and organization phases leads to uPVC and aluminum product photos getting mixed together.
uPVC (Unplasticized Polyvinyl Chloride) is a rigid plastic material widely used in door and window profile manufacturing. Compared to traditional wood or metal, uPVC offers excellent weather resistance, thermal insulation, and maintenance-free properties — it won't corrode, fade, or need repainting. In Middle Eastern regions like the UAE, uPVC is particularly popular due to its outstanding thermal insulation in extreme heat. From a visual identification standpoint, uPVC profiles typically feature thicker walls (usually 2.5–3mm), more rounded corners, and a matte or semi-matte surface finish. White products dominate the market, though co-extrusion or lamination can achieve decorative effects like wood grain.
Relying solely on path information for bulk imports would amplify errors across the entire database.
The Naming Dilemma for 150+ Decorative Glass Panels
Even trickier: over 150 decorative glass panel images, each with a unique design requiring a unique name. Manually identifying each one with Google Lens was completely impractical at this scale — far too slow. These high-variety, low-structure products are precisely the scenario where traditional rule-based engines fall short.
Feasibility Analysis of AI Visual Classification
The developer's planned core pipeline was: Image → Structured JSON → Human review manifest → Sanity client bulk write. This "AI-generated + human-verified" semi-automated pipeline design is quite sound, but each stage has details worth examining closely.
uPVC vs. Aluminum Windows: Can Vision Reliably Tell Them Apart?
This is the most critical technical question. From a visual standpoint, uPVC and aluminum doors and windows do exhibit differences in finished product photos: uPVC profiles are typically thicker with rounded corners and matte surfaces, while aluminum profiles are slimmer with sharper edges and often have a metallic sheen. However, at certain angles, with white powder coating, or under strong lighting, the two can be extremely difficult to distinguish.
A more robust approach is to provide the folder path as a prior hint in the prompt, letting Claude Vision combine visual judgment with path cues to output a confidence score. When the model's determination conflicts with the folder path, flag that entry as "needs manual review" rather than blindly trusting either signal. This "dual-signal cross-validation" approach can significantly reduce misclassification rates.
Current multimodal AI models are fundamentally deep neural networks based on the Transformer architecture, and their outputs have inherent probabilistic characteristics — even for the same input, multiple calls may return slightly different results. This non-determinism stems from the model's sampling strategy and the intrinsic complexity of attention mechanisms. For production systems requiring strict consistency, common mitigation strategies include: setting a low temperature value to reduce randomness, requiring the model to output confidence scores, using multi-inference voting mechanisms for critical decisions, and treating AI output as suggestions rather than final decisions while retaining a human review step.
Sequential Naming or Free-Form Naming?
For naming the 78 stained glass panels, the developer was torn between two approaches: generating sequential names (like "Floral Arch No. 12") or letting the model freely name each one.
From an engineering maintainability perspective, a hybrid strategy is recommended: have the model generate descriptive semantic labels (like "Floral Arch" or "Geometric Diamond Grid"), then automatically append sequential suffixes to ensure uniqueness. Pure free-form naming tends to produce duplicate, overly long, or inconsistent names that create headaches for search and SEO; pure sequential naming sacrifices the semantic value of AI visual understanding. The semantic label + sequence number combination preserves readability while guaranteeing uniqueness and sortability.
Practical Considerations for Sanity Bulk Writes
The final critical issue falls on the engineering implementation level: what should you watch out for when using Sanity's transaction() API to batch-create 400 documents?
Transaction Size and Rate Limiting
Sanity's transaction() API uses an atomic transaction model, ensuring a batch of operations either all succeed or all roll back. It works on Optimistic Concurrency Control: the client submits transactions with document version information, and the server rejects the transaction when it detects conflicts. However, Sanity has implicit limits on individual transactions: request payloads generally shouldn't exceed 10MB, and a single transaction should ideally contain no more than 100 mutation operations. Exceeding these limits may result in 504 timeout or 429 rate-limit responses.
Additionally, Sanity's API rate-limiting strategy adjusts dynamically based on subscription tier: approximately 10 requests/second for the free tier and roughly 30 requests/second for the team tier. Therefore, batch operations should be chunked — for example, 50–100 documents per batch with appropriate delays between batches (e.g., 100–200ms) to avoid triggering API rate limits.
Image Asset Upload Order
A product's mainImage requires uploading the image as an asset to Sanity first, obtaining an asset reference, and then linking it to the document. This means image uploads should be an independent prerequisite step, not mixed into document transactions. Asynchronously uploading all images first, collecting references, and then batch-creating documents is a much cleaner layered approach.
Idempotency and Retry-Safe Design
The biggest fear with bulk imports is being unable to safely retry after a mid-process failure. Idempotency is a core principle of distributed system design, meaning that executing the same operation multiple times produces the same result as executing it once. In data import scenarios, idempotency is crucial: network jitter, process crashes, or manual interruptions can cause bulk tasks to fail mid-stream, and if operations aren't idempotent, retries will produce duplicate data or inconsistent states.
The recommendation is to generate deterministic document IDs for each product (e.g., a hash based on material, category, and filename), combined with createOrReplace or createIfNotExists, ensuring repeated runs don't produce dirty data. Common strategies for achieving idempotency include: using content hashes or UUID v5 for deterministic IDs, using conditional write operations, and modeling the import process as a state machine to ensure every state transition is idempotent.
Takeaways for Similar Projects
Although this case focuses on a door and window product catalog, its methodology offers universally applicable insights for any "large-scale unstructured media → structured database" migration task:
- Don't blindly trust a single signal: Whether it's folder paths or AI judgment, always cross-validate and retain a human review step.
- Let AI handle semantic understanding; let rules handle structural constraints: Use vision models for semantic comprehension, and deterministic rules to ensure uniqueness, formatting, and idempotency.
- Build layered, retry-safe pipelines: Image uploads, content generation, and database writes should be decoupled, with each step independently re-runnable.
As multimodal models like Claude Vision and GPT-4o continue to mature, these "AI-assisted data structuring" workflows are transitioning from experimental to production-ready. The real challenge is no longer whether models can understand images, but how to design a reliable, auditable, and scalable engineering pipeline that safely lands AI's probabilistic outputs into deterministic business systems.
Key Takeaways
- Tech stack selection reflects the modern full-stack paradigm: Next.js provides SEO-friendly frontend rendering, Sanity serves as a flexible headless CMS for content modeling, and Claude Vision API makes visual understanding available as an API call
- Dual verification mechanisms reduce classification errors: Combining folder path priors with AI visual judgment, triggering manual review for conflicting results, avoids systematic errors from relying on a single signal
- Hybrid naming strategies balance semantics and uniqueness: AI-generated descriptive labels preserve semantic value while automatic sequential suffixes ensure uniqueness, balancing human readability with system maintainability
- Transaction chunking and idempotency are critical for bulk imports: Respect Sanity's transaction size limits (50–100 documents per batch), and use deterministic IDs with createOrReplace to ensure operations are safely retryable
- AI output's probabilistic nature requires engineering solutions: Through confidence thresholds, human review manifests, low temperature settings, and similar strategies, probabilistic judgments are transformed into deterministic business decisions
Related articles

AI Agent Cost Optimization in Practice: Engineering Wisdom That Saved $1 Million in One Hour
Databricks eliminated $1M/year in wasted AI Agent spend in just one hour. Learn the root causes of Agent cost overruns and key strategies like model tiering, context pruning, and caching.

How the FDA Is Building an AI-Ready Data Foundation on Databricks
Explore how the FDA leverages Databricks for Government to build a unified Lakehouse architecture and AI-ready data foundation while meeting federal security and compliance standards.

The Power of Security Collaboration: Why Vulnerability Discovery Cannot Do Without Human Intelligence
Explore how security collaboration outperforms tool dependency, the value of vulnerability stories, cross-team knowledge sharing practices, and building stronger defenses by investing in people and collaboration.