Applied ML · Research software
Making attention-based cytology research inspectable
PapLens runs cervical-cytology deep learning models developed through our thesis and research team’s work. The application lets people inspect the resulting attention maps in the original field. I built the inference service, web application, and deployment.
- Role
- Inference service, web application & deployment (solo)
- Model
- ResNet-50 · gated-attention MIL
- Status
- Research prototype
Product walkthrough
PapLens in use
Follow the research workflow from choosing an image and model to reviewing inference results and attention maps. Choose a screen to explore at your own pace.
Research prototype. Not for clinical or diagnostic use.

Research workspace
Start by uploading a microscopy field or choosing one of the reference examples in the research workspace.
01 / Product
From a model pipeline to a usable research workflow
Our thesis and research team developed deep learning models for cervical cytology using attention-based multiple instance learning. PapLens packages those models in an application where a researcher can select a task, submit a field of view, receive the model output, and inspect the regions associated with the attention weights.
The project covers more than a prediction endpoint: it joins image handling, model serving, evidence rendering, deployment, and clear communication about what a research prototype can and cannot say.
Two research workflows
- Binary triage and three-tier severity grading
- Model selection before running an analysis
- Class probabilities returned with each result
Evidence inspection
- Original field and spatial-attention overlay views
- Opacity control and side-by-side comparison
- Ranked high-attention patches for closer inspection
Research workspace
- Upload a microscopy field or load a reference example
- Image validation and backend status feedback
- Clear separation between model output and its interpretation
02 / Problem and constraints
The research pipeline needed an inspectable delivery path
A notebook or training script is useful for experimentation, but it does not give another researcher a straightforward way to submit an image and inspect model behavior. The deployment challenge was to connect the existing patch-based model pipeline to a usable interface without hiding the intermediate spatial evidence.
Inputs are large microscopy fields, while the model consumes smaller patches. Inference also depends on Python image-processing and deep learning libraries, and the available deployment target is CPU infrastructure. The application therefore needed an explicit frontend/backend boundary, predictable image processing, and operational feedback when the inference service was unavailable.
03 / Inference pipeline
Keep patch coordinates connected to model evidence
PapLens runs our thesis deep learning models on high-resolution Pap-smear field-of-view images. Overlapping patches are prepared and encoded individually; gated attention aggregates their features for a field-level prediction. The corresponding weights are then projected back to image coordinates for inspection.
01
Tile and filter
A high-resolution field is split into overlapping 1280 × 1280 patches. Background-heavy patches are filtered before inference.
02
Encode and attend
A ResNet-50 encoder produces patch features; gated attention aggregates them into a field-level representation for classification.
03
Return inspectable output
The API returns class probabilities and patch attention. The interface maps those weights to the original field as a spatial overlay.
The deep learning models are associated with PapSmear Dataset, a dataset of 2,253 expert-annotated conventional Pap-smear field-of-view images. The application does not distribute that dataset.
04 / Engineering decisions
Separate responsibilities and retain the evidence trail
These decisions shape how our research team’s deep learning models are served and how its outputs are presented to a user.
- 01
Keep the image analysis in a dedicated inference service
The browser application uses a Next.js interface, while FastAPI owns image decoding, patch preparation, model execution, and heatmap generation.
The deep learning pipeline is Python and PyTorch based. A separate service keeps the model runtime and image-processing dependencies out of the frontend deployment, with a clear HTTP boundary between interaction and inference.
Trade-off: The browser must communicate directly with a separately deployed API, so health checks, CORS configuration, request validation, and backend status become part of the product experience.
- 02
Preserve field detail through patch-based inference
Rather than resizing the entire microscopy field to the encoder input, the pipeline extracts 1280 × 1280 patches with overlapping windows, filters background-heavy patches, and resizes each retained patch for ResNet-50.
This keeps local cellular texture available to the feature extractor while still making a large field processable as a collection of model inputs.
Trade-off: The pipeline has more moving parts than a single-image classifier: patch selection, coordinates, and attention weights must stay aligned through inference and visualization.
- 03
Make attention part of the model response
The gated-attention deep learning MIL model returns patch-level weights alongside the field-level classification. The backend projects those weights back to patch coordinates and prepares an overlay for the UI.
Researchers can compare the model output with the regions receiving attention instead of seeing only a class label and probability.
Trade-off: An attention map shows how the model distributed attention; it does not identify a lesion, prove correctness, or explain a clinical decision.
- 04
Fit deployment to CPU-first infrastructure
The inference service is containerized with CPU PyTorch and deployed on a self-hosted K3s cluster through Flux CD. Cloudflare Tunnel provides external access without opening inbound ports on the host.
This made it possible to run the research team’s deep learning models on available infrastructure without depending on a GPU host. The deployment and model-weight retrieval are kept separate from the source repository.
Trade-off: CPU inference is slower than a suitable GPU deployment, and the system depends on the health of the cluster, tunnel, model-weight source, and configured backend endpoint.
05 / System and delivery
A decoupled client, inference API, and model runtime
The Next.js client communicates with a FastAPI service that loads the PyTorch deep learning models and performs image inference. The backend is containerized for CPU execution. The documented deployment uses a K3s cluster, Flux CD for GitOps reconciliation, and Cloudflare Tunnel for external HTTPS access; the frontend is deployed separately.
Model checkpoints are retrieved at runtime from Hugging Face Hub instead of being committed to the application source. The client checks backend health and includes a configured alternate endpoint path, so service selection and recovery behavior remain visible parts of the system design.
SYSTEM BOUNDARY
Browser / Next.js → FastAPI → patch extraction → ResNet-50 + gated attention → probabilities + spatial evidence
The repository documents client-side health probing and retry against an alternate backend. That mechanism describes intended failure handling; it should not be read as a measured uptime or availability guarantee.
06 / Outcome and verification
Research deep learning models accessible through an application
PapLens provides two model workflows through a deployed web application, with an API that returns class probabilities and spatial attention data for the interface. The source repository includes backend and frontend test suites, deployment manifests, health endpoints, and operational documentation.
About 4 s average inference for a standard input image. Self-hosted on K3s with GitOps deployment through Flux CD.
The PapSmear Dataset contains 2,253 expert-annotated images from 300+ source slides. Dataset size and inference time do not establish diagnostic accuracy; this application makes no clinical-performance claim.
07 / Limitations and next work
Make evaluation and operations more reproducible
PapLens is an application for running our research team’s cervical-cytology deep learning models. Attention maps can help a researcher inspect model focus, but they do not prove that a prediction is correct or identify a clinically meaningful region. CPU inference also limits throughput, and model behavior may change with stain, illumination, preparation, or acquisition differences.
The next engineering steps are to document a reproducible latency setup, publish evaluation results with cohort definitions and split details, and verify the live fallback behavior against the deployed configuration. Any future evaluation should also make data-leakage controls and class-wise results explicit.


