Skip to main content

Few-shot classifier for detecting eye imaging datasets

Project description

envision-classifier

SetFit few-shot classifier for identifying eye imaging datasets from scientific metadata.

Part of the EyeACT project by the FAIR Data Innovations Hub.

Installation

pip install envision-classifier

Python API

from envision_classifier import EyeImagingClassifier

# Downloads model from HuggingFace on first use
clf = EyeImagingClassifier()

# Classify a single record
result = clf.classify("Retinal OCT dataset for diabetic retinopathy")
print(result)
# {'label': 'EYE_IMAGING', 'confidence': 0.98,
#  'probabilities': {'EYE_IMAGING': 0.98, 'NEGATIVE': 0.02}}

# Classify a batch
results = clf.classify_batch([
    "Retinal fundus photography dataset for glaucoma screening",
    "COVID-19 genome sequencing data",
    {"title": "OCT images", "description": "Macular degeneration scans"},
])

# Use a local model instead of downloading
clf = EyeImagingClassifier(model_path="./my_model")

CLI

After installing, the envision-classifier command is available:

# Classify a text string
envision-classifier classify --text "Retinal OCT dataset for diabetic retinopathy"

# Classify from a JSON file
envision-classifier classify records.json

# Pipe JSON via stdin
echo '{"title": "Fundus images", "description": "DR screening"}' | envision-classifier classify

# Train a new model from built-in training data
envision-classifier train --output ./my_model

# Show model info and training data counts
envision-classifier info

Classification Labels

Label Description
EYE_IMAGING Actual eye imaging datasets (fundus, OCT, OCTA, cornea)
NEGATIVE Everything else (software, non-imaging eye data, unrelated domains)

Model

  • Base model: sentence-transformers/all-mpnet-base-v2 (768-dim)
  • Training data: 891 curated examples (262 EYE_IMAGING, 629 NEGATIVE) from Zenodo, Figshare, Dryad, Kaggle, and NEI
  • Test accuracy: 0.961, EYE_IMAGING F1: 0.936
  • Spot-check: 30/33 (90.9%)
  • Model weights: fairdataihub/envision-eye-imaging-classifier

Zenodo Classification Results

Applied to 515 Zenodo dataset records via envision-discovery:

Class Count
EYE_IMAGING 60
NEGATIVE 455

Classification is based on metadata only (titles, descriptions, keywords, and file types inspected inside archives via HTTP Range requests) -- no dataset files are downloaded.

Related

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

envision_classifier-0.3.1.tar.gz (139.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

envision_classifier-0.3.1-py3-none-any.whl (139.6 kB view details)

Uploaded Python 3

File details

Details for the file envision_classifier-0.3.1.tar.gz.

File metadata

  • Download URL: envision_classifier-0.3.1.tar.gz
  • Upload date:
  • Size: 139.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.3 CPython/3.12.13 Linux/6.17.0-1008-azure

File hashes

Hashes for envision_classifier-0.3.1.tar.gz
Algorithm Hash digest
SHA256 4e16aca671bc7cb826824ea1cafb9ae0b1d6538a896b54f1dbd3632a719f1da9
MD5 843971b9456181256e919828ed2cd891
BLAKE2b-256 83992e417c327874f0e88969fffe55499e9138877ba7783b3ef085468180a617

See more details on using hashes here.

File details

Details for the file envision_classifier-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: envision_classifier-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 139.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.3 CPython/3.12.13 Linux/6.17.0-1008-azure

File hashes

Hashes for envision_classifier-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5deac1b4bb5b95b54fd356b16f837281e3419f35871b3374da2f1f79f8734680
MD5 e8314c478fbd14b28afaca4360095148
BLAKE2b-256 43874883e4154d4a8f280e0343e3e3cd8a4152b6ee6eeb34c1fe60b47f8789d3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page