StanfordAIMI / chexpert-plus-srrg_impression

huggingface.co
Total runs: 85
24-hour runs: 0
7-day runs: 29
30-day runs: 74
Model's Last Updated: May 27 2025
image-to-text

Introduction of chexpert-plus-srrg_impression

Model Details of chexpert-plus-srrg_impression

Requirements:

pip install transformers
pip install torch

Adapted sample script for SRRG

import torch
from PIL import Image
from transformers import BertTokenizer, ViTImageProcessor, VisionEncoderDecoderModel, GenerationConfig
import requests
import re

model_name  = "StanfordAIMI/chexpert-plus-srrg_impression"
model = VisionEncoderDecoderModel.from_pretrained(model_name).eval()
tokenizer = BertTokenizer.from_pretrained(model_name)
image_processor = ViTImageProcessor.from_pretrained(model_name)
generation_args = {
   "bos_token_id": model.config.bos_token_id,
   "eos_token_id": model.config.eos_token_id,
   "pad_token_id": model.config.pad_token_id,
   "num_return_sequences": 1,
   "max_length": 128,
   "use_cache": True,
   "beam_width": 2,
}

# Inference
with torch.no_grad():
   url = "https://huggingface.co/IAMJB/interpret-cxr-impression-baseline/resolve/main/effusions-bibasal.jpg"
   image = Image.open(requests.get(url, stream=True).raw)
   pixel_values = image_processor(image, return_tensors="pt").pixel_values
   # Generate predictions
   generated_ids = model.generate(
       pixel_values,
       generation_config=GenerationConfig(
           **{**generation_args, "decoder_start_token_id": tokenizer.cls_token_id})
   )
   generated_texts = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)

impression = generated_texts[0]
print("Output raw impression:\n", impression)

# format impression
def process_impression_line(line):
    """
    Process one report line.

    - First, deduce from the first valid impression header the expected style:
      e.g. "1." vs. "1 ."
    - Then, only when a candidate match’s number equals the expected impression number,
      treat it as an impression header. For the first valid header, leave it unchanged.
      For subsequent valid headers, insert a newline before it.
    - Any candidate that does not match the expected number is assumed not to be an impression header.
    """
    impression_pattern = re.compile(r'(\d+)(\s*\.)(?!\d)')
    expected_impression = 1
    first_valid = True
    deduced_style = None

    def replacement(match):
        nonlocal expected_impression, first_valid, deduced_style
        candidate_num = int(match.group(1))
        candidate_style = match.group(2)  # may be " ." or "."

        # Only consider a candidate a valid impression header if it equals the expected number.
        if candidate_num == expected_impression:
            if first_valid:
                # This is our first valid impression header.
                first_valid = False
                deduced_style = candidate_style  # record style (with or without whitespace)
                expected_impression += 1
                return match.group(0)  # leave unchanged (i.e. no preceding newline)
            else:
                # For subsequent valid headers, we require the style to be the same as deduced.
                if candidate_style == deduced_style:
                    expected_impression += 1
                    return "\n" + match.group(0)
                else:
                    # If the style does not match the deduced style, leave it unchanged.
                    return match.group(0)
        else:
            # This candidate does not match the expected number; likely it's not a header.
            return match.group(0)

    processed = impression_pattern.sub(replacement, line)
    return processed


impression = impression.strip()
impression = process_impression_line(impression)
print("Formatted impression:\n", impression)

Output

Output raw impression:
 1. moderate bilateral pleural effusions with associated bibasilar opacities, which may represent atelectasis or consolidation. 2. mild pulmonary edema.

Formatted impression:
1. moderate bilateral pleural effusions with associated bibasilar opacities, which may represent atelectasis or consolidation. 
2. mild pulmonary edema.

Runs of StanfordAIMI chexpert-plus-srrg_impression on huggingface.co

85
Total runs
0
24-hour runs
11
3-day runs
29
7-day runs
74
30-day runs

More Information About chexpert-plus-srrg_impression huggingface.co Model

More chexpert-plus-srrg_impression license Visit here:

https://choosealicense.com/licenses/mit

chexpert-plus-srrg_impression huggingface.co

chexpert-plus-srrg_impression huggingface.co is an AI model on huggingface.co that provides chexpert-plus-srrg_impression's model effect (), which can be used instantly with this StanfordAIMI chexpert-plus-srrg_impression model. huggingface.co supports a free trial of the chexpert-plus-srrg_impression model, and also provides paid use of the chexpert-plus-srrg_impression. Support call chexpert-plus-srrg_impression model through api, including Node.js, Python, http.

chexpert-plus-srrg_impression huggingface.co Url

https://huggingface.co/StanfordAIMI/chexpert-plus-srrg_impression

StanfordAIMI chexpert-plus-srrg_impression online free

chexpert-plus-srrg_impression huggingface.co is an online trial and call api platform, which integrates chexpert-plus-srrg_impression's modeling effects, including api services, and provides a free online trial of chexpert-plus-srrg_impression, you can try chexpert-plus-srrg_impression online for free by clicking the link below.

StanfordAIMI chexpert-plus-srrg_impression online free url in huggingface.co:

https://huggingface.co/StanfordAIMI/chexpert-plus-srrg_impression

chexpert-plus-srrg_impression install

chexpert-plus-srrg_impression is an open source model from GitHub that offers a free installation service, and any user can find chexpert-plus-srrg_impression on GitHub to install. At the same time, huggingface.co provides the effect of chexpert-plus-srrg_impression install, users can directly use chexpert-plus-srrg_impression installed effect in huggingface.co for debugging and trial. It also supports api for free installation.

chexpert-plus-srrg_impression install url in huggingface.co:

https://huggingface.co/StanfordAIMI/chexpert-plus-srrg_impression

Url of chexpert-plus-srrg_impression

chexpert-plus-srrg_impression huggingface.co Url

Provider of chexpert-plus-srrg_impression huggingface.co

StanfordAIMI
ORGANIZATIONS

Other API from StanfordAIMI

huggingface.co

Total runs: 4.2K
Run Growth: 2.2K
Growth Rate: 51.81%
Updated:April 02 2026
huggingface.co

Total runs: 1.6K
Run Growth: 345
Growth Rate: 20.92%
Updated:November 19 2022