Skip to main content

TrojAI Integration Package

TrojAI provides the troj Python convenience package to allow users to integrate TrojAI adversarial protections and robustness metrics seamlessly into their AI development pipelines.

Installation

Run the following to install:

pip install troj["dev"]
pip install troj["nlp"]
pip install troj["cv"]

Usage

The troj package has support for Image Classification and Object Detection tasks. The notebooks in the demos folder contain examples to get set up on either task using PyTorch or TensorFlow (limited support for now). The test_troj.py file also contains our tests that run on deployment and could also be helpful for understanding our API better.

One more thing is that our package expects specific data formats for now until we can support more formats. The two formats are described by the following:

'''
ImageNet folder style (Image Classification): 
/train
----/class1
----/class2
...
/test
----/class1
----/class2
...etc 

CoCo annotation style (Object Detection):
/images
----image1.jpg
----image2.jpg
...etc
annotation.json

'''

Examples

Example notebooks for many use cases are contained in the demos folder. If there are errors in the notebook, cross reference the syntax with test_troj.py, the tests will always contain the most updated working version of our packages and the notebooks may lag a bit.

Command Line Tool

Troj package use via command line is currently in development. After package install the command line tool can be accessed through the command "troj" which currently takes two arguments, an attacking config file and a user config file to authenticate with our AWS infrastructure. The command line files can be found under trojai/cmd. If you want to run the NLP demo we currently have setup, try out the following command:

 troj --c "trojai\cmd\example.json" --a "trojai\cmd\user-config.json"

How to develop locally (MOSTLY INTERNAL ONLY)

Here are three commands to run after cloning the repo to install the cloned version to your environment (changes in code will be reflected immediately if using this).

pip install wheel
python setup.py bdist_wheel
pip install -e.[dev]

How to build and upload to pypi (INTERNAL ONLY)

Build the package under dist folder using this, will create tar.gz and .whl for version id in setup.py:

python -m build

Upload it to testpypi repo using this (remove --repository flag to go live, make sure dist only has the files you expect):

Dev Package:
    python -m twine upload --repository testpypi dist/*
prod package:
    python -m twine upload dist/*

When install from testpypi repo you need this format: pip install --extra-index-url https://test.pypi.org/simple/ package_name_here https://stackoverflow.com/questions/51589673/pip-install-producing-could-not-find-a-version-that-satisfies-the-requirement - otherwise dependency packages wont be looked for on live pypi

Metadata

Release files for troj 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for troj 1.0.0
File Size Uploaded Provenance Actions
troj-1.0.0.tar.gz 58.6 kB Without provenance Details for troj-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for troj 1.0.0
File Interpreter ABI Platform Actions
troj-1.0.0-py3-none-any.whl Python 3 none any Details for troj-1.0.0-py3-none-any.whl

Total release size: 131.6 kB

Release files / troj-1.0.0.tar.gz

Download URL troj-1.0.0.tar.gz
Size 58.6 kB
Tags Source
SHA-256 checksum
How to use checksums
4b6b3478ef2b198fd8e28fc5501c0013b91d5b7cf148ddf3e1bd34c089460d5e
BLAKE2b-256 checksum
How to use checksums
7df23221c3cad616e61edcc5c0012d9fd2765dbce06ef6523ecac6d4159ce399
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.0 importlib_metadata/3.10.1 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.10

Release files / troj-1.0.0-py3-none-any.whl

Download URL troj-1.0.0-py3-none-any.whl
Size 73.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
67c9f8b1b9d435a4af44181704265e3718724722871104fe0ca5ee6e9fa9cccf
BLAKE2b-256 checksum
How to use checksums
4e06f5e8eb837172068508c0428370b77cef82fb9de38110c70a94e5d3f864a6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.0 importlib_metadata/3.10.1 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.10

Security for troj 1.0.0

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.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page