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.2.0.tar.gz (137.5 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.2.0-py3-none-any.whl (138.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: envision_classifier-0.2.0.tar.gz
  • Upload date:
  • Size: 137.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.12.13 Linux/6.14.0-1017-azure

File hashes

Hashes for envision_classifier-0.2.0.tar.gz
Algorithm Hash digest
SHA256 deef925eade79a7c2321982d1eb643e21c04e5dcd1d71787077a371a4e772e09
MD5 1c646448f16090e5f5c4f035aeaa586c
BLAKE2b-256 b248ac26768adc51e7c99e6ec1daee4e2f318093e2b442e413af9d6f4369e5bb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: envision_classifier-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 138.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.12.13 Linux/6.14.0-1017-azure

File hashes

Hashes for envision_classifier-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 aa47f208cc472121edf08ec34307972c90f7960695d155f868b4e3f3003472c7
MD5 c7ea506da027abcce50091a53b6fdbc7
BLAKE2b-256 f0020a816882fa8cd3c0160c2f37186ccb33f93513acb33541af42bd34a7ecce

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