Skip to Main Content

MedMamba is an autonomous medical-image diagnostic system: drop in any image and the model decides for itself which of four imaging modalities it is (histopathology, dermoscopy, blood-cell microscopy, or retinal OCT), runs the matching diagnostic head, generates an SSM-GradCAM saliency map, and asks Claude Opus 4.7 to produce a clinician-style explanation of what it's looking at — with no human ever specifying the modality. The problem: standard multi-task medical classifiers fail on an unspoken assumption — a human must tell the model what kind of image it is at inference. That makes them useless for any real triage scenario where the modality is the question itself. The architectural contribution: a Supervised-Contrastive auxiliary objective trained alongside the multi-task heads forces the VMamba backbone to learn modality-separating geometry. After training, per-modality prototypes are stored inside the model. At inference, an unknown image self-routes via 1-NN cosine similarity in feature space, then the matching head fires. Two objectives (fine-grained class CE + coarse-grained domain SupCon) operate at orthogonal scales, so satisfying both costs essentially no per-task accuracy. Trained results across 4 MedMNIST+ datasets: avg F1 = 0.90 (PathMNIST 0.99, BloodMNIST 0.99, OCTMNIST 0.92, DermaMNIST 0.70 — class-imbalance bound), 93/93 tests passing. The Opus 4.7 contribution: the autonomous prediction (modality + class + confidence + top-k) and the GradCAM heatmap are sent to Opus 4.7 alongside the original image. Opus 4.7 returns a structured JSON explanation — focus_region, finding, differential, confidence_note, follow_up — using the right vocabulary per modality (histopathology, dermoscopic, cytomorphological, or retinal-OCT terms). Because Opus 4.7 sees both the image AND the heatmap, it surfaces a known failure mode pure-softmax can't: high model confidence + diffuse heatmap = flag for manual review. Provenance: every line was written collaboratively with Claude Code. The SupCon contrastive feature itself was planned, implemented, tested, and verified by a single Opus 4.7 Claude Code agent session — 7 files changed, 17 new tests added, 93 tests green on first run.

Team

Afify

More from Built with Opus 4.7: a Claude Code hackathon

Medkit is a virtual clinic that lets you make every mistake before the real patients come. It's a voice-first AI simulator for medical students and newly…

Keskin project preview

Every year, 50 million tons of electronics become waste — not because they can't be repaired, but because board-level expertise is locked in a few hands…

Alexis Chapellier project preview

Maieutic flips the role an LLM usually plays in learning to program. Instead of handing the student working code, it guides them to think first about what the…

Maieutic project preview

OmniBridge is an AI agent that identifies unknown serial device protocols autonomously — a workflow that didn't exist a year ago because it needs Opus 4.7's…

OmniBridge project preview

ARIA captures the floor operator's knowledge and puts it to work. Drop in the manufacturer's PDF, answer some calibration questions, and you're live in ten…

TrayStones project preview

Interior architects in France designing offices for banks, law firms and consulting groups are leaving money on the table. Each one handles only one or two…

Saad EL BABIDI project preview