Skip to main content

dpfm_factory

dpfm_factory is a Python package that provides a factory function to easily load different machine learning models and their associated preprocessing pipelines from Hugging Face. This package is particularly useful in the digital and computational pathology domains, where it is crucial to work with various specialized models.

Features

  • Easy Model Loading: Load machine learning models and their preprocessing pipelines with a simple factory function.
  • Hugging Face Integration: Seamlessly integrates with Hugging Face to authenticate and load models.
  • Custom Environment Variables: Supports loading environment variables from a .env file for sensitive data like tokens.

Installation

To install the package directly from GitHub, use the following command:

pip install git+https://github.com/Steven-N-Hart/dpfm_factory

Ensure that you have all necessary dependencies listed in the requirements.txt file. Alternatively, clone the repository and install the package locally:

git clone https://github.com/Steven-N-Hart/dpfm_factory
cd dpfm_factory
pip install -r requirements.txt
pip install .

Usage

Setup

Before using the package, make sure to create a .env file in the root of your project directory with your Hugging Face token:

HUGGINGFACE_TOKEN=your_huggingface_token_here

Example Usage

Here’s an example of how to use the model_factory function to load a model and its associated processor:

from dpfm_factory.model_runners import model_factory

# Specify the model you want to load
model_name = 'MahmoodLab/conch'

# Load the model, processor, and the function to get image embeddings
model, processor, get_image_embedding = model_factory(model_name)

# Example usage with an image (replace 'your_image' with actual image data)
image_embedding = get_image_embedding(your_image)

print("Image Embedding:", image_embedding)

Supported Models

The model_factory function currently supports the following models:

Note: Some of these models require a HuggingFace Token that has been approved by the model owner. The Google model also requires submitters to sign additional Terms of Service.

Error Handling

If an unsupported model name is provided, the model_factory will raise a NotImplementedError. For example:

try:
    model, processor, get_image_embedding = model_factory('unsupported/model_name')
except NotImplementedError as e:
    print(e)

Contributing

Contributions are welcome! Please fork the repository and submit a pull request with your changes.

Release files for dpfm-factory 0.13.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dpfm-factory 0.13.7
File Size Uploaded
dpfm_factory-0.13.7.tar.gz 27.9 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for dpfm-factory 0.13.7
File Interpreter ABI Platform
dpfm_factory-0.13.7-py3-none-any.whl Python 3 none any Details

Total release size: 55.8 MB

Release files / dpfm_factory-0.13.7.tar.gz

Download URL dpfm_factory-0.13.7.tar.gz
Size 27.9 MB
Tags Source
SHA-256 checksum
How to use checksums
fe28da017132e37ffaf8b4c9245089e928966a68a983e443c2e8bf2cecf8b8ee
BLAKE2b-256 checksum
How to use checksums
ef16015dafb001fc4b01949d7a15e3e79149f48208c01fd4b50c10ec334599c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.12

Release files / dpfm_factory-0.13.7-py3-none-any.whl

Download URL dpfm_factory-0.13.7-py3-none-any.whl
Size 27.9 MB
Tags Python 3
SHA-256 checksum
How to use checksums
6b5f23252a47b034b2f9b9ba12e426360c6f0919a6be32baa6ab8158b3be30a9
BLAKE2b-256 checksum
How to use checksums
d3d594d38468f8140165e7035473567631a61d8116c9ced01a97e84358f5184e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.12

Release history Release notifications | RSS feed

This release

0.13.7 This release

2 release files

0.13.5

2 release files

0.13.4

2 release files

0.13.3

2 release files

0.13.2

2 release files

0.13.1

2 release files

0.13

2 release files

0.12

2 release files

0.11

2 release files

0.10

2 release files

0.9.1

2 release files

0.9

2 release files

0.8.9

2 release files

0.8.8

2 release files

0.8.7

2 release files

0.8.6

2 release files

0.8.5

2 release files

0.8.4

2 release files

0.8.3

2 release files

0.8.2

2 release files

0.8.1

2 release files

0.8

2 release files

0.7

2 release files

0.6

2 release files

0.5

2 release files

0.4

2 release files

0.3

2 release files

0.2

2 release files

0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page