Instructions to use kiselyovd/chest-xray-classifier with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use kiselyovd/chest-xray-classifier with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-classification", model="kiselyovd/chest-xray-classifier") pipe("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/parrots.png")# pip install -U transformers accelerate # Load model directly from transformers import AutoImageProcessor, AutoModelForImageClassification processor = AutoImageProcessor.from_pretrained("kiselyovd/chest-xray-classifier") model = AutoModelForImageClassification.from_pretrained("kiselyovd/chest-xray-classifier", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Download hf_processor.py from kiselyovd/chest-xray-classifier: direct link, hf CLI and curl.
- Browser
- Download file 1.18 kB
-
https://huggingface.co/kiselyovd/chest-xray-classifier/resolve/main/hf_processor.py
- Command line
-
hf download hf://kiselyovd/chest-xray-classifier/hf_processor.py
-
curl -L -o hf_processor.py https://huggingface.co/kiselyovd/chest-xray-classifier/resolve/main/hf_processor.py
1.18 kB
| """Native ConvNeXT processor preserving the project's torchvision crop rounding.""" | |
| # Copyright (c) 2026 Daniil Kiselyov. SPDX-License-Identifier: MIT | |
| from __future__ import annotations | |
| import torch | |
| from torchvision.transforms.v2 import functional as functional | |
| from transformers.image_utils import SizeDict | |
| from transformers.models.convnext.image_processing_convnext import ConvNextImageProcessor | |
| class ChestXrayImageProcessor(ConvNextImageProcessor): | |
| """Use torchvision's rounded center anchor instead of the Hub backend's truncation.""" | |
| # Transformers 5.5's external typing exposes the legacy PIL signature for | |
| # this torchvision backend. Runtime dispatch supplies Tensor + SizeDict. | |
| def center_crop( # type: ignore[override] | |
| self, image: torch.Tensor, size: SizeDict, **kwargs | |
| ) -> torch.Tensor: | |
| """Preserve exactly the crop used by the training/evaluation transform.""" | |
| if size.height is None or size.width is None: | |
| raise ValueError("Crop size requires height and width") | |
| return functional.center_crop(image, [size.height, size.width]) | |
| ChestXrayImageProcessor.register_for_auto_class("AutoImageProcessor") | |