A setup script to generate ITK Python Wheels

Overview

ITK Python Package

This project provides a setup.py script to build ITK Python binary packages and infrastructure to build ITK external module Python packages.

ITK is an open-source, cross-platform system that provides developers with an extensive suite of software tools for image analysis.

Installation

To install the ITK Python package:

    $ pip install itk

Usage

Simple example script

    import itk
    import sys

    input_filename = sys.argv[1]
    output_filename = sys.argv[2]

    image = itk.imread(input_filename)

    median = itk.median_image_filter(image, radius=2)

    itk.imwrite(median, output_filename)

See also the ITK Python Quick Start Guide. There are also many downloadable examples documented in Sphinx.

For more information on ITK's Python wrapping, an introduction is provided in the ITK Software Guide.

Comments
  • Add support for shared libraries dependencies in remote modules

    Add support for shared libraries dependencies in remote modules

    We want to package the OpenCL ICD loader in particular in dependent remote modules.

    We can build on the shared library support in 5.3rc1 for TBB.

    For the platform-specific wheel fix-up tools, auditwheel (Linux), delocate (macOS), delvewheel (Windows) we need to add support for additional shared libraries. Mostly, this should be making the scripts that expose the path to local libraries with environmental variables allow appending to that variable, then set this variable to the path to the OpenCL ICD loader library in the remote module GitHub CI configuration.

    E.g.:

    https://github.com/InsightSoftwareConsortium/ITKPythonPackage/blob/ad3f8d0c3dcb0e1b959924b4ceea8e832d612758/scripts/internal/manylinux-build-module-wheels.sh#L14

    ->

    export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/work/oneTBB-prefix/lib64
    

    For Windows:

    https://github.com/InsightSoftwareConsortium/ITKPythonPackage/blob/ad3f8d0c3dcb0e1b959924b4ceea8e832d612758/scripts/windows_build_wheels.py#L225-L228

    We may need to change this script to enable passing addition paths as a CLI argument. Also, we will likely need to adjust the strategy since delvewheel patches itk/__init__.py.

    For macOS:

    https://github.com/InsightSoftwareConsortium/ITKPythonPackage/blob/ad3f8d0c3dcb0e1b959924b4ceea8e832d612758/scripts/macpython-build-module-wheels.sh#L29

    opened by thewtex 17
  • Source path directory too long

    Source path directory too long

    When attempting to install via the pip: pip install itk

    I receive the following error:

    ITK source code directory path length is too long (${n} > 50).
    Please move the ITK source code directory to a directory with a shorter path.
    

    According to this article (https://public.kitware.com/pipermail/community/2013-December/004475.html), the check is due to Visual Studio and truncation of commands.

    Is there a way to specify the build and install directory? In addition, the build files in skbuild are fairly long as it is so I could only place the ITKPythonPackage directory in my D: drive for it to work.

    If there is not a way to specify the build and install directory, I propose this option be added and documentation be added to the front page.

    opened by addisonElliott 14
  • COMP: Ensure tbb library is built with the expected deployment target

    COMP: Ensure tbb library is built with the expected deployment target

    This commit is a follow-up of these commits:

    • a5f774ba5 (ENH: Add TBB support to Linux wheels)
    • 374c744a1 (ENH: Add macOS wheel TBB support)
    • 037a326c1 (ENH: Build macOS module wheels with TBB support)

    It ensures that oneTBB is built specifying the non-default options expected by oneTBB ^1 and it should ensure the library can be loaded on macOS >= 10.9.

    See https://discourse.itk.org/t/itk-5-3rc4-post3-failure-to-load-libtbb-library-observed-on-macos-10-13/5405/1#suggested-path-forward-3

    opened by jcfr 13
  • delocate is failing on Python files

    delocate is failing on Python files

    Interestingly, delocate-listdeps has recently started to fail when building module packages:

    +/Users/Kitware/Dashboards/ITK/ITKPythonPackage/scripts/../venvs/2.7/bin/delocate-listdeps /Users/travis/build/InsightSoftwareConsortium/ITKRingArtifact/dist/itk_ringartifact-0.1.0-cp27-cp27m-macosx_10_6_x86_64.whl /Users/travis/build/InsightSoftwareConsortium/ITKRingArtifact/dist/itk_ringartifact-0.1.0-cp34-cp34m-macosx_10_6_x86_64.whl /Users/travis/build/InsightSoftwareConsortium/ITKRingArtifact/dist/itk_ringartifact-0.1.0-cp35-cp35m-macosx_10_6_x86_64.whl /Users/travis/build/InsightSoftwareConsortium/ITKRingArtifact/dist/itk_ringartifact-0.1.0-cp36-cp36m-macosx_10_6_x86_64.whl
    /Users/travis/build/InsightSoftwareConsortium/ITKRingArtifact/dist/itk_ringartifact-0.1.0-cp27-cp27m-macosx_10_6_x86_64.whl:
    Traceback (most recent call last):
      File "/Users/Kitware/Dashboards/ITK/ITKPythonPackage/scripts/../venvs/2.7/bin/delocate-listdeps", line 61, in <module>
        main()
      File "/Users/Kitware/Dashboards/ITK/ITKPythonPackage/scripts/../venvs/2.7/bin/delocate-listdeps", line 44, in main
        lib_dict = wheel_libs(path)
      File "/Users/kitware/Dashboards/ITK/ITKPythonPackage/venvs/2.7/lib/python2.7/site-packages/delocate/libsana.py", line 161, in wheel_libs
        lib_dict = tree_libs(tmpdir, filt_func)
      File "/Users/kitware/Dashboards/ITK/ITKPythonPackage/venvs/2.7/lib/python2.7/site-packages/delocate/libsana.py", line 54, in tree_libs
        for install_name in get_install_names(depending_libpath):
      File "/Users/kitware/Dashboards/ITK/ITKPythonPackage/venvs/2.7/lib/python2.7/site-packages/delocate/tools.py", line 173, in get_install_names
        if not _line0_says_object(lines[0], filename):
      File "/Users/kitware/Dashboards/ITK/ITKPythonPackage/venvs/2.7/lib/python2.7/site-packages/delocate/tools.py", line 143, in _line0_says_object
        raise InstallNameError('Unexpected first line: ' + line0)
    delocate.tools.InstallNameError: Unexpected first line: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/objdump: '/private/var/folders/bb/n7t3rs157850byt_jfdcq9k80000gn/T/tmp_NF5m6/itk/itkFourierStripeArtifactImageFilterPython.py': The file was not recognized as a valid object file
    

    CC: @jcfr @matthew-brett

    opened by thewtex 10
  • Add support for multiple manylinux versions

    Add support for multiple manylinux versions

    Motivation for this change is to build wheels with C++ ABI compatible with Slicer built using newer g++ having _GLIBCXX_USE_CXX11_ABI defaulting to 1.

    See https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html

    Note that the latest Slicer release (5.0) is built using centos7 based ^1 environment having _GLIBCXX_USE_CXX11_ABI set to 0.

    We should likely build wheels using both manylinux2014 and manylinux_2_28.

    As of 2022.06.22, this pull-request uses 2_24, as commented ^2 by @henryiii, I will instead update dockcross ^3 to add 2_28 based image (instead of 2_24).

    References:

    • https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html
    • https://discuss.python.org/t/how-to-set-glibcxx-use-cxx11-abi-for-manylinux2014-and-manylinux2010-wheels/10551
    • https://github.com/pytorch/pytorch/issues/51039
    • https://github.com/pypa/manylinux/issues/1012
    • https://github.com/dockcross/dockcross/pull/705
    opened by jcfr 9
  • itkHelpers.py missing in itk python 5.2.0

    itkHelpers.py missing in itk python 5.2.0

    Unable to find itkHelpers.py in the installation and got python error: ModuleNotFoundError: No module named 'itkHelpers'

    itk python 5.2.0 installed via pip install itk

    opened by yliu7366 8
  • import _ITKPyBasePython failed

    import _ITKPyBasePython failed

    my Env: win10 64 bits python 3.6 itk 5.1.0

    my err: File "C:\Users\haoch\AppData\Local\Programs\Python\Python36\lib\site-packages\itk\Configuration..\ITKPyBasePython.py", line 15, in import _ITKPyBasePython ImportError: DLL load failed:

    when I use itk.imread(path),then the error occured what can I do?

    opened by xiaoxifei1223 8
  • Latest manylinux images missing `sudo`

    Latest manylinux images missing `sudo`

    Summary

    Local and CI tests in relation to https://github.com/InsightSoftwareConsortium/ITKPythonPackage/pull/233 fail to build on Linux. The issue appears to originate from the dockcross manylinux image.

    Observed behavior

    Building wheels for x64 using manylinux_2_28
    ++ type ninja
    ++ MANYLINUX_VERSION=_2_28
    ++ echo 'Building wheels for x64 using manylinux_2_28'
    + sudo ldconfig
    /opt/rh/gcc-toolset-12/root/usr/bin/sudo: line 41: /usr/bin/sudo: No such file or directory
    Error: Process completed with exit code 127.
    

    See log: https://github.com/InsightSoftwareConsortium/ITKSplitComponents/actions/runs/3583756532/jobs/6029570633

    Expected behavior

    Build succeeds.

    Steps to Reproduce

    > MANYLINUX_VERSION=_2_28
    > IMAGE_TAG=20221128-2024e4b
    
    # Generate dockcross scripts
    > docker run --rm dockcross/manylinux${MANYLINUX_VERSION}-x64:${IMAGE_TAG} > /tmp/dockcross-manylinux-x64
    > chmod u+x /tmp/dockcross-manylinux-x64
    
    # Launch container
    > /tmp/dockcross-manylinux-x64 bash
    
    # Try to run any command with sudo
    >> sudo ldconfig
    /opt/rh/gcc-toolset-12/root/usr/bin/sudo: line 41: /usr/bin/sudo: No such file or directory
    
    # Try to find sudo in /usr/bin
    >> ls /usr/bin | grep sudo
    # no results
    

    Other Notes

    Possibly related to the most recent image tag update: https://github.com/InsightSoftwareConsortium/ITKPythonPackage/pull/230

    Investigation shows that sudo works in the previous dockcross image:

    > IMAGE_TAG=20221108-102ebcc
    > docker run --rm dockcross/manylinux${MANYLINUX_VERSION}-x64:${IMAGE_TAG} > /tmp/dockcross-manylinux-x64
    > chmod u+x /tmp/dockcross-manylinux-x64
    > /tmp/dockcross-manylinux-x64 bash
    >> sudo ldconfig
    >> sudo echo "sudo works"
    sudo works
    
    opened by tbirdso 6
  • ENH: Add build script update step to download script

    ENH: Add build script update step to download script

    Several related updates:

    • Adds update step to apply build script patches to ITKPythonBuilds packages
    • Exposes manylinux parameters and resolves issue where wrong image was used with specialized tarballs
    • Reverts manylinux image tag while awaiting fix for sudo issue tracked in https://github.com/InsightSoftwareConsortium/ITKPythonPackage/issues/235 and https://github.com/dockcross/dockcross/issues/746

    These changes are tested at https://github.com/InsightSoftwareConsortium/ITKSplitComponents/actions/runs/3586129456

    opened by tbirdso 6
  • CMake version ignored

    CMake version ignored

    Despite explicitly getting CMake 3.24 in the CI, an older version is used during some stage resulting in insufficient version error:

    -- Configuring done
    -- Generating done
    -- Build files have been written to: /work/_cmake_test_compile/build
    CMake Error at CMakeLists.txt:1 (cmake_minimum_required):
      CMake 3.24 or higher is required.  You are running version 3.23.1
    
    
    -- Configuring incomplete, errors occurred!
      File "/opt/python/cp38-cp38/lib/python3.8/site-packages/skbuild/setuptools_wrap.py", line 544, in setup
        env = cmkr.configure(cmake_args,
      File "/opt/python/cp38-cp38/lib/python3.8/site-packages/skbuild/cmaker.py", line 221, in configure
        raise SKBuildError(
    An error occurred while configuring with CMake.
      Command:
    
        "cmake" "/work" "-G" "Ninja" "-DCMAKE_INSTALL_PREFIX:PATH=/work/_skbuild/linux-x86_64-3.8/cmake-install" "-DPYTHON_EXECUTABLE:FILEPATH=/opt/python/cp38-cp38/bin/python" "-DPYTHON_VERSION_STRING:STRING=3.8.13" "-DPYTHON_INCLUDE_DIR:PATH=/opt/_internal/cpython-3.8.13/include/python3.8" "-DPYTHON_LIBRARY:FILEPATH=libpython3.8.a" "-DSKBUILD:BOOL=TRUE" "-DCMAKE_MODULE_PATH:PATH=/opt/python/cp38-cp38/lib/python3.8/site-packages/skbuild/resources/cmake" "-DITK_DIR:PATH=/work/ITK-cp38-cp38-manylinux_2_28_x64" "-DITK_USE_SYSTEM_SWIG:BOOL=ON" "-DWRAP_ITK_INSTALL_COMPONENT_IDENTIFIER:STRING=PythonWheel" "-DSWIG_EXECUTABLE:FILEPATH=/work/ITK-cp38-cp38-manylinux_2_28_x64/Wrapping/Generators/SwigInterface/swig/bin/swig" "-DCMAKE_CXX_COMPILER_TARGET:STRING=x86_64-linux-gnu" "-DCMAKE_INSTALL_LIBDIR:STRING=lib" "-DBUILD_TESTING:BOOL=OFF" "-DPython3_EXECUTABLE:FILEPATH=/opt/python/cp38-cp38/bin/python" "-DPython3_INCLUDE_DIR:PATH=/opt/python/cp38-cp38/bin/../include/python3.8" "-DCMAKE_BUILD_TYPE:STRING=Release"
    

    This might be a problem in https://github.com/python-cmake-buildsystem/python-cmake-buildsystem.

    opened by dzenanz 6
  • TimeVaryingDiffeomorphisms in ITKPythonPackage

    TimeVaryingDiffeomorphisms in ITKPythonPackage

    Hello I wanted to know if the itkpythonpackage provides bindings for the deformable registration components of itk. So far i havent found this using google search.

    Thansk

    opened by cakeinspace 6
  • COMP: Consolidate Linux ARM build script

    COMP: Consolidate Linux ARM build script

    Several quality-of-life fixes and updates for ARM support:

    • Consolidates ARM module script with x86_64 module script for easier maintenance and comparison between procedures. Internal ARM script is preserved as a wrapper around generic internal build script.
    • Splits MANYLINUX_VERSION variable into MANYLINUX_VERSION prefix and TARGET_ARCH postfix to better reflect available images.
    • Uses sudo to avoid permissions failure when running docker or cleaning up files on ARM systems

    Applies changes introduced by @thewtex in https://github.com/InsightSoftwareConsortium/ITKPythonPackage/pull/234.

    Tests have passed at https://github.com/InsightSoftwareConsortium/ITKSplitComponents/actions/runs/3736106376/jobs/6340059855. Note that ARM builds on Github Actions runners are significantly slower than x86/x64 builds due to emulation. ITKSplitComponents Linux jobs previously completed in ~10 minutes and now complete in ~30 minutes with the addition of ARM wheels.

    co-authored-by: Matt McCormick [email protected]

    opened by tbirdso 9
  • fail to build release 5.2rc03 on ArchLinux

    fail to build release 5.2rc03 on ArchLinux

    Error log:

    CMake Error at Wrapping/CMakeUtilityFunctions.cmake:40 (math):
      math cannot parse the expression: ")
    
      set(ITK_WRAP_VECTOR_COMPONENTS + 1": syntax error, unexpected
      exp_CLOSEPARENT (1).
    Call Stack (most recent call first):
      Wrapping/WrapBasicTypes.cmake:55 (INCREMENT)
      Wrapping/ConfigureWrapping.cmake:131 (include)
      Wrapping/CMakeLists.txt:97 (include)
    
    
    CMake Warning (dev) at Wrapping/CMakeUtilityFunctions.cmake:40 (math):
      Unexpected character in expression at position 1: "
    
    Call Stack (most recent call first):
      Wrapping/WrapBasicTypes.cmake:63 (INCREMENT)
      Wrapping/ConfigureWrapping.cmake:131 (include)
      Wrapping/CMakeLists.txt:97 (include)
    This warning is for project developers.  Use -Wno-dev to suppress it.
    
    CMake Error at Wrapping/WrapBasicTypes.cmake:73 (message):
      ITK_WRAP_VECTOR_COMPONENTS must include ITK_WRAP_IMAGE_DIMS
    Call Stack (most recent call first):
      Wrapping/ConfigureWrapping.cmake:131 (include)
      Wrapping/CMakeLists.txt:97 (include)
    

    See the complete build log here

    opened by hubutui 20
Releases(v5.3.0)
Owner
Insight Software Consortium
Community development of the Insight Toolkit (ITK)
Insight Software Consortium
Parris, the automated infrastructure setup tool for machine learning algorithms.

README Parris, the automated infrastructure setup tool for machine learning algorithms. What Is This Tool? Parris is a tool for automating the trainin

Joseph Greene 319 Aug 2, 2022
Add-on for importing and auto setup of character creator 3 character exports.

CC3 Blender Tools An add-on for importing and automatically setting up materials for Character Creator 3 character exports. Using Blender in the Chara

null 260 Jan 5, 2023
Python code to generate art with Generative Adversarial Network

GAN_Canvas_Maker Generating Art using Generative Adversarial Network (GAN) Python code to generate art with Generative Adversarial Network: https://to

Jonny Banana 10 Aug 22, 2022
A simple python module to generate anchor (aka default/prior) boxes for object detection tasks.

PyBx WIP A simple python module to generate anchor (aka default/prior) boxes for object detection tasks. Calculated anchor boxes are returned as ndarr

thatgeeman 4 Dec 15, 2022
Generate pixel-style avatars with python.

face2pixel Generate pixel-style avatars with python. Run: Clone the project: git clone https://github.com/theodorecooper/face2pixel install requiremen

Theodore Cooper 2 May 11, 2022
Fake-user-agent-traffic-geneator - Python CLI Tool to generate fake traffic against URLs with configurable user-agents

Fake traffic generator for Gartner Demo Generate fake traffic to URLs with custo

New Relic Experimental 3 Oct 31, 2022
Python package to generate image embeddings with CLIP without PyTorch/TensorFlow

imgbeddings A Python package to generate embedding vectors from images, using OpenAI's robust CLIP model via Hugging Face transformers. These image em

Max Woolf 81 Jan 4, 2023
Python utility to generate filesystem content for Obsidian.

Security Vault Generator Quickly parse, format, and output common frameworks/content for Obsidian.md. There is a strong focus on MITRE ATT&CK because

Justin Angel 73 Dec 2, 2022
Spectrum is an AI that uses machine learning to generate Rap song lyrics

Spectrum Spectrum is an AI that uses deep learning to generate rap song lyrics. View Demo Report Bug Request Feature Open In Colab About The Project S

null 39 Dec 16, 2022
Generate saved_model, tfjs, tf-trt, EdgeTPU, CoreML, quantized tflite and .pb from .tflite.

tflite2tensorflow Generate saved_model, tfjs, tf-trt, EdgeTPU, CoreML, quantized tflite and .pb from .tflite. 1. Supported Layers No. TFLite Layer TF

Katsuya Hyodo 214 Dec 29, 2022
Generate indoor scenes with Transformers

SceneFormer: Indoor Scene Generation with Transformers Initial code release for the Sceneformer paper, contains models, train and test scripts for the

Chandan Yeshwanth 110 Dec 6, 2022
Use AI to generate a optimized stock portfolio

Use AI, Modern Portfolio Theory, and Monte Carlo simulation's to generate a optimized stock portfolio that minimizes risk while maximizing returns. Ho

Greg James 30 Dec 22, 2022
The toolkit to generate auto labeled datasets

Ozeu Ozeu is the toolkit to autolabal dataset for instance segmentation. You can generate datasets labaled with segmentation mask and bounding box fro

Xiong Jie 28 Mar 28, 2022
Fine-Tune EleutherAI GPT-Neo to Generate Netflix Movie Descriptions in Only 47 Lines of Code Using Hugginface And DeepSpeed

GPT-Neo-2.7B Fine-Tuning Example Using HuggingFace & DeepSpeed Installation cd venv/bin ./pip install -r ../../requirements.txt ./pip install deepspe

Nikita 180 Jan 5, 2023
Generate Contextual Directory Wordlist For Target Org

PathPermutor Generate Contextual Directory Wordlist For Target Org This script generates contextual wordlist for any target org based on the set of UR

null 8 Jun 23, 2021
Official PyTorch implementation of "Rapid Neural Architecture Search by Learning to Generate Graphs from Datasets" (ICLR 2021)

Rapid Neural Architecture Search by Learning to Generate Graphs from Datasets This is the official PyTorch implementation for the paper Rapid Neural A

null 48 Dec 26, 2022
PyTorch implementation of ECCV 2020 paper "Foley Music: Learning to Generate Music from Videos "

Foley Music: Learning to Generate Music from Videos This repo holds the code for the framework presented on ECCV 2020. Foley Music: Learning to Genera

Chuang Gan 30 Nov 3, 2022
Generate vibrant and detailed images using only text.

CLIP Guided Diffusion From RiversHaveWings. Generate vibrant and detailed images using only text. See captions and more generations in the Gallery See

Clay M. 401 Dec 28, 2022
Code used to generate the results appearing in "Train longer, generalize better: closing the generalization gap in large batch training of neural networks"

Train longer, generalize better - Big batch training This is a code repository used to generate the results appearing in "Train longer, generalize bet

Elad Hoffer 145 Sep 16, 2022