A lightweight proof-of-concept for extracting structured engineering component information from schematics, diagrams, and equipment nameplates using Google's Gemini multimodal model.
Instead of allowing the LLM to generate free-form text, this project validates every response against a strict schema before presenting it to the user, providing a safer and more reliable extraction pipeline.
- Upload engineering drawings, schematics, or equipment images
- Extract structured component information using Gemini 2.5 Flash
- Validate outputs with Pydantic models
- Interactive Streamlit interface
- FastAPI backend for API-based integration
- JSON output suitable for downstream automation
Engineering Image
│
▼
Streamlit Frontend (app.py)
│
POST /extract (Multipart Image)
│
▼
FastAPI Backend (main.py)
│
▼
Gemini 2.5 Flash Vision Model
│
JSON Response
│
▼
Pydantic Validation (schema.py)
│
Validated Component Data
│
▼
Interactive Table in Streamlit
engineering-extractor/
│
├── app.py # Streamlit frontend
├── main.py # FastAPI server
├── extractor.py # Gemini inference logic
├── schema.py # Pydantic validation models
├── requirements.txt
└── README.md
| Component | Technology |
|---|---|
| Backend | FastAPI |
| Frontend | Streamlit |
| AI Model | Gemini 2.5 Flash |
| Validation | Pydantic v2 |
| Image Processing | Pillow |
| API | Google GenAI SDK |
Each detected engineering component is validated against the following structure:
Component(
tag_id: str,
component_type: str,
spec_value: str,
unit: str,
connections: List[str]
)Any response that does not conform to this schema is rejected before reaching the frontend.
- Python 3.10+
- Google AI Studio API Key
git clone <repository-url>
cd engineering-extractorpython -m venv venv
venv\Scripts\activatepython3 -m venv venv
source venv/bin/activatepip install fastapi \
uvicorn \
pydantic \
google-genai \
pillow \
python-multipart \
streamlit \
requestsThis project consists of two services.
uvicorn main:app --reloadRuns on:
http://localhost:8000
streamlit run app.pyRuns on:
http://localhost:8501
- Upload an engineering drawing.
- The image is sent to the FastAPI backend.
- Gemini analyzes the image.
- The model returns structured JSON.
- Pydantic validates the response.
- Valid data is displayed in Streamlit.
The system has no reference engineering database or asset registry.
As a result, it cannot automatically determine:
- whether every component was extracted,
- whether an object was missed,
- or whether the extracted values are factually correct.
The application validates structure, not semantic correctness.
The connections field is inferred entirely from Gemini's visual reasoning.
No computer vision techniques (such as OpenCV line tracing or graph extraction) are used to verify physical wiring or pipe connectivity.
Extraction accuracy depends heavily on input quality.
Blurred, low-resolution, poorly scanned, or low-contrast engineering drawings may produce incorrect identifiers or specification values.
- OpenCV-based line tracing
- OCR-assisted extraction
- Engineering symbol detection
- Asset registry integration
- Confidence scoring
- Batch image processing
- Export to CSV / Excel
- Human-in-the-loop verification
- Support for P&ID and electrical CAD drawings
- Engineering drawing digitization
- Equipment inventory generation
- P&ID preprocessing
- Legacy documentation modernization
- Industrial asset extraction
- Engineering data pipelines
This project is intended as a proof-of-concept demonstrating multimodal information extraction with schema validation.
It is not intended for safety-critical engineering workflows without additional verification mechanisms.