Catalog PyPI
Back to packageRELEASE DETAILS

0.1.1

PyPI

agl_anonymizer

This package is made to censor sensitive data in images and extract the contents. NER is planned for the future

Published6 Sept 2024
Direct dependencies18
Transitive dependenciesNot calculated

README

Version 0.1.1 documentation

AGL Anonymizer

AGL Anonymizer is a Django-based API that interacts with the AGL Anonymizer Pipeline to provide comprehensive image processing capabilities, specifically for anonymizing sensitive information using common German names, blurring, and OCR (Optical Character Recognition). This API is designed to facilitate the seamless integration of anonymization functionalities into various applications, ensuring privacy and compliance with data protection regulations.

Features of the pipeline

  • Text Detection and Anonymization: Leverages advanced OCR techniques to detect and anonymize text within images, safeguarding sensitive information.
  • Blurring Functionality: Includes customizable blurring options to obscure specific areas of an image, enhancing privacy.
  • Image Saving: Efficiently saves processed images in the desired format while maintaining high-quality output.
  • Extensive Format Support: Capable of handling various image and document formats for diverse applications.
  • Pdf,

Installation

To get started with AGL Anonymizer, follow these steps:

  1. Clone the Repository:

    git clone https://github.com/wg-lux/agl_anonymizer.git
    cd agl_anonymizer
    
  2. Set Up the Development Environment:

    nix develop
    
  3. Install Dependencies: Ensure you have all required dependencies installed. Refer to pypoetry.toml for a list of dependencies.

  4. Download the Text Detection Model: Download a text detection model, such as frozen_east_text_detection.pb, and place it in the appropriate directory.

Usage

To use the AGL Anonymizer API, follow these steps:

  1. Prepare Your Images: Place the images you want to process in a designated folder.

  2. Configure Settings: Adjust settings in the configuration file (if applicable) to suit your anonymizing and blurring needs.

  3. Run the Django Server:

    python manage.py runserver
    
  4. Make API Requests: Decide first, if validation of the anonymization is necessary. (only available with a running instance of agl-validator) If so, the validation flag needs to be set to true inside of the request.

    Use an API client like Postman, cURL, or the requests library in Python to interact with the AGL Anonymizer API. Example request using the requests library:

    import requests
    import os
    
    # Get the directory of the current script
    base_dir = os.path.dirname(os.path.abspath(__file__))
    
    # Define the path to the image file located in the 'requests_agl_anonymizer' folder
    image_path = os.path.join(base_dir, 'frame_0.jpg')
    
    # Ensure the file exists
    if not os.path.exists(image_path):
        raise FileNotFoundError(f"No such file or directory: '{image_path}'")
    
    # Define the URL of the Django API endpoint
    url = 'http://127.0.0.1:8000/process/'
    
    # Open the file in binary mode and send it as part of the multipart form-data payload
    with open(image_path, 'rb') as image_file:
        files = {
            'file': image_file,
        }
        data = {
            'title': 'Example Image',
        }
        response = requests.post(url, files=files, data=data)
    
    # Print the response from the server
    print(response.status_code)
    print(response.json())  # Assuming the server returns a JSON response
    

API Endpoints

  • /process/: Endpoint to upload images and receive anonymized results.

Modules

AGL Anonymizer API comprises several key modules:

  • OCR Module: Detects and extracts text from images.
  • Anonymizer Module: Applies anonymization techniques to identified sensitive text regions.
  • Blur Module: Provides functions to blur specific areas in the image.
  • Save Module: Handles the saving of processed images in a chosen format.

Models

UploadedFile

Represents an uploaded file with fields for the original file, upload date, and an optional description.

from django.db import models
from django.utils import timezone

class UploadedFile(models.Model):
    original_file = models.FileField(upload_to='uploads/original/')
    upload_date = models.DateTimeField(default=timezone.now)
    description = models.TextField(blank=True, null=True)
    
    def __str__(self):
        return self.original_file.name

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 18

Native requirements
18 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
transformers
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": "<4.0,>=3.11",
  "evaluation": "NOT_EVALUATED"
}
transformers<5.0.0,>=4.20.0runtime
Pillow
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": "<4.0,>=3.11",
  "evaluation": "NOT_EVALUATED"
}
Pillow<10.0.0,>=9.0.0runtime
PyMuPDF
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": "<4.0,>=3.11",
  "evaluation": "NOT_EVALUATED"
}
PyMuPDF<2.0.0,>=1.20.0runtime
numpy
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": "<4.0,>=3.11",
  "evaluation": "NOT_EVALUATED"
}
numpy==1.26.4runtime
spacy
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": "<4.0,>=3.11",
  "evaluation": "NOT_EVALUATED"
}
spacy<4.0.0,>=3.4.0runtime
requests
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": "<4.0,>=3.11",
  "evaluation": "NOT_EVALUATED"
}
requests==2.31.0runtime
flair
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": "<4.0,>=3.11",
  "evaluation": "NOT_EVALUATED"
}
flair==0.13.0runtime
gender-guesser
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": "<4.0,>=3.11",
  "evaluation": "NOT_EVALUATED"
}
gender-guesser==0.4.0runtime
PyPDF2
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": "<4.0,>=3.11",
  "evaluation": "NOT_EVALUATED"
}
PyPDF2==3.0.1runtime
reportlab
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": "<4.0,>=3.11",
  "evaluation": "NOT_EVALUATED"
}
reportlab==4.1.0runtime
torch
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": "<4.0,>=3.11",
  "evaluation": "NOT_EVALUATED"
}
torch<3.0.0,>=2.2.2runtime
gensim
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": "<4.0,>=3.11",
  "evaluation": "NOT_EVALUATED"
}
gensim<5.0.0,>=4.1.2runtime
gunicorn
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": "<4.0,>=3.11",
  "evaluation": "NOT_EVALUATED"
}
gunicorn<23.0.0,>=22.0.0runtime
django
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": "<4.0,>=3.11",
  "evaluation": "NOT_EVALUATED"
}
django<4.3,>=4.2runtime
djangorestframework
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": "<4.0,>=3.11",
  "evaluation": "NOT_EVALUATED"
}
djangorestframework<4.0.0,>=3.14.0runtime
django-bootstrap5
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": "<4.0,>=3.11",
  "evaluation": "NOT_EVALUATED"
}
django-bootstrap5<24.0,>=23.4runtime
agl-anonymizer-pipeline
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": "<4.0,>=3.11",
  "evaluation": "NOT_EVALUATED"
}
agl-anonymizer-pipeline<0.2.0,>=0.1.2runtime
opencv-python-headless
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": "<4.0,>=3.11",
  "evaluation": "NOT_EVALUATED"
}
opencv-python-headless<5.0.0.0,>=4.10.0.84runtime

Distribution files

2 collected
agl_anonymizer-0.1.1-py3-none-any.whl

bdist_wheel · 87,728.54 KB · Python py3

Source file
agl_anonymizer-0.1.1.tar.gz

sdist · 87,729.02 KB · Python source

Source file

Metadata history

Meaningful changes
Current collected state Current

Observed since 21 Oct, 09:13 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:ce72fc54f75aece71623292f97ff0d9e981b1779cfb77928e8d14d7d5c2ca430

Other collected versions

View all collected versions →