MiniCorteX is a simplified version of an AI-powered visual inspection system. It analyzes product images for defects and generates human-readable insights for factory operators.
This project implements a two-stage pipeline:
-
Inspection Layer (Vision LLM)
- Analyzes an image using a vision-capable LLM (OpenAI GPT-4o-mini)
- Outputs structured JSON with defect detection results
-
Insight Layer (LLM)
- Converts structured inspection results into plain-English explanations
- Designed for non-technical factory floor managers
your-repo/
├── README.md
├── requirements.txt
├── .env.example
├── LEAD_NOTES.md
├── src/
│ ├── inspector.py # Vision-based defect detection (Task 1)
│ ├── llm_insight.py # Insight generation (Task 2)
│ └── main.py # Entry point
├── tests/
│ └── test_inspector.py # Unit tests
- Clone the repository
git clone
cd your-repo
- Install dependencies
pip install -r requirements.txt
- Configure environment variables
Create a .env file in the root directory:
OPENAI_API_KEY=your_api_key_here
- Add an image
There is an example image in the src/ folder. For other tests place an image file (e.g. image.jpg) inside the src/ folder. This way, the system can be tested in detecting different kinds of defects.
- Run the application
cd src
python main.py
This project uses the OpenAI API with the GPT-4o-mini model for both vision-based inspection and insight generation.
To configure the API key, create a .env file in the root directory:
OPENAI_API_KEY=your_api_key_here
Inspection Result (JSON)
{ "filename": "image.jpg", "status": "defect_detected", "confidence": 0.85, "defect_type": "crack", "processing_time_ms": 2613.97 }
LLM Insight (Plain English)
A crack was detected on the inspected part with high confidence. This may be caused by material stress or handling issues. The part should be reviewed and repaired or replaced if necessary.
Task 1 Approach: Vision LLM (Option C)
I chose a vision-capable LLM instead of rule-based or pretrained CV models because:
- Faster to implement under time constraints
- No need for dataset or training
- Flexible and adaptable to different defect types
Separation of Concerns
- Inspector handles perception (defect detection)
- LLM Insight handles reasoning (explanation and recommendation)
This keeps the system modular and easier to extend.
Confidence Handling
Confidence scores are guided via prompt engineering to avoid overconfident predictions, since LLM outputs are not inherently calibrated.
Run unit tests:
python -m unittest discover -s tests
A FastAPI endpoint is implemented to expose the pipeline as a REST API.
Run the API:
cd src
uvicorn api:app --reload
Then open:
Use the /inspect endpoint to upload an image and receive both inspection results and LLM insights.
Project setup: 20 min
Task 1 (Inspection): 60–75 min
Task 2 (LLM Insight): 45 min
Testing and debugging: 30 min
README and polish: 30 min
Total: approximately 3.5 hours
If given more time, I would:
- Replace Vision LLM with a fine-tuned defect detection model (e.g., YOLO)
- Add confidence calibration using real labeled data
- Improve robustness of JSON parsing with stricter validation
- Add API endpoint (FastAPI) for real-time usage
- Implement logging (CSV or database) for inspection history
ChatGPT was used to assist with debugging, structuring the code, and refining prompt design. All code was reviewed, understood, and adapted manually.
MiniCorteX demonstrates a practical AI pipeline combining vision-based defect detection, structured outputs, and a conversational explanation layer. It reflects a scalable approach toward real-world industrial AI systems.