Skip to main content

Christofy is a lightweight, modular PyTorch-based AI toolkit that unifies essential deep learning capabilities. It supports Image Classification, Segmentation, and advanced Vision Analysis with clean, easy-to-use APIs. With built-in Retrieval-Augmented Generation (RAG) powered by ChromaDB and Ollama, it seamlessly blends vision and language intelligence. Designed for flexibility and speed, Christofy is your all-in-one arsenal for building modern AI solutions.

Project description

Christofy 🧠📦

Christofy is a lightweight and modular PyTorch-based image classification package designed for both training and prediction. Built on top of ResNet18, it supports both binary and multi-class classification with clean abstractions and an easy-to-use API. Now featuring a powerful RAG (Retrieval-Augmented Generation) system and Vision Analysis capabilities with Ollama integration!


🚀 Features

  • ✅ Train image classifiers using CNN (ResNet18)
  • ✅ Binary and multi-class classification support
  • ✅ Predict the class of a single image using saved model
  • ✅ Modular structure: clean separation between training and prediction
  • ✅ RAG pipeline with Ollama integration for text analysis
  • ✅ Support for multiple file formats (PDF, DOCX, CSV, Excel, TXT, JSON)
  • ✅ Vision Analysis with multimodal AI models
  • ✅ Conversation mode for interactive image analysis
  • ✅ Batch processing for multiple images
  • ✅ Graph-based image segmentation
  • ✅ AutoML for tabular data with multiple algorithms
  • ✅ Ready to be installed as a Python package

📚 Usage

Image Classification

import christofy

# Train a model
christofy.train_model(
    data_dir="path/to/dataset",
    learning_rate=0.001,
    epochs=10,
    batch_size=32,
    output_dir="output"
)

# Make predictions
predicted_class = christofy.predict_image(
    model_path="output/model.pth",
    image_path="path/to/image.jpg"
)

RAG Pipeline

from christofy import run_rag_pipeline

# Example usage
response = run_rag_pipeline(
    data="path/to/documents",  # Can be file, directory, or text
    query="Your question here?",
    model="llama2",              # Your local Ollama model
    embedding_model="nomic-embed-text",  # For embeddings
    temperature=0.7
)

print(response)

Supported File Formats for RAG

  • PDF files (requires PyPDF2 or pdfplumber)
  • Word documents (DOCX) (requires python-docx)
  • CSV and Excel files (requires pandas)
  • Text files (TXT)
  • JSON files

Vision Analysis

from christofy import vision_spell

# Basic usage
vision_spell("image.jpg", "What do you see?")

# With model selection
vision_spell("image.jpg", "What do you see?", model="llava:13b")

# Full parameters
vision_spell(
    image_path="image.jpg",
    question="What do you see?",
    model="llava",
    temperature=0.7,
    max_tokens=None,
    system_prompt=None,
    conversation_mode=False
)

# Conversation mode
chat = vision_spell("image.jpg", "What do you see?", conversation_mode=True)
chat.ask("What colors are present?")
chat.ask("Is this indoors or outdoors?")

# Export conversation
chat.export_conversation("json")
chat.export_conversation("txt")

# Batch processing
from christofy import batch_vision_analysis

batch_vision_analysis(
    image_paths=["img1.jpg", "img2.png"],
    questions="What do you see?",
    model="llava"
)

# Utility functions
from christofy import list_vision_models, get_system_info, show_module_info

# Alternative function name
from christofy import vision
vision("image.jpg", "What do you see?")

Image Segmentation

from christofy import segmenter

# Basic usage with default parameters
segmenter("image.jpg")

# With custom parameters
segmenter(
    image_path="image.jpg",
    sigma=0.5,           # Standard deviation for Gaussian smoothing
    merge_threshold=500,  # Threshold for merging segments
    min_size=50          # Minimum segment size
)

Machine Learning for Tabular Data

from christofy.ml import ml_trainer, ml_predictor

# Example 1: AutoML (automatic algorithm selection)
result1 = ml_trainer(
    data="data.csv",  # Replace with your CSV file
    target="target",  # Replace with your target column
    hyperparams={
        "test_size": 0.3,
        "cv": 5
    },
    save_path="automl_model.pkl"
)

# Example 2: User-specified algorithm
result2 = ml_trainer(
    data="data.csv",
    target="target",
    algorithm="random_forest",
    hyperparams={
        "test_size": 0.25,
        "cv": 10,
        "n_estimators": 200,
        "max_depth": 8
    },
    save_path="rf_model.pkl"
)

# Example 3: Make predictions
predictions = ml_predictor(
    model_path="automl_model.pkl",
    values=[[5.1, 3.5, 1.4, 0.2], [6.2, 2.8, 4.8, 1.8]]
)

Requirements

  • Python 3.9+
  • PyTorch
  • Ollama (for RAG and Vision functionality)
  • Pillow (for Vision functionality)
  • scikit-image (for Segmentation functionality)
  • matplotlib (for Segmentation visualization)
  • scikit-learn (for ML functionality)
  • pandas (for ML and CSV/Excel support)
  • Additional dependencies based on file formats

Installation

pip install christofy

For PDF support:

pip install PyPDF2  # or pdfplumber

For DOCX support:

pip install python-docx

For CSV/Excel support:

pip install pandas openpyxl

📝 License

This project is licensed under the MIT License - see the LICENSE file for details.

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

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

christofy-1.0.2.tar.gz (25.5 kB view details)

Uploaded Source

Built Distribution

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

christofy-1.0.2-py3-none-any.whl (26.4 kB view details)

Uploaded Python 3

File details

Details for the file christofy-1.0.2.tar.gz.

File metadata

  • Download URL: christofy-1.0.2.tar.gz
  • Upload date:
  • Size: 25.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.8

File hashes

Hashes for christofy-1.0.2.tar.gz
Algorithm Hash digest
SHA256 b164ce969c0ed86fda13e5aae7dc39f8fe1af6814cf3d51e0759a5b8d6e2747e
MD5 dca6d4e7322475ec813b7bcc046a428c
BLAKE2b-256 19446e6bcc946fbda9e48b0f72830460ad6f45d8486b2ad0fbc844e61e198d02

See more details on using hashes here.

File details

Details for the file christofy-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: christofy-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 26.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.8

File hashes

Hashes for christofy-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 862c688d2ae1caa22287e8ad44aa5478032763d6ee9dc8711a444fc5f85c9be7
MD5 d925d2969dc648cdbf34c6802d827ab9
BLAKE2b-256 efb57405199e1bca71bd117231f43cf12b11de61b26c6f32d3abc717c43982e8

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