Run this model with HF Jobs
Run NeuronZero/CXR-Classifier on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/NeuronZero/CXR-Classifier. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/NeuronZero/CXR-Classifier on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use NeuronZero/CXR-Classifier with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use NeuronZero/CXR-Classifier with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-classification", model="NeuronZero/CXR-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("NeuronZero/CXR-Classifier") model = AutoModelForImageClassification.from_pretrained("NeuronZero/CXR-Classifier", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files123456789101112131415161718192021227 unmodified lines303132---tags:- autotrain- image-classificationwidget:- src: https://huggingface.co/datasets/mishig/sample_images/resolve/main/tiger.jpgexample_title: Tiger- src: https://huggingface.co/datasets/mishig/sample_images/resolve/main/teapot.jpgexample_title: Teapot- src: https://huggingface.co/datasets/mishig/sample_images/resolve/main/palace.jpgexample_title: Palacedatasets:- CXR-Classifier/autotrain-data---# Model Trained Using AutoTrain- Problem type: Image Classification## Validation Metricsloss: 0.11808194220066077 unmodified linesauc: 0.9916270580630442accuracy: 0.96446078431372551234567891011121314151617181920212223242526277 unmodified lines3536373839404142434445464748495051525354555657585960---tags:- autotrain- image-classification- visiondatasets:- CXR-Classifier/autotrain-datalicense: apache-2.0pipeline_tag: image-classification---# CXR-Classifier(Small-size model)It is a fine tuned version of [Vision Transformer(base-sized model)](https://huggingface.co/google/vit-base-patch16-224). It was trained on a private dataset.## Model descriptionThe Vision Transformer (ViT) is a transformer encoder model (BERT-like) pretrained on a large collection of images in a supervised fashion, namely ImageNet-21k, at a resolution of 224x224 pixels. Next, the model was fine-tuned on ImageNet (also referred to as ILSVRC2012), a dataset comprising 1 million images and 1,000 classes, also at resolution 224x224.Images are presented to the model as a sequence of fixed-size patches (resolution 16x16), which are linearly embedded. One also adds a [CLS] token to the beginning of a sequence to use it for classification tasks. One also adds absolute position embeddings before feeding the sequence to the layers of the Transformer encoder.By pre-training the model, it learns an inner representation of images that can then be used to extract features useful for downstream tasks: if you have a dataset of labeled images for instance, you can train a standard classifier by placing a linear layer on top of the pre-trained encoder. One typically places a linear layer on top of the [CLS] token, as the last hidden state of this token can be seen as a representation of an entire image.It was introduced in the paper [An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale](https://arxiv.org/abs/2010.11929) by Dosovitskiy et al. and first released in [this repository](https://github.com/google-research/vision_transformer). However, the weights were converted from the [timm repository](https://github.com/rwightman/pytorch-image-models) by Ross Wightman, who already converted the weights from JAX to PyTorch. Credits go to him## Validation Metricsloss: 0.11808194220066077 unmodified linesauc: 0.9916270580630442accuracy: 0.9644607843137255## How to useHere is how to use this model to identify a pneumonia from a chest x-ray image.```pythonfrom transformers import AutoImageProcessor, AutoModelForImageClassificationfrom PIL import Imageimport requestsprocessor = AutoImageProcessor.from_pretrained("NeuronZero/CXR-Classifier")model = AutoModelForImageClassification.from_pretrained("NeuronZero/CXR-Classifier")#dataset URL: "https://www.kaggle.com/datasets/paultimothymooney/chest-xray-pneumoniaimage_url = "https://storage.googleapis.com/kagglesdsdata/datasets/17810/23812/chest_xray/test/PNEUMONIA/person100_bacteria_482.jpeg?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=databundle-worker-v2%40kaggle-161607.iam.gserviceaccount.com%2F20240406%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20240406T182943Z&X-Goog-Expires=345600&X-Goog-SignedHeaders=host&X-Goog-Signature=7edc1aa6f7c2b182355aa18dd1e712c88594decce41f4f69f0c1839b1bc549e5e2d9e9b0eadc836ce0daf884c60f84e482eb0313b921bbc613b8de406dfec403df3845cb32c04c6df9efc2469a2f182a58e65c9def260409ac751d6c06302afb00d32205e8072cc773ba37867bd0940b0e45dff3bfb9924ac44f7bc3682f64b99b4ce26160f62484894594b89da602af0fa235cc998cda55b71d1d99bf10b2a7b7829f68e6742440d11ca141efe1af9cdf7bee47afc5be99bacc1d1c8d2c5eb2dc0978fa8f845b0c1e4a53d2641dc3ba8d10fd4161586596c57314b23b94813427b122141f26d5277ce5b63355801e65a1d39a955f6390f704afc024e91c8a47"image = Image.open(requests.get(image_url, stream=True).raw)inputs = processor(images=image, return_tensors="pt")outputs = model(**inputs)logits = outputs.logitspredicted_class_idx = logits.argmax(-1).item()print("Predicted class:", model.config.id2label[predicted_class_idx])```
README.md+38-10