Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run inference with non-svs files #7

Open
OliS1311 opened this issue Jan 19, 2025 · 2 comments
Open

Run inference with non-svs files #7

OliS1311 opened this issue Jan 19, 2025 · 2 comments

Comments

@OliS1311
Copy link

Hi,

Thanks for sharing your new model. I am interested in using CellViT with ndpi files. I am able to run the inference script with the example svs file but not for my dataset which is in ndpi format:

ValueError: Cannot find a plugin to handle 'my_filename.ndpi'!

I'm just trying to run this with one slide at present. I can see there's an option for setting slide extension in process_dataset:

--wsi_extension WSI_EXTENSION
                        The extension types used for the WSI files, see configs.python.config (WSI_EXT)

I've tried setting this to ndpi and pointing the inference script to a directory containing a single ndpi slide but I'm getting the same message. It is able to load the model and detects the slide resolution:

2025-01-19 12:02:48,764 [INFO] - Loading model: checkpoints/CellViT-SAM-H-x40-AMP.pth
2025-01-19 12:03:10,256 [INFO] - <All keys matched successfully>
2025-01-19 12:03:11,151 [INFO] - Based on the hardware we limit the batch size to a maximum of:
2025-01-19 12:03:11,151 [INFO] - 4
2025-01-19 12:03:11,151 [INFO] - Apply limits - Batch size: 4
2025-01-19 12:03:11,151 [INFO] - Loading inference transformations
2025-01-19 12:03:15,395 INFO worker.py:1724 -- Started a local Ray instance.
2025-01-19 12:03:41,227 [INFO] - Using 4 ray-workers
2025-01-19 12:03:41,228 [INFO] - Processing whole dataset
2025-01-19 12:03:41,228 [INFO] - Loading all files from folder /input/. No filelist provided.
2025-01-19 12:03:41,230 [INFO] - Progress: 1/1
2025-01-19 12:03:41,230 [INFO] - Processing WSI: my_filename.ndpi
2025-01-19 12:03:41,230 [INFO] - Preparing WSI - Loading tissue region and prepare patches
2025-01-19 12:03:41,235 [INFO] - Using target_mpp: 0.22815423226100845 instead of 0.25

Is it possible to run the detect_cells.py script with non-svs slides?

FYI I also noticed that I wasn't able to run the example training/inference scripts you've provided with torch==2.2.1 torchaudio==2.2.1 torchvision==0.17.1. It did run when I used torch==2.2.2 torchvision==0.17.2 torchaudio==2.2.2 which you referred to after saying the versions you'd been using.

Any help very much appreciated! :)

@FabianHoerst
Copy link
Collaborator

Hi, could you provide me the entire command you used?

@OliS1311
Copy link
Author

Sure. I've tried this for the process_wsi option:

python3 cellvit/detect_cells.py \
    --model checkpoints/CellViT-SAM-H-x40-AMP.pth \
    --gpu 0 \
    --outdir output/ \
    --geojson \
    process_wsi \
        --wsi_path input/my_filename.ndpi

If I run the following then it runs but just seems to ignore the single wsi in the 'input' folder. No error is thrown but it finishes running and there's no output.

python3 cellvit/detect_cells.py \
    --model checkpoints/CellViT-SAM-H-x40-AMP.pth \
    --gpu 0 \
    --outdir output/ \
    --geojson \
    process_dataset \
        --wsi_folder input/

If I specify ndpi then I get the same error as for process_wsi:

python3 cellvit/detect_cells.py \
    --model checkpoints/CellViT-SAM-H-x40-AMP.pth \
    --gpu 0 \
    --outdir output/ \
    --geojson \
    process_dataset \
        --wsi_folder input/ \
        --wsi_extension ndpi

I AM however able to run it if I change the format to .ome.tiff and specify metadata manually:

python3 cellvit/detect_cells.py \
    --model checkpoints/CellViT-SAM-H-x40-AMP.pth \
    --gpu 0 \
    --outdir output/ \
    --geojson \
    process_wsi \
        --wsi_path input/my_filename.ome.tif \
        --wsi_properties "{\"slide_mpp\": 0.22815423226100845, \"magnification\": 40}"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants