gdm-train-inspection

Automates cargo-train inspection reports with photo extraction, OCR, and theft-detection models.

Updated May 28, 2026
One-click install
npx skills add https://github.com/patty-chow/the-stable --skill gdm-train-inspection-patty-chow
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: gdm-train-inspection
Source: https://github.com/patty-chow/the-stable/tree/main/skills/productivity/gdm-train-inspection
Command: npx skills add https://github.com/patty-chow/the-stable --skill gdm-train-inspection-patty-chow

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires pymupdf, openpyxl, pytesseract, torch, fastapi, uvicorn, fpdf2, openai-whisper, and includes references (resource) components.

What problem does it solve? GDM cargo-train inspections for DeAcero arrive as Gmail emails with Excel label sheets and multi-page PDF photo evidence, and manually renaming photos, reading car IDs, and judging tampering (MANIPULADA) across thousands of cars is slow and error-prone. This Skill provides the tooling and hard-won domain knowledge to automate that pipeline end to end. ## Core Features & Use Cases - Attachment extraction and parsing: Pull PDF/Excel attachments from Gmail via the REST API, extract per-car cargo photos with PyMuPDF, and join them to ESTATUS labels by normalized PLACA. - Two-regime theft detection: Route photos by covered vs uncovered regime and apply per-regime ResNet models (uncovered ~96% recall, covered as a recall-first flagging aid), selected by Average Precision. - Hybrid PLACA OCR: Tesseract-first with a vision-LLM fallback and double-read consistency check, reaching 92% match with 0% wrong-car error. - Report generation and human review: A FastAPI reviewer app that drafts Spanish Excel/PDF reports matching GDM's exact templates, with human approval before emailing. - Use Case: Given a new inspection email, extract the cargo photos, score each car for tampering, surface upstream checkpoint history, and produce a reviewer-approved Excel and PDF report for the client. ## Quick Start Ask the agent to pull the latest GDM inspection report from Gmail, extract the cargo photos, and run the theft-detection models to draft a review-ready report.

Frequently Asked Questions about gdm-train-inspection

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I extract PDF and Excel attachments from Gmail in Python?▼

Use the Gmail REST API directly: fetch the message with format=full, walk the MIME tree for parts with a filename or attachmentId, then download each attachment and base64url-decode the body. The google-workspace CLI does not expose attachments, so this REST pattern is required.

How do I detect cargo theft from train inspection photos?▼

Split cars into covered and uncovered regimes and apply a per-regime ResNet model, since the signal differs: covered cars carry it in comments, uncovered cars require judging moved wooden bracing visually. Select models by Average Precision and tune the threshold for recall-first flagging with human review.

Why does Tesseract OCR fail on photo overlay text?▼

Tesseract caps around 62-67% match on stylized low-contrast overlay text and returns garbage it cannot post-process. The fix is a hybrid: Tesseract-first with batch-list matching, then a small vision-LLM fallback with a double-read consistency check, reaching 92% match with 0% wrong-car error.

Can I join PDF photos to Excel labels by car ID?▼

Yes, but normalize the PLACA by stripping all whitespace first, since the PDF writes IDs with spaces and Excel without. That single fix raised the join match rate from 69% to 97%, and the join must be per-report, never a global per-car verdict.

What are the limitations of a single blended theft classifier?▼

A blended model fails because the two regimes differ fundamentally: uncovered cars are ~96% recall visually, while covered cars top out near 78-86% recall with far higher variance. Covered-car output must remain a recall-first flagging aid with mandatory human review, not an autopilot.