Image Classification Pipeline with Multi-Stage LLM Analysis

I built a multi-stage classification system that uses large language models to triage telecom infrastructure images—separating useful field photos from noise, then classifying them into operational categories—all logged and tracked through BigQuery for continuous performance monitoring.

LLM VisionMulti-Stage PipelineBigQueryTelecom Infrastructure

The Problem

When I first received this project, the immediate question was not about which model to use. It was about understanding what exactly the business needed from these images. Telecom field teams generate thousands of photos every week—images of fiber installations, pole infrastructure, underground conduits, site surveys, and cartographic plans. But mixed into this flood of visual data is an enormous amount of noise: accidental screenshots, blurry captures, photos of lunch breaks, duplicates, and entirely irrelevant content.

The operations team was spending hours each day manually sorting through image uploads to find the ones that actually mattered for project tracking and compliance reporting. They needed to know which images showed real infrastructure work, which ones were cartographic planning documents, and which ones could be discarded entirely. The volume made manual review unsustainable, and simple rule-based filtering (file size, metadata) caught less than 20% of the irrelevant content.

The deeper challenge was that this wasn't a standard image classification problem. The categories were highly context-specific to telecom operations, the training data was limited and inconsistent, and the business required not just a label but a justification for each decision—auditors needed to understand why an image was classified a certain way. Traditional CNN approaches would have required months of labeled data collection. I needed a solution that could leverage contextual understanding from day one.

The Approach

I designed the system as a multi-stage pipeline, where each stage acts as a progressively finer filter. The first insight was that trying to solve everything in one classification step would be both unreliable and opaque. Instead, I broke the problem into three sequential decisions, each with its own specialized LLM prompt and confidence threshold.

Decision: Multi-Stage vs. Single-Pass Classification

A single prompt asking "what is this image?" produced inconsistent results because the task was too broad. By decomposing into (1) Is this useful? (2) Is it a photo or a plan? (3) What infrastructure type?, each stage had a focused, well-defined task that the LLM could handle with much higher reliability. The trade-off was latency—three API calls per image—but accuracy mattered far more than speed for this batch processing workflow.

The first stage performs utility detection: is this image relevant to telecom operations at all? This eliminates the bulk of noise immediately. Images that pass proceed to the second stage, which performs a binary segmentation between field photographs and cartographic/planning documents—a distinction that determines the downstream workflow. The third stage identifies the specific infrastructure type (fiber, pole, conduit, cabinet, etc.) and generates a structured classification with confidence scores.

Decision: LLM Vision vs. Fine-Tuned CNN

I chose LLM-based classification over training a custom CNN for three reasons: (1) zero-shot capability meant we could deploy immediately without months of labeling, (2) the LLM naturally generates textual justifications that satisfy audit requirements, and (3) prompt engineering allows rapid iteration on classification logic without retraining. The cost per image was higher, but the time-to-value was weeks instead of months.

Implementation Details

The technical implementation required solving several non-trivial problems. First, image preprocessing: field photos come in wildly different resolutions and formats. I built a normalization layer that resizes images to optimal dimensions for LLM processing while preserving enough detail for classification, then encodes them to base64 for API compatibility. Large images are center-cropped or resized to stay within token budgets without losing critical visual information.

The prompt engineering was the most iterative part of the project. Each classification stage has a carefully crafted system prompt that provides domain context (what telecom infrastructure looks like, what cartographic plans contain, what constitutes "irrelevant"), followed by structured output instructions that enforce JSON responses with specific fields. I developed a prompt versioning system so we could A/B test different prompt formulations and track which versions produced the best precision/recall trade-offs.

BigQuery integration serves as both the logging backbone and the performance monitoring layer. Every classification decision is logged with the image metadata, the prompt version used, the model's response, confidence scores, and processing time. This creates a continuous feedback loop—when the operations team overrides a classification, that correction feeds back into prompt refinement. Weekly performance dashboards show accuracy trends, confidence distributions, and processing volumes across different image categories.

The automated routing system takes classification results and organizes images into the appropriate storage paths and project management systems. Photos of completed installations go to the compliance folder, cartographic plans route to the planning team's workspace, and irrelevant images are quarantined for periodic review rather than deleted outright—a safety net that proved valuable during the initial calibration period.

Key Takeaway

LLMs excel at classification tasks where the categories are domain-specific and hard to define with traditional features—but only when you decompose the problem into focused, sequential decisions. A single "classify everything" prompt fails; a pipeline of narrow, well-prompted stages produces reliable, auditable results. The real value isn't just the label—it's the generated justification that makes the system trustworthy to non-technical stakeholders.

Comments

FAQ

What is the key takeaway from "Image Classification Pipeline with Multi-Stage LLM Analysis"?

Multi-stage image classification pipeline using LLMs for telecom infrastructure triage, separating useful imagery from noise and classifying photos vs. cartographic plans.

Who wrote this and what is it about?

This was written by Mahmoud Trigui, Senior Data Scientist. Multi-stage image classification pipeline using LLMs for telecom infrastructure triage, separating useful imagery from noise and classifying photos vs. cartographic plans.

Machine Learning Feature Engineering MLForecast Time Series Decomposition Forecasting LightGBM XGBoost Catboost Clustering Segmentation NLP LLMs Web App R Markdown SQL Oracle DB SAS-Guide SAS E-Miner Dataiku BigQuery GCP Python R CRISP-DM Hypothesis Testing ANOVA Data Analytics Dimensionality Reduction Recommendation System Network Analysis Geospace Analysis Spatial Data Embedding Sampling Techniques Decision Rules Data Storytelling CVM Churn Fraud Detection Sentiment Analysis Topic Modeling IBM Watson PowerBI Looker Studio VBA Statistical Learning Ensemble Modeling Stacking Cross-Validation Profiling ABT Construction Plumber Tidyverse Shiny Prophet Deep Learning Scikit-Learn JSON SAS Programming Git VS Code CSS Styling Automated Reporting Outlier Detection Temporal Clustering Startup Survival Pre-Valuation Modeling K-Means Decision Trees Data Science Predictive Modeling SVM LDA Text Classification Weight Prediction Pattern Recognition Real-Time Detection Community Detection Pipeline Automation Data Quality Checks Data Reliability Specification Mapping Business Strategy Marketing Campaigns Try & Buy Frameworks KPI Dashboards Network Quality Sales Analytics Mentoring Statistics Lecturer Remote Work Hybrid Work Consulting Contract Full-Time Freelance Sofrecom Orange Group Tunisia Telecom Kiota Intelligence VC Analytics Series A Prediction Production ML Applied AI Prompt Engineering Business Forecasting Decision Systems Graph Analytics Household Detection Multi-SIM Detection FTTH Forecasting Audit Extraction Infrastructure Classification Pydantic GPT-4 OpenAI API Base64 Classification Zindi Codementor LAAS-CNRS ESSAI MIT xPRO Tunisia ML Competition Cell Tower Analysis Uber Logistics Uber Cape Town Necessary Condition Analysis Behavioral Signals Spike Smoothing Observation Unit Design Dendrogram Ward Clustering VIF Target Encoding Machine Learning Feature Engineering MLForecast Time Series Decomposition Forecasting LightGBM XGBoost Catboost Clustering Segmentation NLP LLMs Web App R Markdown SQL Oracle DB SAS-Guide SAS E-Miner Dataiku BigQuery GCP Python R CRISP-DM Hypothesis Testing ANOVA Data Analytics Dimensionality Reduction Recommendation System Network Analysis Geospace Analysis Spatial Data Embedding Sampling Techniques Decision Rules Data Storytelling CVM Churn Fraud Detection Sentiment Analysis Topic Modeling IBM Watson PowerBI Looker Studio VBA Statistical Learning Ensemble Modeling Stacking Cross-Validation Profiling ABT Construction Plumber Tidyverse Shiny Prophet Deep Learning Scikit-Learn JSON SAS Programming Git VS Code CSS Styling Automated Reporting Outlier Detection Temporal Clustering Startup Survival Pre-Valuation Modeling K-Means Decision Trees Data Science Predictive Modeling SVM LDA Text Classification Weight Prediction Pattern Recognition Real-Time Detection Community Detection Pipeline Automation Data Quality Checks Data Reliability Specification Mapping Business Strategy Marketing Campaigns Try & Buy Frameworks KPI Dashboards Network Quality Sales Analytics Mentoring Statistics Lecturer Remote Work Hybrid Work Consulting Contract Full-Time Freelance Sofrecom Orange Group Tunisia Telecom Kiota Intelligence VC Analytics Series A Prediction Production ML Applied AI Prompt Engineering Business Forecasting Decision Systems Graph Analytics Household Detection Multi-SIM Detection FTTH Forecasting Audit Extraction Infrastructure Classification Pydantic GPT-4 OpenAI API Base64 Classification Zindi Codementor LAAS-CNRS ESSAI MIT xPRO Tunisia ML Competition Cell Tower Analysis Uber Logistics Uber Cape Town Necessary Condition Analysis Behavioral Signals Spike Smoothing Observation Unit Design Dendrogram Ward Clustering VIF Target Encoding