diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..d6aac91 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,38 @@ +# SPDX-FileCopyrightText: 2024 German Aerospace Center (DLR) +# +# SPDX-License-Identifier: MIT +# EditorConfig helps developers define and maintain consistent coding styles between different editors and IDEs +# editorconfig.org + +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_size = 4 +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true + +# JSON Files +[*.{json,json5,webmanifest}] +indent_size = 2 + +# YAML Files +[*.{yml,yaml,cff}] +indent_size = 2 + +# Markdown Files +[*.{md,mdx}] +trim_trailing_whitespace = false + +# TOML Files +[*.toml] +indent_size = 2 + +# License files +[/LICENSES/**] +insert_final_newline = unset +trim_trailing_whitespace = unset +indent_style = unset +indent_size = unset diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..ddb4bc9 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,4 @@ +# SPDX-FileCopyrightText: 2024 German Aerospace Center (DLR) +# +# SPDX-License-Identifier: MIT +* @juhannc diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..20c7605 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,13 @@ +# SPDX-FileCopyrightText: 2024 German Aerospace Center (DLR) +# +# SPDX-License-Identifier: MIT +# Please see the documentation for all configuration options: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + # Maintain dependencies for GitHub Actions +- package-ecosystem: github-actions + directory: / + schedule: + interval: monthly diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 0000000..0636816 --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,38 @@ +# SPDX-FileCopyrightText: 2024 German Aerospace Center (DLR) +# +# SPDX-License-Identifier: MIT +General: +- changed-files: + - any-glob-to-any-file: + - '*' + +GitHub: +- changed-files: + - any-glob-to-any-file: + - .github/** + +Workflows: +- changed-files: + - any-glob-to-any-file: + - .github/workflows/** + +Dependabot: +- changed-files: + - any-glob-to-any-file: + - .github/dependabot.yml + +Labels: +- changed-files: + - any-glob-to-any-file: + - .github/labeler.yml + - .github/workflows/labeler.yml + +v1.0.0: +- changed-files: + - any-glob-to-any-file: + - 1.0.0/* + +pre-commit: +- changed-files: + - any-glob-to-any-file: + - .pre-commit-config.yaml diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml new file mode 100644 index 0000000..dc83fa0 --- /dev/null +++ b/.github/workflows/labeler.yml @@ -0,0 +1,21 @@ +# SPDX-FileCopyrightText: 2024 German Aerospace Center (DLR) +# +# SPDX-License-Identifier: MIT +name: Pull Request Labeler + +on: + pull_request_target: + workflow_dispatch: + schedule: + - cron: 0 1 * * 1 + +jobs: + triage: + permissions: + contents: read + pull-requests: write + runs-on: ubuntu-latest + steps: + - uses: actions/labeler@v5 + with: + sync-labels: true diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 0000000..9dbddef --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,30 @@ +# SPDX-FileCopyrightText: 2024 German Aerospace Center (DLR) +# +# SPDX-License-Identifier: MIT +name: Running pre-commit (pre-commit) + +on: + push: + branches: + - main + - develop + - releases/** + pull_request: + branches: + - main + - develop + +permissions: + contents: read + +jobs: + flake8: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Python 3.11 + uses: actions/setup-python@v5 + with: + python-version: 3.11 + - name: Running pre-commit + uses: pre-commit/action@v3.0.1 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9196bdc --- /dev/null +++ b/.gitignore @@ -0,0 +1,213 @@ +# SPDX-FileCopyrightText: 2024 German Aerospace Center (DLR) +# +# SPDX-License-Identifier: MIT +# Created by https://www.toptal.com/developers/gitignore/api/python,visualstudiocode,linux +# Edit at https://www.toptal.com/developers/gitignore?templates=python,visualstudiocode,linux + +### Linux ### +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### Python ### +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ + +### Python Patch ### +# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration +poetry.toml + +# ruff +.ruff_cache/ + +# LSP config files +pyrightconfig.json + +### VisualStudioCode ### +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +!.vscode/*.code-snippets + +# Local History for Visual Studio Code +.history/ + +# Built Visual Studio Code Extensions +*.vsix + +### VisualStudioCode Patch ### +# Ignore all local history of files +.history +.ionide + +# End of https://www.toptal.com/developers/gitignore/api/python,visualstudiocode,linux diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..f1df742 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,56 @@ +# SPDX-FileCopyrightText: 2024 German Aerospace Center (DLR) +# +# SPDX-License-Identifier: MIT +# Here are some commonly used pre-commit hooks. You can find more at: +# +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.6.0 + hooks: + - id: check-case-conflict + - id: check-json + - id: check-merge-conflict + - id: check-shebang-scripts-are-executable + - id: check-toml + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace +- repo: https://github.com/fsfe/reuse-tool + rev: v4.0.3 + hooks: + - id: reuse + name: Check license headers (REUSE) +- repo: https://github.com/citation-file-format/cffconvert + rev: b6045d78aac9e02b039703b030588d54d53262ac + hooks: + - id: validate-cff + name: Validate CITATION.cff file +- repo: https://github.com/codespell-project/codespell + rev: v2.3.0 + hooks: + - id: codespell + name: Fixing common spelling mistakes + args: + - --write-changes +- repo: https://github.com/python-jsonschema/check-jsonschema + rev: 0.29.2 + hooks: + - id: check-github-workflows + name: Check GitHub Workflow configuration +- repo: https://github.com/editorconfig-checker/editorconfig-checker.python + rev: 3.0.3 + hooks: + - id: editorconfig-checker +- repo: https://github.com/igorshubovych/markdownlint-cli + rev: v0.41.0 + hooks: + - id: markdownlint + name: Fixing markdown linting errors + args: [--disable, MD013, MD033, --fix] +- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks + rev: v2.14.0 + hooks: + - id: pretty-format-yaml + args: [--autofix, --indent, '2', CITATION.cff] + - id: pretty-format-toml + args: [--autofix] diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..ef3420a --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,22 @@ +{ + "json.schemas": [ + { + "fileMatch": [ + "*/1.0.0/*/*_manifest.json" + ], + "url": "./1.0.0/manifest.schema.json" + }, + { + "fileMatch": [ + "*/1.0.0/*/*_safetynet.json" + ], + "url": "./1.0.0/safetynet.schema.json" + }, + { + "fileMatch": [ + "*/1.0.0/*/*_nnet.json" + ], + "url": "./1.0.0/nnet.schema.json" + } + ] +} diff --git a/1.0.0/manifest.schema.json b/1.0.0/manifest.schema.json new file mode 100644 index 0000000..a004ccd --- /dev/null +++ b/1.0.0/manifest.schema.json @@ -0,0 +1,454 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://gitlab.dlr.de/resilienz-ki/safetynet/schema/manifest.schema.json", + "title": "SafetyNet Manifest", + "description": "Definition of the SafetyNet manifest.", + "type": "object", + "properties": { + "version": { + "type": "string", + "description": "Version of the manifest.", + "const": "1.0.0" + }, + "description": { + "type": "string", + "description": "Description of the function of the safety network." + }, + "function": { + "type": "string", + "description": "Name of the function of the safety network." + }, + "datatype": { + "type": "string", + "description": "Datatype used for inference", + "oneOf": [ + { + "enum": [ + "int8", + "i8" + ], + "title": "8-bit (signed) integer" + }, + { + "enum": [ + "int16", + "i16" + ], + "title": "16-bit (signed) integer" + }, + { + "enum": [ + "int32", + "i32" + ], + "title": "32-bit (signed) integer" + }, + { + "enum": [ + "int64", + "i64" + ], + "title": "64-bit (signed) integer" + }, + { + "enum": [ + "uint8", + "u8" + ], + "title": "8-bit unsigned integer" + }, + { + "enum": [ + "uint16", + "u16" + ], + "title": "16-bit unsigned integer" + }, + { + "enum": [ + "uint32", + "u32" + ], + "title": "32-bit unsigned integer" + }, + { + "enum": [ + "uint64", + "u64" + ], + "title": "64-bit unsigned integer" + }, + { + "enum": [ + "float16", + "f16" + ], + "title": "16-bit floating point number" + }, + { + "enum": [ + "float32", + "f32" + ], + "title": "32-bit floating point number" + }, + { + "enum": [ + "float64", + "f64" + ], + "title": "64-bit floating point number" + } + ] + }, + "inputs": { + "type": "array", + "description": "Inputs of the safety network.", + "items": { + "$ref": "#/templates/input" + }, + "minItems": 1, + "uniqueItems": true, + "additionalProperties": false + }, + "numberOutputs": { + "type": "integer", + "description": "Number of outputs", + "minimum": 1 + }, + "networks": { + "type": "array", + "description": "Networks to be used", + "items": { + "$ref": "#/templates/network" + }, + "minItems": 1, + "uniqueItems": true, + "additionalProperties": false + }, + "luts": { + "type": "array", + "description": "Lookup tables to be used.", + "items": { + "$ref": "#/templates/lut" + }, + "minItems": 1, + "uniqueItems": true, + "additionalProperties": false + } + }, + "required": [ + "version", + "description", + "function", + "datatype", + "inputs", + "numberOutputs", + "networks", + "luts" + ], + "additionalProperties": false, + "templates": { + "input": { + "type": "object", + "properties": { + "index": { + "type": "integer", + "description": "Index of the input", + "minimum": 0 + }, + "id": { + "type": "string", + "description": "ID of the input" + }, + "name": { + "type": "string", + "description": "Name of the input" + }, + "description": { + "type": "string", + "description": "Description of the input" + }, + "minimum": { + "type": "number", + "description": "Minimum value (set either minimum or exclusiveMinimum)." + }, + "exclusiveMinimum": { + "type": "number", + "description": "Exclusive minimum value (set either minimum or exclusiveMinimum)." + }, + "maximum": { + "type": "number", + "description": "Maximum value (set either maximum or exclusiveMaximum)." + }, + "exclusiveMaximum": { + "type": "number", + "description": "Exclusive maximum value (set either maximum or exclusiveMaximum)." + }, + "unit": { + "type": "string", + "description": "Unit of the input." + }, + "ranges": { + "type": "array", + "description": "Ranges of the input.", + "items": { + "$ref": "#/templates/stridedRange" + }, + "minItems": 1, + "uniqueItems": true, + "additionalProperties": false + } + }, + "oneOf": [ + { + "required": [ + "minimum", + "maximum" + ] + }, + { + "required": [ + "exclusiveMinimum", + "maximum" + ] + }, + { + "required": [ + "minimum", + "exclusiveMaximum" + ] + }, + { + "required": [ + "exclusiveMinimum", + "exclusiveMaximum" + ] + } + ], + "required": [ + "index", + "id", + "name", + "description", + "unit", + "ranges" + ], + "additionalProperties": false + }, + "network": { + "type": "object", + "properties": { + "file": { + "type": "string", + "description": "Local filename or full path to the network." + }, + "networkFormat": { + "type": "string", + "oneOf": [ + { + "enum": [ + "nnet" + ], + "title": "Classic NNet format." + }, + { + "enum": [ + "jnet" + ], + "title": "JSON formatted NNet." + }, + { + "enum": [ + "onnx" + ], + "title": "Open Neural Network Exchange format." + }, + { + "enum": [ + "tflite" + ], + "title": "TensorFlow Lite format." + }, + { + "enum": [ + "torch" + ], + "title": "PyTorch format." + } + ] + }, + "if": { + "type": "object", + "description": "Valid input ranges for the neural network.", + "patternProperties": { + "^.*$": { + "anyOf": [ + { + "type": "number" + }, + { + "$ref": "#/templates/range" + } + ] + } + }, + "additionalProperties": false + } + }, + "required": [ + "file", + "networkFormat", + "if" + ], + "additionalProperties": false + }, + "lut": { + "type": "object", + "properties": { + "file": { + "type": "string", + "description": "Local filename or full path to the SafetyNet." + }, + "lutFormat": { + "type": "string", + "oneOf": [ + { + "enum": [ + "snet" + ], + "title": "SafetyNet format." + } + ] + }, + "if": { + "type": "object", + "description": "Valid input ranges for the SafetyNet.", + "patternProperties": { + "^.*$": { + "anyOf": [ + { + "type": "number" + }, + { + "$ref": "#/templates/range" + } + ] + } + }, + "additionalProperties": false + } + }, + "required": [ + "file", + "lutFormat", + "if" + ], + "additionalProperties": false + }, + "range": { + "type": "object", + "properties": { + "minimum": { + "type": "number", + "description": "Minimum value (set either minimum or exclusiveMinimum)." + }, + "exclusiveMinimum": { + "type": "number", + "description": "Exclusive minimum value (set either minimum or exclusiveMinimum)." + }, + "maximum": { + "type": "number", + "description": "Maximum value (set either maximum or exclusiveMaximum)." + }, + "exclusiveMaximum": { + "type": "number", + "description": "Exclusive maximum value (set either maximum or exclusiveMaximum)." + } + }, + "oneOf": [ + { + "required": [ + "minimum", + "maximum" + ] + }, + { + "required": [ + "exclusiveMinimum", + "maximum" + ] + }, + { + "required": [ + "minimum", + "exclusiveMaximum" + ] + }, + { + "required": [ + "exclusiveMinimum", + "exclusiveMaximum" + ] + } + ], + "additionalProperties": false + }, + "stridedRange": { + "type": "object", + "properties": { + "minimum": { + "type": "number", + "description": "Minimum value (set either minimum or exclusiveMinimum)." + }, + "exclusiveMinimum": { + "type": "number", + "description": "Exclusive minimum value (set either minimum or exclusiveMinimum)." + }, + "maximum": { + "type": "number", + "description": "Maximum value (set either maximum or exclusiveMaximum)." + }, + "exclusiveMaximum": { + "type": "number", + "description": "Exclusive maximum value (set either maximum or exclusiveMaximum)." + }, + "stride": { + "type": "number", + "minimum": 0, + "description": "Stride of the range. E.g. min = 3, max = 9, stride = 3 -> [3, 6, 9]; min = 3, max = 10, stride = 3 -> [3, 6, 9]" + } + }, + "oneOf": [ + { + "required": [ + "minimum", + "maximum" + ] + }, + { + "required": [ + "exclusiveMinimum", + "maximum" + ] + }, + { + "required": [ + "minimum", + "exclusiveMaximum" + ] + }, + { + "required": [ + "exclusiveMinimum", + "exclusiveMaximum" + ] + } + ], + "required": [ + "stride" + ], + "additionalProperties": false + } + } +} diff --git a/1.0.0/nnet.schema.json b/1.0.0/nnet.schema.json new file mode 100644 index 0000000..3360394 --- /dev/null +++ b/1.0.0/nnet.schema.json @@ -0,0 +1,242 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://gitlab.dlr.de/resilienz-ki/nnet/schema/nnet.schema.json", + "title": "NNet Schema", + "description": "Definition of the NNet schema from .", + "type": "object", + "properties": { + "version": { + "type": "string", + "description": "Version of the manifest.", + "const": "1.0.0" + }, + "description": { + "type": "string", + "description": "Description of the function of the nnet. This is not part of the nnet file itself, but part of the manifest." + }, + "datatype": { + "type": "string", + "description": "Datatype used for inference", + "oneOf": [ + { + "enum": [ + "int8", + "i8" + ], + "title": "8-bit (signed) integer" + }, + { + "enum": [ + "int16", + "i16" + ], + "title": "16-bit (signed) integer" + }, + { + "enum": [ + "int32", + "i32" + ], + "title": "32-bit (signed) integer" + }, + { + "enum": [ + "int64", + "i64" + ], + "title": "64-bit (signed) integer" + }, + { + "enum": [ + "uint8", + "u8" + ], + "title": "8-bit unsigned integer" + }, + { + "enum": [ + "uint16", + "u16" + ], + "title": "16-bit unsigned integer" + }, + { + "enum": [ + "uint32", + "u32" + ], + "title": "32-bit unsigned integer" + }, + { + "enum": [ + "uint64", + "u64" + ], + "title": "64-bit unsigned integer" + }, + { + "enum": [ + "float16", + "f16" + ], + "title": "16-bit floating point number" + }, + { + "enum": [ + "float32", + "f32" + ], + "title": "32-bit floating point number" + }, + { + "enum": [ + "float64", + "f64" + ], + "title": "64-bit floating point number" + } + ] + }, + "header": { + "type": "array", + "description": "Header text of the nnet file. This can be any text.", + "items": { + "type": "string" + }, + "uniqueItems": false + }, + "numberLayers": { + "type": "integer", + "description": "Number of layers", + "minimum": 1 + }, + "numberInputs": { + "type": "integer", + "description": "Number of inputs", + "minimum": 1 + }, + "numberOutputs": { + "type": "integer", + "description": "Number of outputs", + "minimum": 1 + }, + "maximumLayerSize": { + "type": "integer", + "description": "Maximum size of a layer", + "minimum": 1 + }, + "layerSizes": { + "type": "array", + "description": "Sizes of the layers", + "items": { + "type": "integer", + "minimum": 1 + }, + "minItems": 1, + "uniqueItems": false + }, + "symmetric": { + "type": "boolean", + "description": "[DEPRECATED] Whether the network is symmetric (the field is only kept for backwards compatibility).", + "default": false + }, + "inputMinimums": { + "type": "array", + "description": "Minimum values of the inputs", + "items": { + "type": "number" + }, + "minItems": 1, + "uniqueItems": false + }, + "inputMaximums": { + "type": "array", + "description": "Maximum values of the inputs", + "items": { + "type": "number" + }, + "minItems": 1, + "uniqueItems": false + }, + "inputOutputMeans": { + "type": "array", + "description": "Means of the inputs", + "items": { + "type": "number" + }, + "minItems": 1, + "uniqueItems": false + }, + "inputOutputRanges": { + "type": "array", + "description": "Ranges of the inputs", + "items": { + "type": "number" + }, + "minItems": 1, + "uniqueItems": false + }, + "layers": { + "type": "array", + "description": "Layers of the network", + "items": { + "$ref": "#/templates/layer" + }, + "minItems": 1, + "uniqueItems": false, + "additionalProperties": false + } + }, + "required": [ + "version", + "description", + "datatype", + "numberLayers", + "numberInputs", + "numberOutputs", + "maximumLayerSize", + "layerSizes", + "inputMinimums", + "inputMaximums", + "inputOutputMeans", + "inputOutputRanges", + "layers" + ], + "additionalProperties": false, + "templates": { + "layer": { + "type": "object", + "properties": { + "weights": { + "type": "array", + "description": "Weight matrix of the layer", + "items": { + "type": "array", + "description": "Single row vector of the weight matrix", + "items": { + "type": "number" + }, + "minItems": 1, + "uniqueItems": false + }, + "minItems": 1, + "uniqueItems": false + }, + "biases": { + "type": "array", + "description": "Bias vector of the layer", + "items": { + "type": "number" + }, + "minItems": 1, + "uniqueItems": false + } + }, + "required": [ + "weights", + "biases" + ], + "additionalProperties": false + } + } +} diff --git a/1.0.0/safetynet.schema.json b/1.0.0/safetynet.schema.json new file mode 100644 index 0000000..1a1029c --- /dev/null +++ b/1.0.0/safetynet.schema.json @@ -0,0 +1,361 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://gitlab.dlr.de/resilienz-ki/safetynet/schema/safetynet.schema.json", + "title": "SafetyNet Schema", + "description": "Definition of the SafetyNet schema.", + "type": "object", + "properties": { + "version": { + "type": "string", + "description": "Version of the manifest.", + "const": "1.0.0" + }, + "description": { + "type": "string", + "description": "Description of the function of the safety network." + }, + "datatype": { + "type": "string", + "description": "Datatype used for inference", + "oneOf": [ + { + "enum": [ + "int8", + "i8" + ], + "title": "8-bit (signed) integer" + }, + { + "enum": [ + "int16", + "i16" + ], + "title": "16-bit (signed) integer" + }, + { + "enum": [ + "int32", + "i32" + ], + "title": "32-bit (signed) integer" + }, + { + "enum": [ + "int64", + "i64" + ], + "title": "64-bit (signed) integer" + }, + { + "enum": [ + "uint8", + "u8" + ], + "title": "8-bit unsigned integer" + }, + { + "enum": [ + "uint16", + "u16" + ], + "title": "16-bit unsigned integer" + }, + { + "enum": [ + "uint32", + "u32" + ], + "title": "32-bit unsigned integer" + }, + { + "enum": [ + "uint64", + "u64" + ], + "title": "64-bit unsigned integer" + }, + { + "enum": [ + "float16", + "f16" + ], + "title": "16-bit floating point number" + }, + { + "enum": [ + "float32", + "f32" + ], + "title": "32-bit floating point number" + }, + { + "enum": [ + "float64", + "f64" + ], + "title": "64-bit floating point number" + } + ] + }, + "inputs": { + "type": "array", + "description": "Inputs of the safety network.", + "items": { + "$ref": "#/templates/input" + }, + "minItems": 1, + "uniqueItems": true, + "additionalProperties": false + }, + "numberOutputs": { + "type": "integer", + "description": "Number of outputs", + "minimum": 1 + }, + "data": { + "type": "array", + "description": "Data inside the lookup table", + "items": { + "$ref": "#/templates/dataRange" + }, + "minItems": 1, + "uniqueItems": true, + "additionalProperties": false + } + }, + "required": [ + "version", + "description", + "datatype", + "inputs", + "numberOutputs", + "data" + ], + "additionalProperties": false, + "templates": { + "input": { + "type": "object", + "properties": { + "index": { + "type": "integer", + "description": "Index of the input", + "minimum": 0 + }, + "id": { + "type": "string", + "description": "ID of the input" + }, + "name": { + "type": "string", + "description": "Name of the input" + }, + "description": { + "type": "string", + "description": "Description of the input" + }, + "minimum": { + "type": "number", + "description": "Minimum value (set either minimum or exclusiveMinimum)." + }, + "exclusiveMinimum": { + "type": "number", + "description": "Exclusive minimum value (set either minimum or exclusiveMinimum)." + }, + "maximum": { + "type": "number", + "description": "Maximum value (set either maximum or exclusiveMaximum)." + }, + "exclusiveMaximum": { + "type": "number", + "description": "Exclusive maximum value (set either maximum or exclusiveMaximum)." + }, + "unit": { + "type": "string", + "description": "Unit of the input." + }, + "ranges": { + "type": "array", + "description": "Ranges of the input.", + "items": { + "$ref": "#/templates/stridedRange" + }, + "minItems": 1, + "uniqueItems": true + } + }, + "oneOf": [ + { + "required": [ + "minimum", + "maximum" + ] + }, + { + "required": [ + "exclusiveMinimum", + "maximum" + ] + }, + { + "required": [ + "minimum", + "exclusiveMaximum" + ] + }, + { + "required": [ + "exclusiveMinimum", + "exclusiveMaximum" + ] + } + ], + "required": [ + "index", + "id", + "name", + "description", + "unit", + "ranges" + ], + "additionalProperties": false + }, + "stridedRange": { + "type": "object", + "properties": { + "minimum": { + "type": "number", + "description": "Minimum value (set either minimum or exclusiveMinimum)." + }, + "exclusiveMinimum": { + "type": "number", + "description": "Exclusive minimum value (set either minimum or exclusiveMinimum)." + }, + "maximum": { + "type": "number", + "description": "Maximum value (set either maximum or exclusiveMaximum)." + }, + "exclusiveMaximum": { + "type": "number", + "description": "Exclusive maximum value (set either maximum or exclusiveMaximum)." + }, + "stride": { + "type": "number", + "minimum": 0, + "description": "Stride of the range. E.g. min = 3, max = 9, stride = 3 -> [3, 6, 9]; min = 3, max = 10, stride = 3 -> [3, 6, 9]" + } + }, + "oneOf": [ + { + "required": [ + "minimum", + "maximum" + ] + }, + { + "required": [ + "exclusiveMinimum", + "maximum" + ] + }, + { + "required": [ + "minimum", + "exclusiveMaximum" + ] + }, + { + "required": [ + "exclusiveMinimum", + "exclusiveMaximum" + ] + } + ], + "required": [ + "stride" + ], + "additionalProperties": false + }, + "dataRange": { + "type": "object", + "properties": { + "inputs": { + "type": "object", + "description": "Valid input ranges for the lookup table.", + "patternProperties": { + "^.*$": { + "anyOf": [ + { + "type": "number" + }, + { + "$ref": "#/templates/range" + } + ] + } + } + }, + "outputs": { + "type": "array", + "description": "Output values of the lookup table.", + "items": { + "type": "number" + }, + "minItems": 1 + } + }, + "required": [ + "inputs", + "outputs" + ], + "additionalProperties": false + }, + "range": { + "type": "object", + "properties": { + "minimum": { + "type": "number", + "description": "Minimum value (set either minimum or exclusiveMinimum)." + }, + "exclusiveMinimum": { + "type": "number", + "description": "Exclusive minimum value (set either minimum or exclusiveMinimum)." + }, + "maximum": { + "type": "number", + "description": "Maximum value (set either maximum or exclusiveMaximum)." + }, + "exclusiveMaximum": { + "type": "number", + "description": "Exclusive maximum value (set either maximum or exclusiveMaximum)." + } + }, + "oneOf": [ + { + "required": [ + "minimum", + "maximum" + ] + }, + { + "required": [ + "exclusiveMinimum", + "maximum" + ] + }, + { + "required": [ + "minimum", + "exclusiveMaximum" + ] + }, + { + "required": [ + "exclusiveMinimum", + "exclusiveMaximum" + ] + } + ], + "additionalProperties": false + } + } +} diff --git a/CITATION.cff b/CITATION.cff new file mode 100644 index 0000000..9c57197 --- /dev/null +++ b/CITATION.cff @@ -0,0 +1,71 @@ +# SPDX-FileCopyrightText: 2024 German Aerospace Center (DLR) +# +# SPDX-License-Identifier: MIT +authors: +- affiliation: German Aerospace Center (DLR) + email: johann.christensen@dlr.de + family-names: Christensen + given-names: Johann Maximilian + name-particle: Johann + orcid: https://orcid.org/0000-0001-9871-122X +- affiliation: German Aerospace Center (DLR) + family-names: Zaeske + given-names: Wanja + orcid: https://orcid.org/0000-0002-1427-2627 +- affiliation: German Aerospace Center (DLR) + family-names: Anilkumar Girija + given-names: Akshay + orcid: https://orcid.org/0000-0002-4384-9739 +- affiliation: German Aerospace Center (DLR) + family-names: Friedrich + given-names: Sven + orcid: https://orcid.org/0009-0003-4258-8148 +- affiliation: German Aerospace Center (DLR) + family-names: Stefani + given-names: Thomas + orcid: https://orcid.org/0000-0001-7352-0590 +- affiliation: German Aerospace Center (DLR) + family-names: Durak + given-names: Umut + orcid: https://orcid.org/0000-0002-2928-1710 +- affiliation: German Aerospace Center (DLR) + family-names: Köster + given-names: Frank +- affiliation: German Aerospace Center (DLR) + family-names: Krüger + given-names: Thomas +- affiliation: German Aerospace Center (DLR) + family-names: Hallerbach + given-names: Sven +cff-version: 1.2.0 +date-released: '2024-09-01' +message: If you use this software, please cite it using the metadata from this file. +preferred-citation: + authors: + - family-names: Christensen + given-names: Johann Maximilian + - family-names: Zaeske + given-names: Wanja + - family-names: Anilkumar Girija + given-names: Akshay + - family-names: Friedrich + given-names: Sven + - family-names: Stefani + given-names: Thomas + - family-names: Durak + given-names: Umut + - family-names: Köster + given-names: Frank + - family-names: Krüger + given-names: Thomas + - family-names: Hallerbach + given-names: Sven + conference: + name: 2024 IEEE/AIAA 43st Digital Avionics Systems Conference (DASC) + date-released: '2024-09-01' + publisher: + name: IEEE + title: 'Towards Certifiable AI in Aviation: A Framework for Neural Network Assurance Using Advanced Visualization and Safety Nets' + type: conference-paper +repository-code: https://github.com/DLR-KI/safetynet.git +title: 'Towards Certifiable AI in Aviation: A Framework for Neural Network Assurance Using Advanced Visualization and Safety Nets' diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..140a99e --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,90 @@ + + +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socioeconomic status, nationality, personal appearance, race, religion, or sexual identity and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience +* Focusing on what is best not just for us as individuals, but for the overall community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or advances of any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email address, without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at . +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series of actions. + +**Consequence**: A warning with consequences for continued behavior. +No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. +This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. +No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within the community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0, available at . + +Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity). + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see the FAQ at . Translations are available at . diff --git a/LICENSES/MIT.txt b/LICENSES/MIT.txt new file mode 100644 index 0000000..2071b23 --- /dev/null +++ b/LICENSES/MIT.txt @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..c9785a4 --- /dev/null +++ b/README.md @@ -0,0 +1,23 @@ + + +# SafetyNet Manifest + +This directory contains the JSON manifests for the different components of the SafetyNet standard. + +## Citation + +If you found our work useful, please cite our paper: + +```text +@InProceedings{Christensen2024, + author = {Christensen, Johann Maximilian and Zaeske, Wanja and Anilkumar Girija, Akshay and Friedrich, Sven and Stefani, Thomas and Durak, Umut and K{\"{o}}ster, Frank and Kr{\"{u}}ger, Thomas and Hallerbach, Sven}, + booktitle = {2024 {IEEE/AIAA} 43st Digital Avionics Systems Conference ({DASC})}, + date = {2024-09}, + title = {Towards Certifiable AI in Aviation: A Framework for Neural Network Assurance Using Advanced Visualization and Safety Nets}, + publisher = {{IEEE}}, +} +``` diff --git a/REUSE.toml b/REUSE.toml new file mode 100644 index 0000000..f66250c --- /dev/null +++ b/REUSE.toml @@ -0,0 +1,15 @@ +# SPDX-FileCopyrightText: 2024 German Aerospace Center (DLR) +# +# SPDX-License-Identifier: MIT + +version = 1 + +[[annotations]] +SPDX-FileCopyrightText = "German Aerospace Center (DLR) " +SPDX-License-Identifier = "MIT" +path = "1.0.0/*.json" + +[[annotations]] +SPDX-FileCopyrightText = "German Aerospace Center (DLR) " +SPDX-License-Identifier = "MIT" +path = ".vscode/*.json"