Skip to main content

A deeplearning package for the basegun weapon recognition app

Project description

Project description

Basegun_ml is a deeplearning package for the basegun weapon recongition app.

Installation

pip install basegun-ml

Usage

Classification

Gun Mechanism Classification: This feature categorizes an image into a list of families representing different firearm mechanisms. The classification is based on descriptive, objective criteria that are independent of legal classification.

from basegun_ml.classification import get_typology, list_typologies
#After the import the model is already warmed-up for faster inference

#Convert image to bytes
with open("test.jpg", "rb") as file:
    image_bytes = file.read()

#Prediction of the weapon typology
typology,confidence_score,confidence_level=get_typology(image_bytes)

#Obtain the list of the different typologies
list_typologies()

Variables description

  • typology: it corresponds to the weapon class predicted from the image. The list of typologies can be obtained from the function
  • confidence_score: it corresponds to the confidence of the class prediction of the algorithm, the closer to 1 to more confident is the prediction
  • confidence_level: there are 3 level of confidence defined. According to this performance level the basegun user will have more information.

    Measure length

    Measure Length Module: Measuring the overall length of a firearm or its barrel length is crucial for its legal classification. In France, the classification of long guns depends on these measurements. This module measures these lengths using an image.

    from basegun_ml.measure import get_lengths
    
    #Convert image to bytes
    with open("test.jpg", "rb") as file:
        image_bytes = file.read()
    
    #Get lengths
    weapon_length,barrel_length,confidence_card=get_lengths(image_bytes)
    

    Variables description

  • weapon_length: it corresponds to the weapon overall length predicted from the image.
  • barrel_length: it corresponds to the barrel length of the weapon predicted from the image.
  • confidence_card: it corresponds to the confidence score for the card prediction. A card is used as a reference for the measure module
  • If the gun is not detected, the exception MissingGun is raised
  • If the card is not detected, the exception MissingCard is raised

    Alarm Model detection

    Alarm Gun Recognition: An alarm gun is a type of blank gun recognized as an alarm by French legislation. These guns are considered impossible to modify to make them lethal. The associated algorithm detects alarm guns using markings on the weapon.

    from basegun_ml.ocr import is_alarm_weapon
    #After the import the model is already warmed-up for faster inference
    
    #Convert image to bytes
    with open("test.jpg", "rb") as file:
        image_bytes = file.read()
    
    #Prediction of the weapon typology
    alarm_model = is_alarm_weapon(image_bytes, quality_check=True )
    

    Variables description

  • alarm_model if the gun is one of the alarm model it returns "Alarm_model". If the gun has the PAK marking then alarm_model returns "PAK" else it return "Not_alarm"
  • quality_check specify if the quality analysis is run before the text detection
  • If the image quality is too low, the exception LowQuality is raised
  • If no text is detected, the exception MissingText is raised

    Tests

    Tests are available for the classification task and the measure length task

    pytest tests/test_classification.py 
    pytest tests/test_measure.py
    pytest tests/test_OCR.py
    

    Credits

  • 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

    basegun_ml-2.0.3.tar.gz (39.5 MB view details)

    Uploaded Source

    Built Distribution

    basegun_ml-2.0.3-py3-none-any.whl (39.5 MB view details)

    Uploaded Python 3

    File details

    Details for the file basegun_ml-2.0.3.tar.gz.

    File metadata

    • Download URL: basegun_ml-2.0.3.tar.gz
    • Upload date:
    • Size: 39.5 MB
    • Tags: Source
    • Uploaded using Trusted Publishing? No
    • Uploaded via: twine/5.1.1 CPython/3.12.4

    File hashes

    Hashes for basegun_ml-2.0.3.tar.gz
    Algorithm Hash digest
    SHA256 613f0db73d486f3776d9906e1d4952e90ffa9e900c7269c386b6c95624cf2709
    MD5 91d659a4f0b7fff22a870990cd300ca3
    BLAKE2b-256 82c068cadbd8d674992aca4710e4bae1908d9a5805e6cdbfed26a539b40de927

    See more details on using hashes here.

    File details

    Details for the file basegun_ml-2.0.3-py3-none-any.whl.

    File metadata

    • Download URL: basegun_ml-2.0.3-py3-none-any.whl
    • Upload date:
    • Size: 39.5 MB
    • Tags: Python 3
    • Uploaded using Trusted Publishing? No
    • Uploaded via: twine/5.1.1 CPython/3.12.4

    File hashes

    Hashes for basegun_ml-2.0.3-py3-none-any.whl
    Algorithm Hash digest
    SHA256 eba8837ab43bb1d8078a3442e87a3c9e375e3a2d79ae5dbbd89131c0fa92179c
    MD5 45ebc20e7e524f5f6e9151e397b3f23b
    BLAKE2b-256 e1bcfdc181085d3109e03a145e4019f6bfb72e0637b943a52ae3919db1a35d28

    See more details on using hashes here.

    Supported by

    AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page