PRNU Toolkit & AI Predictor
A Python library for Photo-Response Non-Uniformity (PRNU) noise extraction, camera identification through fingerprint correlation and a ResNet-18-based AI image detector.
Links
Refer to the interactive website as a usage example and the repository
Installation
pip install prnu
Usage Examples
1. Extract visible noise
Extract PRNU noise from an image and scale subtle variance into a viewable 8-bit PNG image:
import prnu
# Initialize extractor with an image file path
extractor = prnu.NoiseExtractor("image.png")
# Extract PRNU multiplicative noise residual
extractor.extract_noise()
# Make the noise visible
extractor.shift_to_visual()
# Save visual representation to disk
extractor.write_to_file("visual_noise.png")
2. Camera identification
Average the noise patterns from training photos taken by a single camera, compute an average reference fingerprint, and then test an unknown image:
import os
import prnu
training_dir = "/path/to/camera_samples"
test_image_path = "/path/to/test_image.jpg"
# 1. Collect noise from training photos
avg = prnu.AverageNoise()
for file_name in os.listdir(training_dir):
file_path = os.path.join(training_dir, file_name)
# Extract noise without zero-meaning during aggregation
extractor = prnu.NoiseExtractor(file_path)
extractor.extract_noise(disable_zero_meaning=True)
avg.add_image_data(extractor)
# Compute final reference fingerprint
avg.analyse()
# 2. Extract noise from test image
test_extractor = prnu.NoiseExtractor(test_image_path)
test_extractor.extract_noise()
# 3. Correlate test image against reference profile
comparison = prnu.Compare(test_extractor, avg)
score = comparison.correlate()
print(f"Correlation Score: {score:.5f}")
if score > 0.008:
print("The test image likely originated from the target camera sensor.")
Generally with a correlation score of 0.008 or higher a photo can be considered as being from the same camera
3. AI Image Detection
Load the attached trained ResNet-18 model to predict the likelihood that a give image is AI-generated:
import prnu.ai_predictor as ai_predictor
# Initialize model instance
model = ai_predictor.Model() # this model is saved in your python installation
model.load():
# Returns scaled AI probability between 0 and 1
probability = model.predict("sample_image.png")
print(f"AI Probability: {probability * 100:.2f}%")
License
This software is licensed under the GPLv3 License.
Metadata
Release files for prnu 0.1.1
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 | Actions |
|---|---|---|---|---|
| prnu-0.1.1.tar.gz | 41.6 MB | Without provenance | Details for prnu-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| prnu-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for prnu-0.1.1-py3-none-any.whl |
Total release size: 83.1 MB
Release files / prnu-0.1.1.tar.gz
| Download URL | prnu-0.1.1.tar.gz |
|---|---|
| Size | 41.6 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
35fde9524dc964234b5ca43be631956adbe3ff9d6dab1255a9788533138d1fc9
|
|
BLAKE2b-256 checksum How to use checksums |
6d4ec453ffe04d32026d6999cc43b832ebf54001152e26892731feb3850d4987
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.7
|
Release files / prnu-0.1.1-py3-none-any.whl
| Download URL | prnu-0.1.1-py3-none-any.whl |
|---|---|
| Size | 41.6 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0c2fd367d6ef1724791ace3b25e7336944426103df73f9f51add9dcb7a82343b
|
|
BLAKE2b-256 checksum How to use checksums |
40caf63125a06078ba39e9b3187504853a78118275b9f0c1bf2102ee26a315e2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.7
|
Security for prnu 0.1.1
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.