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
File size: 1,184 Bytes
09bd78b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | """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")
|