MedGemma on Modal: three labeled images, two adversarial inputs, and a bias
MedGemma 4B IT is now boringai's primary image model. We ran it on three labeled open-dataset images (pneumonia CXR, normal CXR, actinic keratosis) and two adversarial inputs. Summarised outputs, ground-truth comparison, the systematic bias we found, and the bug we caught writing the post.

This is a test on three images (N=3), not a clinical validation. The model outputs below are not medical advice and must not be used to diagnose any patient or condition. Anyone with a health concern should see a clinician.
MedGemma 4B IT is now boringai's primary image model. It was run against three labeled open-dataset images and two adversarial inputs. On the pneumonia film it reported a lung opacity with pneumonia first in the differential. On the normal chest film it reported clear lung fields and no consolidation. On the dermatology lesion it declined to name a diagnosis without biopsy. The server-side guards rejected both adversarial inputs. The model also overcalled heart size on both chest films. The prompts are quoted verbatim. The outputs are summarised and reformatted from the raw responses, with the model's own words in quotation marks, and each is compared with the dataset label.
Transcript
Not for diagnosis or medical advice: this is a test on three images, not a clinical validation. MedGemma 4B IT, Google's medically specialized multimodal model, is now boringai's primary image model. It was run on three labeled open-dataset images and two adversarial inputs.
Each image has a dataset label the model never sees. On the pneumonia chest X-ray, it reported a right lung opacity, with pneumonia first in its differential, the list of possible causes. That matches the label. On the normal film, it described clear lung fields: also a match. On the skin lesion, labeled actinic keratosis, it described the features the prompt asked for, and declined to name a diagnosis without a biopsy.
One error repeated: it flagged an enlarged heart on both chest films, including the normal one. These are pediatric films, where the heart normally looks relatively large, so that is an overcall. Two films are too few to establish a bias.
Two adversarial inputs, a 1 by 1 pixel image and a blank 64 by 64 one, were both rejected by server-side guards. Writing the post exposed a bug: the rejections had reached the caller as "Modal GPU service is unavailable". Now the real reason gets through.
Three images do not establish clinical accuracy, and nothing here is medical advice. The full write-up is at boracode.ai.
Method
A medical vision-language model can only be scored against ground truth, so the test uses three images from open datasets that ship with labels:
Label:
PNEUMONIALabel:
NORMALLabel:
Actinic keratosesCases 1 and 2 used a neutral prompt with no few-shot examples and no "you are an expert radiologist" priming: "Describe the imaging modality, anatomical structures visible, and any abnormalities." The model never sees the dataset label.
Case 3 used a different prompt: "Describe the lesion: type, color, border, asymmetry, and any concerning features." That prompt names the ABCD features (asymmetry, border, color) and asks for concerning ones, so it is leading. The structure of the case 3 output follows the prompt and does not show the model choosing those features on its own.
The pipeline
Each image call can escalate through three models on Modal GPU. The first stage that produces output passing the guards is used.
MedGemma 4B IT is Google's medically specialized multimodal model (4.3B params, bf16). LLaVA-1.5-7B is the non-gated general fallback. BLIP plus a clinical LLM is the last resort, which captions the image and then interprets the caption. Three server-side guards (size ≥ 16×16, std-dev ≥ 3.0, no trigram repetition) reject inputs that cause degenerate output on any of the models.
Case 1: Pneumonia chest X-ray
PROMPT: "Describe the imaging modality, anatomical structures visible, and any abnormalities." · 13 cr · 12,753 tokens · cold-start 97s
Ground truth label: PNEUMONIA. Output, summarised and reformatted from the raw response:
Imaging Modality:
X-ray — standard chest X-ray (radiography).
Anatomical Structures Visible:
Ribs, Lungs (air-filled, dark), Heart, Mediastinum (heart +
aorta + vena cava + trachea + esophagus), Clavicles,
Scapulae, Diaphragm.
Abnormalities:
• Right Lung Opacity — increased density in the right lung
field. Differential:
→ Pneumonia: infection of the lung tissue. ← MATCH
→ Pleural Effusion: fluid in the pleural space.
→ Consolidation: solidification of lung tissue.
→ Tumor: growth in the lung tissue.
→ Atelectasis: collapse of lung tissue.
• Cardiomegaly — heart appears enlarged. Differential:
→ Hypertension, Cardiomyopathy, Valvular disease, CHF.
• Mediastinal Shift — space between the lungs shifted right.Verdict: matches the label. The dataset label is PNEUMONIA. MedGemma flagged a right lung opacity and listed pneumonia as the first item in the differential. The remaining four entries are standard causes of lung opacity on a chest film, and no finding looks fabricated.
Limitation: the output also flags cardiomegaly (enlarged heart). On a pediatric chest X-ray the heart normally looks relatively large because the thorax has not finished growing, so this is an overcall. Case 2 shows the same pattern on a normal film.
Case 2: Normal chest X-ray
PROMPT: same as Case 1 · 16 cr · 15,153 tokens
Ground truth label: NORMAL. This is the harder test, because the model has to avoid inventing findings on a normal image, which many vision-language models fail to do. Output, summarised and reformatted from the raw response:
Anatomical Structures Visible:
Ribs, Lungs, Heart, Mediastinum, Clavicles, Scapulae, Diaphragm.
Abnormalities:
• Heart Size: slightly enlarged (cardiomegaly). The model
notes this is "common in infants and young children, as
their hearts are still growing."
• Lung Fields: relatively clear, with no obvious signs of
consolidation (fluid or infection) or other significant
abnormalities. ← MATCH
Important Considerations:
Age: infant. Clinical context required. Further evaluation
by a medical professional if concerns.
Disclaimer: AI cannot provide medical diagnoses.Verdict: matches the label, with the same systematic error. The lung fields are described as clear with no consolidation, which is the call that matters against the NORMAL label. Cardiomegaly is flagged again, this time with the note that it is common in infants (the keremberke dataset is pediatric). Heart size was overcalled on both chest films, which points to a consistent bias, although two films are too few to establish one.
Case 3: Actinic keratosis (dermatology)
PROMPT: "Describe the lesion: type, color, border, asymmetry, and any concerning features." · 9 cr · 8,856 tokens
Ground truth label: Actinic keratoses — a precancerous lesion caused by sun damage. Clinical diagnosis requires dermoscopy and often biopsy. Output, summarised and reformatted from the raw response:
Type: skin lesion, irregular and atypical. "Difficult to definitively classify without a clinical examination and potentially a biopsy." Color: multitude of colors — brown, tan, possibly red or pink. "This variation in color is a concerning feature." Border: irregular and poorly defined. Not smooth. Asymmetry: asymmetrical — one half doesn't mirror the other. Concerning Features: • Multiple colors (red flag) • Irregular border (suggests growth or change) • Asymmetry (key indicator of potential malignancy) Disclaimer: refers to dermatologist for definitive diagnosis.
Verdict: appropriately cautious. The model did not name "actinic keratosis", which is correct behavior because that diagnosis requires dermoscopy and biopsy. It described asymmetry, border irregularity and color variation, which the prompt asked for by name, and deferred the diagnosis. For a clinical decision-support tool, flagging features and deferring is the intended behavior.
A model that answered "this is actinic keratosis" would have matched the label on this image, but a photo alone does not support that call in clinical practice. boringai is decision support, not autonomous diagnosis.
Adversarial cases and the guards
The three server-side guards reject inputs that cause degenerate output. Two adversarial inputs were run live against them:
model=modal/guard
message="Image too small (1x1px); minimum 16x16."
cost=1 cr
model=modal/guard
message="Image appears blank (std-dev 0.0)."
cost=1 cr
Before the fix, both inputs returned "Modal GPU service is unavailable" because the tool layer treated the guard's error response as a service outage and discarded the real reason. The bug surfaced while this post was being written. The guard's rejection message now reaches the caller with reviewer_gated.status = "rejected".
The third guard (trigram repetition) targets the original failure, the looping output seen earlier on BLIP. When a 3-word window appears 3+ times in a stage's output, the output is flagged and the caller escalates to the next stage or to caption-then-interpret. None of the three real cases triggered it.
Limitations
The sample is three images and is not a clinical validation study. Three observations:
- Systematic cardiomegaly overcall on pediatric chest X-rays. Both chest films were flagged for an enlarged heart, including the normal one. MedGemma noted that this is common in infants, so the flag adds noise on a pediatric dataset.
- Dermatology output is flag-only. The model declined to name actinic keratosis on a labeled actinic-keratosis image. That is correct clinically, since a biopsy is needed, but it limits the tool to "is this concerning?" flagging and rules it out for dermatology triage.
- Cost varies 1.8× across cases that look similar. The normal CXR cost 16 cr (15,153 tokens) and the dermatology image cost 9 cr (8,856 tokens). The model generated more text on the chest film, and per-token billing means cost follows output length rather than input complexity.
Cost economics
Charged in these runs: 9–16 cr per image.
L4 GPU, cold-start 90+ seconds.
As an example, a clinic running 100 PII strips a day (2 cr each, no cache) burns 200 cr. Add 20 chest X-ray analyses a day at ~15 cr each: another 300 cr. A 10,000-cr top-up lasts about three weeks at that volume.
Correction (2026-10-10): the charges recorded for the three cases (13, 16 and 9 cr) equal the token count divided by 1,000, rounded up (12,753, 15,153 and 8,856 tokens). They do not include the 10 cr base on the price card, which would give 23, 26 and 19 cr. The measured charges are left as recorded; at card price the 20 analyses in the example would cost about 500 cr a day instead of 300. Also corrected 2026-10-10: the title called this medical-grade image analysis, and two verdicts read "correct"; three images do not establish clinical accuracy, so the title was changed, the verdicts now say the output matches the dataset label, and a not-for-diagnosis note was added at the top.
Reproducing the results
The samples ship with the app at /samples/chest-xray.jpg, /samples/chest-xray-normal.jpg, and /samples/dermatology.jpg. They can be run directly:
# Pneumonia chest X-ray
curl -X POST https://boracode.ai/api/tools/image_analyze \
-H "Authorization: Bearer bai_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"image_base64":"...","prompt":"Describe the imaging modality, anatomical structures visible, and any abnormalities."}'
# Or just open the playground and click "Pneumonia CXR":
# https://boracode.ai/playground → image_analyzeThe two adversarial inputs are simple to recreate: the 1×1 transparent PNG and the blank 64×64 are both <100 bytes and can be made in any image editor.
