Skip to content

Arash-Alborz/Mini_CorteX

Repository files navigation

MiniCorteX – AI Inspection Pipeline

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.


Overview

This project implements a two-stage pipeline:

  1. Inspection Layer (Vision LLM)

    • Analyzes an image using a vision-capable LLM (OpenAI GPT-4o-mini)
    • Outputs structured JSON with defect detection results
  2. Insight Layer (LLM)

    • Converts structured inspection results into plain-English explanations
    • Designed for non-technical factory floor managers

Project Structure

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


Setup Instructions

  1. Clone the repository

git clone
cd your-repo

  1. Install dependencies

pip install -r requirements.txt

  1. Configure environment variables

Create a .env file in the root directory:

OPENAI_API_KEY=your_api_key_here

  1. 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.

  1. Run the application

cd src
python main.py


LLM Configuration

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

Example Output

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.


Design Decisions

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.


Testing

Run unit tests:

python -m unittest discover -s tests


Bonus: FastAPI Endpoint

A FastAPI endpoint is implemented to expose the pipeline as a REST API.

Run the API:

cd src
uvicorn api:app --reload

Then open:

http://127.0.0.1:8000/docs

Use the /inspect endpoint to upload an image and receive both inspection results and LLM insights.

Time Log

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


Future Improvements

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

AI Tool Usage

ChatGPT was used to assist with debugging, structuring the code, and refining prompt design. All code was reviewed, understood, and adapted manually.


Summary

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.

About

MiniCorteX: AI-powered image inspection pipeline using Vision LLMs and a conversational insight layer, with a FastAPI endpoint for real-time analysis.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages