You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

setup.py 3.3 kB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. # Copyright 2019 Huawei Technologies Co., Ltd
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. import os
  15. import stat
  16. from setuptools import find_packages
  17. from setuptools import setup
  18. from setuptools.command.egg_info import egg_info
  19. from setuptools.command.build_py import build_py
  20. version = '0.2.0'
  21. cur_dir = os.path.dirname(os.path.realpath(__file__))
  22. pkg_dir = os.path.join(cur_dir, 'build')
  23. try:
  24. from wheel.bdist_wheel import bdist_wheel as _bdist_wheel
  25. class bdist_wheel(_bdist_wheel):
  26. def finalize_options(self):
  27. _bdist_wheel.finalize_options(self)
  28. self.root_is_pure = False
  29. except ImportError:
  30. bdist_wheel = None
  31. def write_version(file):
  32. file.write("__version__ = '{}'\n".format(version))
  33. def build_depends():
  34. """generate python file"""
  35. version_file = os.path.join(cur_dir, 'mindarmour/', 'version.py')
  36. with open(version_file, 'w') as f:
  37. write_version(f)
  38. build_depends()
  39. def update_permissions(path):
  40. """
  41. Update permissions.
  42. Args:
  43. path (str): Target directory path.
  44. """
  45. for dirpath, dirnames, filenames in os.walk(path):
  46. for dirname in dirnames:
  47. dir_fullpath = os.path.join(dirpath, dirname)
  48. os.chmod(dir_fullpath, stat.S_IREAD | stat.S_IWRITE | stat.S_IEXEC | stat.S_IRGRP | stat.S_IXGRP)
  49. for filename in filenames:
  50. file_fullpath = os.path.join(dirpath, filename)
  51. os.chmod(file_fullpath, stat.S_IREAD)
  52. class EggInfo(egg_info):
  53. """Egg info."""
  54. def run(self):
  55. super().run()
  56. egg_info_dir = os.path.join(cur_dir, 'mindarmour.egg-info')
  57. update_permissions(egg_info_dir)
  58. class BuildPy(build_py):
  59. """BuildPy."""
  60. def run(self):
  61. super().run()
  62. mindarmour_dir = os.path.join(pkg_dir, 'lib', 'mindarmour')
  63. update_permissions(mindarmour_dir)
  64. setup(
  65. name='mindarmour',
  66. version=version,
  67. author='The MindSpore Authors',
  68. author_email='contact@mindspore.cn',
  69. url='https://www.mindspore.cn/',
  70. download_url='https://gitee.com/mindspore/mindarmour/tags',
  71. project_urls={
  72. 'Sources': 'https://gitee.com/mindspore/mindarmour',
  73. 'Issue Tracker': 'https://gitee.com/mindspore/mindarmour/issues',
  74. },
  75. description="A smart AI security and trustworthy tool box.",
  76. license='Apache 2.0',
  77. packages=find_packages(),
  78. include_package_data=True,
  79. zip_safe=False,
  80. cmdclass={
  81. 'egg_info': EggInfo,
  82. 'build_py': BuildPy,
  83. 'bdist_wheel': bdist_wheel
  84. },
  85. install_requires=[
  86. 'scipy >= 1.3.3',
  87. 'numpy >= 1.17.0',
  88. 'matplotlib >= 3.1.3',
  89. 'Pillow >= 2.0.0'
  90. ],
  91. classifiers=[
  92. 'License :: OSI Approved :: Apache Software License'
  93. ]
  94. )
  95. print(find_packages())

MindArmour关注AI的安全和隐私问题。致力于增强模型的安全可信、保护用户的数据隐私。主要包含3个模块:对抗样本鲁棒性模块、Fuzz Testing模块、隐私保护与评估模块。 对抗样本鲁棒性模块 对抗样本鲁棒性模块用于评估模型对于对抗样本的鲁棒性,并提供模型增强方法用于增强模型抗对抗样本攻击的能力,提升模型鲁棒性。对抗样本鲁棒性模块包含了4个子模块:对抗样本的生成、对抗样本的检测、模型防御、攻防评估。