Skip to main content

A package for generalized image classification using In-Context-Learning with PyTorch.

Project description

PictSure: In-Context Learning for Image Classification

PictSure is a deep learning library designed for in-context learning using images and labels. It allows users to provide a set of labeled reference images and then predict labels for new images based on those references. This approach eliminates the need for traditional training, making it highly adaptable for various classification tasks.

The classification process

Features

  • In-Context Learning: Predict labels for new images using a set of reference images without traditional model training.
  • Multiple Model Architectures: Choose between ResNet and ViT-based models for your specific needs.
  • Pretrained Models: Use our pretrained models or train your own.
  • Torch Compatibility: Fully integrated with PyTorch, supporting CPU and GPU.
  • Easy-to-use CLI: Manage models and weights through a simple command-line interface.

Installation

  1. Clone this repository
git clone https://git.ni.dfki.de/pictsure/pictsure-library
  1. Navigate into the folder
cd pictsure-library
  1. Install the pip package
pip install .

Quick Start

from PictSure import PictSure
import torch

# Initialize the model (using ViT as an example)
model = PictSure(
    embedding='vit',  # or 'resnet'
    pretrained=True,  # use pretrained weights
    device='cuda'     # or 'cpu'
)

# you can also pull our pre-trained models from Huggingface
model = PictSure.from_pretrained("pictsure/pictsure-vit")

# Set your reference images and labels
model.set_context_images(reference_images, reference_labels)

# Make predictions on new images
predictions = model.predict(new_images)

Command Line Interface

PictSure comes with a command-line interface to manage models and weights:

List Available Models

pictsure list-models

This command shows all available models, their status (downloaded/not downloaded), and detailed information about each model.

Remove Model Weights

pictsure remove <model_name> [--force]

Remove the weights of a specific model. Available models are:

  • ViTPreAll: ViT-based model
  • ResPreAll: ResNet-based model

Use the --force or -f flag to skip the confirmation prompt.

Examples

For a complete working example, check out the Jupyter notebook in the Examples directory:

Examples/example.ipynb

This notebook demonstrates:

  • Model initialization
  • Loading and preprocessing images
  • Setting up reference images
  • Making predictions
  • Visualizing results

Citation

If you use this work, please cite it using the following BibTeX entry:

@article{schiesser2025pictsure,
  title={PictSure: Pretraining Embeddings Matters for In-Context Learning Image Classifiers},
  author={Schiesser, Lukas and Wolff, Cornelius and Haas, Sophie and Pukrop, Simon},
  journal={arXiv preprint arXiv:2506.14842},
  year={2025}
}

License

This project is open-source under the MIT License.

Contributing

Contributions and suggestions are welcome! Open an issue or submit a pull request.

Contact

For questions or support, open an issue on GitHub.

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

pictsure-0.1.0.tar.gz (12.6 kB view details)

Uploaded Source

Built Distribution

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

pictsure-0.1.0-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

Details for the file pictsure-0.1.0.tar.gz.

File metadata

  • Download URL: pictsure-0.1.0.tar.gz
  • Upload date:
  • Size: 12.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pictsure-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fd9b1b86f9e0dd67850421232d639148bd6bf5a44cc4603b9ad29f4fc8f239a4
MD5 6714d63b92023de1512d7e63571d72c0
BLAKE2b-256 43585bc8a37bbea28e226984f6b4b9d3dfafe9136bf56c077362220b4b124ab6

See more details on using hashes here.

Provenance

The following attestation bundles were made for pictsure-0.1.0.tar.gz:

Publisher: publish.yml on PictSure/pictsure-library

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pictsure-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pictsure-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pictsure-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f6076a9ba33d0894a2dc723acee201024eeb3d83aec0c7769bb0425208816e17
MD5 c4d527447e6d65f454299a2dc8437b00
BLAKE2b-256 2ff3c3410ce9479c04d03acc2ba555b87a6e5647fa6c775441020360531dc3ff

See more details on using hashes here.

Provenance

The following attestation bundles were made for pictsure-0.1.0-py3-none-any.whl:

Publisher: publish.yml on PictSure/pictsure-library

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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