A candidate-filtered verification pipeline for print and online advertising evidence.
English · 한국어
Project · Tech Stack · Architecture · Pipelines · Technical Decisions · Outcome
Client project. Under the project agreement, client materials and source code cannot be made public.
| Category | Details |
|---|---|
| Period | April – July 2025 |
| Project type | Client project |
| Role | Full-stack developer |
| Responsibilities | Print and online validation pipelines, performance optimization, backend APIs, task-status UI, and result generation |
| Validation scope | Print publications and online media |
| Area | Technologies |
|---|---|
| Backend | Python, FastAPI |
| AI and matching | OpenAI GPT-4o, Tesseract OCR, ImageHash/pHash |
| Automation and data | Selenium, Pillow, pandas, OpenPyXL, pdf2image, ReportLab |
| Frontend | TypeScript, Next.js, React, Tailwind CSS |
| Deployment | AWS EC2 |
| Phase | Approach | Finding |
|---|---|---|
| Existing workflow | Users compared evidence with print pages and online placements manually. | The work was repetitive and difficult to scale. |
| Initial prototype | Collected images were compared directly with GPT-4o Vision. | About 100 items took roughly 150 minutes in internal testing. |
| Final redesign | Candidate filtering narrows the search before Vision confirms the reduced set. | The same test workload fell to roughly 40 minutes. |
I designed candidate filtering around the characteristics of each medium. Print advertisements contain substantial text, so OCR and text similarity select a likely page. Online outlets commonly publish a resized or recompressed version of the original creative, so pHash retrieves visually similar candidates before GPT-4o confirms the match.
- Redesigned the Vision-only prototype to filter candidates before Vision confirmation.
- Built separate print and online validation paths behind FastAPI services.
- Added a Next.js interface for uploads, progress polling, result review, and downloads.
- Identified the outlet from each evidence filename, then mapped it to a print API media code or publisher URL.
- Scheduled print-page collection for 06:00 each day and collected dynamic online images with headless Selenium.
- Combined OCR, text similarity, perceptual hashing, and GPT-4o Vision according to each medium.
- Generated formatted Excel results, matched print pages as individual PDFs, ZIP downloads, and screenshots of validated online placements.
%%{init: {"themeVariables": {"fontSize": "18px"}, "flowchart": {"curve": "linear", "nodeSpacing": 40, "rankSpacing": 50}}}%%
flowchart TB
User["User"]:::person
subgraph Browser["Browser"]
WebApp["Web UI<br/>Next.js + React<br/>Uploads evidence<br/>Shows progress and results"]:::app
end
subgraph EC2["AWS EC2"]
direction TB
PrintAPI["Print validation API<br/>FastAPI + Tesseract<br/>Scheduled page collection<br/>OCR filtering · Vision confirmation"]:::app
OnlineAPI["Online validation API<br/>FastAPI + Selenium<br/>Image crawling<br/>pHash filtering · Vision confirmation"]:::app
Files[("File workspace<br/>Uploads · page, OCR, and pHash caches<br/>Crawled images · reports")]:::store
PrintAPI <-->|"Files"| Files
OnlineAPI <-->|"Files"| Files
end
subgraph External["External services"]
direction TB
PageAPI["Print page API<br/>Daily newspaper pages"]:::external
GPT["OpenAI GPT-4o<br/>Media-name extraction<br/>Visual confirmation"]:::external
Publishers["Publisher websites<br/>Pages and image assets"]:::external
PageAPI ~~~ GPT
GPT ~~~ Publishers
end
User -->|"Uses"| WebApp
WebApp <-->|"Print jobs"| PrintAPI
WebApp <-->|"Online jobs"| OnlineAPI
Files ~~~ PageAPI
PrintAPI -->|"Scheduled pages"| PageAPI
PrintAPI -->|"OCR candidate"| GPT
OnlineAPI -->|"pHash candidates"| GPT
OnlineAPI -->|"Image crawl"| Publishers
classDef person fill:#FFFFFF,stroke:#475569,color:#0F172A,stroke-width:2px;
classDef app fill:#EFF6FF,stroke:#2563EB,color:#1E3A8A,stroke-width:2px;
classDef store fill:#ECFDF5,stroke:#059669,color:#065F46,stroke-width:2px;
classDef external fill:#F3F4F6,stroke:#6B7280,color:#374151,stroke-width:2px;
style Browser fill:#F8FAFC,stroke:#94A3B8,stroke-width:1px,color:#334155
style EC2 fill:#F8FAFC,stroke:#64748B,stroke-width:2px,color:#334155
style External fill:#FAFAFA,stroke:#9CA3AF,stroke-width:1px,color:#374151
The Next.js UI is served from EC2 and runs in the browser. It calls the print and online FastAPI services directly; the services run as separate processes and share a local file workspace. Job state stays in each process, with no separate queue or database.
%%{init: {"themeVariables": {"fontSize": "18px"}, "flowchart": {"curve": "linear", "nodeSpacing": 25, "rankSpacing": 35}}}%%
flowchart LR
A["Evidence ZIP<br/>+ mapping Excel"] --> B["Media identification<br/>Outlet → print API code"]
B --> C["Scheduled 06:00 pages<br/>Reuse or fetch missing"]
C --> D["Candidate filtering<br/>OCR + text similarity"]:::candidate
D --> E["Vision confirmation<br/>GPT-4o layout check"]:::vision
E --> F["Excel + matched<br/>PDF ZIP"]
classDef candidate fill:#FFF7ED,stroke:#F97316,color:#7C2D12,stroke-width:2px;
classDef vision fill:#F5F3FF,stroke:#7C3AED,color:#4C1D95,stroke-width:2px;
Media identification restricts the search to the relevant publication. OCR uses the text-heavy nature of newspaper advertisements to select one likely page, then only that pair is sent to GPT-4o for layout confirmation.
%%{init: {"themeVariables": {"fontSize": "18px"}, "flowchart": {"curve": "linear", "nodeSpacing": 25, "rankSpacing": 35}}}%%
flowchart LR
A["Evidence ZIP<br/>+ publisher URL Excel"] --> B["Media identification<br/>Outlet → publisher URL"]
B --> C["Selenium crawl<br/>Deduplicate · remove tiny images"]
C --> D["Candidate filtering<br/>pHash distance ≤ 10 · top 3"]:::candidate
D --> E["Vision confirmation<br/>GPT-4o score ≥ 0.95"]:::vision
E --> F["Excel + placement<br/>screenshots"]
classDef candidate fill:#FFF7ED,stroke:#F97316,color:#7C2D12,stroke-width:2px;
classDef vision fill:#F5F3FF,stroke:#7C3AED,color:#4C1D95,stroke-width:2px;
The crawler collects dynamic image sources, lazy-loaded images, background images, and Open Graph images. Images smaller than 10,000 pixels in area are removed before comparison. A 64-bit pHash Hamming-distance cutoff of ≤ 10 ranks candidates and keeps up to the three closest hits. If none pass, the pipeline falls back to the mapped publisher's collected image set. GPT-4o then compares candidates in batches of three and accepts a match when its returned score is ≥ 0.95.
Both paths begin with media identification. The evidence filename is mapped to one print API media code or one publisher URL, preventing an all-to-all comparison across unrelated outlets.
| # | Decision | Reason |
|---|---|---|
| 1 | Scheduled source collection | Collect pages at 06:00 so the request can reuse the daily page set and fetch only missing data. |
| 2 | OCR candidate filtering | Newspaper advertisements are text-heavy, so text similarity can select one likely page before the expensive image check. |
| 3 | OCR cache and concurrency | Cache OCR text with a filename and normalized-pixel hash, then use three OCR workers with early cancellation to limit repeated work and CPU contention. |
| 4 | Vision confirmation | Send only the selected evidence/page pair to GPT-4o to confirm the page layout. |
| # | Decision | Reason |
|---|---|---|
| 1 | Targeted source collection | Crawl only the mapped publisher and remove duplicate, invalid, and very small images before matching. |
| 2 | pHash candidate filtering | pHash tolerates resizing and recompression. A 64-bit Hamming-distance cutoff of ≤ 10 ranks candidates, and at most three hits continue. |
| 3 | pHash cache and fallback | Reuse computed pHash values; if no image passes the cutoff, use the mapped publisher's collected set rather than creating an immediate false negative. |
| 4 | Vision confirmation | Resize inputs to at most 512×512, encode them as JPEG quality 70, and accept a match when GPT-4o's returned score is ≥ 0.95. |
- Delivered one workflow for collecting source material, validating print and online placements, tracking progress, and exporting review results.
- Reduced repeated downloads, OCR work, and unnecessary Vision comparisons through mapping, reuse, caching, candidate retrieval, and bounded concurrency.
| Internal project measure | Approximate result |
|---|---|
| Processing time for about 100 items | About 150 minutes → 40 minutes, approximately 73% shorter |
| Image-validation accuracy | Approximately 98% |
Performance figures are approximate results from internal client testing. The source dataset and measurement artifacts cannot be published.