Skip to content

import torch changes OpenSlide vendor detection (Philips WSI becomes generic-tiff) #372

Description

@0820LL

Operating system

Ubuntu 16.04.7 LTS

Platform

x86_64

OpenSlide Python version

openslide-python: 1.4.6

OpenSlide version

openslide=4.0.1

Slide format

TIFF

Issue details

I encountered a very strange issue where the import order of torch and openslide changes how OpenSlide detects the same WSI file.

The exact same Philips TIFF file is recognized correctly when openslide is imported first, but is detected as generic-tiff when torch is imported first.

This causes downstream applications (e.g. HoverNet) to fail because OpenSlide no longer exposes Philips-specific metadata such as openslide.mpp-x.

Environment:

Python: 3.12.13
openslide-python: 1.4.6
openslide: 4.0.1
torch: 2.12.1+cu126
OS: Ubuntu 16.04.7 LTS

Minimal Reproducible Example

Case 1 (works)

import openslide

slide = openslide.OpenSlide("patient_190_node_0.tif")

print(slide.properties["openslide.vendor"])
print("openslide.mpp-x" in slide.properties)

Case 1 Output:

philips
True

Case 2 (works)

import openslide
import torch

slide = openslide.OpenSlide("patient_190_node_0.tif")

print(slide.properties["openslide.vendor"])
print("openslide.mpp-x" in slide.properties)

Case 2 Output:

philips
True

Case 3 (fails)

import torch
import openslide

slide = openslide.OpenSlide("patient_190_node_0.tif")

print(slide.properties["openslide.vendor"])
print("openslide.mpp-x" in slide.properties)

Case 3 Output:

generic-tiff
False

The WSI file used

https://github.com/0820LL/openslide-python-issue-file/releases/download/1.0/patient_190_node_0.tif

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions