SensitiveImgDetect
This package provides a way to load a trained PyTorch model.
Installation
You can install this package using pip:
pip install SensitiveImgDetect
## Overview
The `Detect` class is designed for image classification tasks, allowing users to predict the class of single or multiple images using a pre-trained model. This document provides an overview of how to initialize and use the class, including example code snippets.
## Installation
Before using the `Detect` class, ensure that you have installed the necessary libraries:
```bash
pip install torch pillow torchvision
Initialization
To use the Detect class, you need to initialize it. The class constructor allows you to specify the device for computation (CPU or GPU).
from SensitiveImgDetect import Detect
# Initialize the Detect class
detector = Detect(device='cuda') # Use 'cpu' if you don't have CUDA
Methods
1. Detecting the Class of a Single Image
Method: detect_single_type
Description: Predicts the class label for a single image.
Parameters:
img: An image object (PIL Image).
Returns: A string representing the predicted class label.
Example Usage:
from PIL import Image
# Load an image
img = Image.open("path_to_your_image.jpg")
# Predict the class label
predicted_label = detector.detect_single_type(img)
print(f"The predicted class for the single image is: {predicted_label}")
2. Detecting Class Probabilities for a Single Image
Method: detect_single_prob
Description: Predicts the class probabilities for a single image.
Parameters:
img: An image object (PIL Image).
Returns: A dictionary with class labels and their corresponding probabilities.
Example Usage:
# Predict class probabilities
predicted_probs = detector.detect_single_prob(img)
print("Class probabilities for the image:")
for class_label, probability in predicted_probs.items():
print(f"{class_label}: {probability}")
3. Detecting Classes for a List of Images
Method: detect_list_type
Description: Predicts the class labels for a list of images.
Parameters:
img_list: A list of image objects (PIL Images).
Returns: A list of predicted class labels.
Example Usage:
# Load multiple images
images = [Image.open("image_1.jpg"), Image.open("image_2.jpg")]
# Predict class labels for the list of images
predicted_labels = detector.detect_list_type(images)
print("Predicted classes for the list of images:")
print(predicted_labels)
4. Detecting Class Probabilities for a List of Images
Method: detect_list_prob
Description: Predicts the class probabilities for a list of images.
Parameters:
img_list: A list of image objects (PIL Images).
Returns: A list of dictionaries with class labels and their corresponding probabilities.
Example Usage:
# Predict class probabilities for the list of images
predicted_probs_list = detector.detect_list_prob(images)
for index, probs in enumerate(predicted_probs_list):
print(f"Probabilities for image {index + 1}:")
for class_label, probability in probs.items():
print(f"{class_label}: {probability}")
Model Perference
Class: carton
Precision: 0.95
Recall: 0.95
Class: other
Precision: 0.92
Recall: 0.82
Class: politic
Precision: 0.79
Recall: 0.93
Class: sex
Precision: 0.95
Recall: 0.88
Overall Accuracy: 0.89
version
model_v1
- base model
Class: carton
Precision: 0.95
Recall: 0.95
Class: other
Precision: 0.92
Recall: 0.82
Class: politic
Precision: 0.79
Recall: 0.93
Class: sex
Precision: 0.95
Recall: 0.88
Overall Accuracy: 0.89
model_v2
- add some data
Class: carton
Precision: 0.92
Recall: 0.88
Class: other
Precision: 0.93
Recall: 0.93
Class: politic
Precision: 0.88
Recall: 0.88
Class: sex
Precision: 0.86
Recall: 0.90
Overall Accuracy: 0.89
Metadata
Release files for SensitiveImgDetect 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| sensitiveimgdetect-0.0.2.tar.gz | 79.1 MB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| SensitiveImgDetect-0.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 158.2 MB
Release files / sensitiveimgdetect-0.0.2.tar.gz
| Download URL | sensitiveimgdetect-0.0.2.tar.gz |
|---|---|
| Size | 79.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
16e7655205d5bd8e9b4d512b36bb0e7c94aae2df4de21e715b0084a75436d52c
|
|
BLAKE2b-256 checksum How to use checksums |
234b2b10c1a4a0b99a5964e3b38d9f77c0c965c66344a16eee998053486efacd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.8.10
|
Release files / SensitiveImgDetect-0.0.2-py3-none-any.whl
| Download URL | SensitiveImgDetect-0.0.2-py3-none-any.whl |
|---|---|
| Size | 79.1 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3f830dd65ebacc519efccbce6a44dc5e3b90a1e7bd96e1350f968c7089239ea4
|
|
BLAKE2b-256 checksum How to use checksums |
38e134440c0888e8167e3731a385bbf048c5655183f76b111e85851011a55e62
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.8.10
|
Security for SensitiveImgDetect 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.