Skip to main content

A package to make the usage of DeepLearning models easier

Project description

svnm - A Simplified Deep Learning Models Package

svnm is a Python package designed to simplify the process of using deep learning models in your code. With just a simple import, you can easily load pre-trained models and make predictions with minimal setup. This package is aimed at making deep learning models more accessible for developers, enabling rapid experimentation and deployment.

Routing

Image Classification

Features

  • Easy-to-use interface: Import the package and start making predictions with minimal code.
  • Pre-trained models: Includes popular deep learning models ready for use without additional training.
  • Flexible prediction methods: Support for various types of input data to make predictions.
  • Lightweight and efficient: Focuses on simplifying deep learning workflows without overhead.

Installation

To install svnm, simply use pip:

pip install svnm

Model Usage

Gender Detection

from svnm.models import GenderDetection

model = GenderDetection()

# Single Prediction
prediction, confidence = model.predict("face_image.jpg")
print(f"Predicted Gender: {prediction} with confidence {confidence:.2f}")

# Batch Prediction
image_paths = ["face1.jpg", "face2.jpg", "face3.jpg"]
predictions = model.predict_batch(image_paths)
for img, (label, conf) in zip(image_paths, predictions):
    print(f"Image: {img} -> Predicted Gender: {label} with confidence {conf:.2f}")

# Visualization
model.visualize_prediction("face_image.jpg")

How Gender Detection Works

The Gender Detection model in svnm classifies whether a detected face belongs to a male or female. It works as follows:

  1. Loading the Model: The pre-trained deep learning model is loaded automatically when the GenderDetection class is initialized.
  2. Processing the Image: The input image is preprocessed and resized before being fed into the model.
  3. Making Predictions: The model analyzes the facial features and predicts the gender along with a confidence score.
  4. Batch Processing:
    • Supports batch predictions for multiple images at once.
    • Each image is processed individually, and the results are returned as a list.
  5. Visualization:
    • If visualize_prediction() is called, the image is displayed with the predicted gender and confidence score.

Face Detection

from svnm.models import FaceDetection

model = FaceDetection(save=True, save_dir="predictions")

# Single Image Prediction
predictions = model.predict("face_image.jpg")
print("Face Detection Results:", predictions)

# Batch Prediction
image_paths = ["face1.jpg", "face2.jpg", "face3.jpg"]
batch_predictions = model.predict_batch(image_paths)
for img, preds in zip(image_paths, batch_predictions):
    print(f"Image: {img} -> Predictions: {preds}")

How Face Detection Works

The Face Detection model in svnm is designed to detect human faces in images. It works as follows:

  1. Loading the Model: The pre-trained YOLO-based face detection model is loaded automatically when the FaceDetection class is initialized.
  2. Processing the Image: The input image is read, preprocessed, and fed into the model.
  3. Detecting Faces: The model detects faces in the image and returns bounding box coordinates, confidence scores, and class labels.
  4. Batch Processing:
    • Supports batch predictions for multiple images at once.
    • Each image is processed individually, and the results are returned as a list.
  5. Saving and Visualizing Results:
    • If save=True, the detected faces are highlighted in the image and saved to the specified directory.
    • The model outputs a list of detected faces with their positions and confidence levels.

Face Recognition

from svnm.models import FaceRecognition

model = FaceRecognition()

# Train the model
train_dataset = [
    {"imagepath": "person1.jpg", "label": "John"},
    {"imagepath": "person2.jpg", "label": "Jane"}
]
model.train(train_dataset)

# Predict from a new image
prediction = model.predict("test_face.jpg")
print("Face Recognition Prediction:", prediction)

How Face Recognition Works

  1. Face Detection: Detects faces in the given image using the FaceDetection model.
  2. Face Embeddings: Extracts feature embeddings using a deep learning model.
  3. Matching Faces: Compares embeddings with the trained dataset using cosine similarity.
  4. Making Predictions:
    • If a match is found, returns the predicted label and confidence score.
    • If no match is found, returns Unknown.

Handwritten Digit Recognition

from svnm.models import HandwrittenDigitRecognition

model = HandwrittenDigitRecognition()

# Single Image Prediction
prediction = model.predict("digit_image.jpg")
print("Predicted Digit:", prediction)

How Handwritten Digit Recognition Works

  1. Loading the Model: The pre-trained digit recognition model is initialized.
  2. Processing the Image: The input image is resized and normalized before being fed into the model.
  3. Making Predictions:
    • The model predicts the digit and outputs the confidence score.
    • Supports batch predictions for multiple images at once.

Example Output

{"digit": 7, "confidence": 0.98}

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

svnm-1.4.1.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

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

svnm-1.4.1-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file svnm-1.4.1.tar.gz.

File metadata

  • Download URL: svnm-1.4.1.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.1

File hashes

Hashes for svnm-1.4.1.tar.gz
Algorithm Hash digest
SHA256 2a0557d3a77c65e715cb1e331fa58319101de0f9b24bc70764908202b91ef7ae
MD5 8bf681dfc7fa5d2c21b7222baacb4fe5
BLAKE2b-256 cc947011bf54c45eebc30b2227cee1911a1655e80bc6c151a5858f9fbeb56e7b

See more details on using hashes here.

File details

Details for the file svnm-1.4.1-py3-none-any.whl.

File metadata

  • Download URL: svnm-1.4.1-py3-none-any.whl
  • Upload date:
  • Size: 11.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.1

File hashes

Hashes for svnm-1.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f1c3cc051d9dc202eb92770b868f5089fd8f7d6dbf1c248a8bd398e6aea90bdf
MD5 7e3fd7a44585e3ebd3d5270789be8601
BLAKE2b-256 df9a031c8730e74326231fd7b93a3f2b626b2958d8d9b248a5cde7bd14f41071

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