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
Self-Supervised Document-to-Document Similarity Ranking via Contextualized Language Models and Hierarchical Inference

Self-Supervised Document Similarity Ranking (SDR) via Contextualized Language Models and Hierarchical Inference This repo is the implementation for SD

Microsoft 36 Nov 28, 2022
A simple Python library for stochastic graphical ecological models

What is Viridicle? Viridicle is a library for simulating stochastic graphical ecological models. It implements the continuous time models described in

Theorem Engine 0 Dec 04, 2021
OpenCVのGrabCut()を利用したセマンティックセグメンテーション向けアノテーションツール(Annotation tool using GrabCut() of OpenCV. It can be used to create datasets for semantic segmentation.)

[Japanese/English] GrabCut-Annotation-Tool GrabCut-Annotation-Tool.mp4 OpenCVのGrabCut()を利用したアノテーションツールです。 セマンティックセグメンテーション向けのデータセット作成にご使用いただけます。 ※Grab

KazuhitoTakahashi 30 Nov 18, 2022
A Rao-Blackwellized Particle Filter for 6D Object Pose Tracking

PoseRBPF: A Rao-Blackwellized Particle Filter for 6D Object Pose Tracking PoseRBPF Paper Self-supervision Paper Pose Estimation Video Robot Manipulati

NVIDIA Research Projects 107 Dec 25, 2022
Text-to-Image generation

Generate vivid Images for Any (Chinese) text CogView is a pretrained (4B-param) transformer for text-to-image generation in general domain. Read our p

THUDM 1.3k Dec 29, 2022
A template repository for submitting a job to the Slurm Cluster installed at the DISI - University of Bologna

Cluster di HPC con GPU per esperimenti di calcolo (draft version 1.0) Per poter utilizzare il cluster il primo passo è abilitare l'account istituziona

20 Dec 16, 2022
Tensorflow implementation of Human-Level Control through Deep Reinforcement Learning

Human-Level Control through Deep Reinforcement Learning Tensorflow implementation of Human-Level Control through Deep Reinforcement Learning. This imp

Devsisters Corp. 2.4k Dec 26, 2022
Channel Pruning for Accelerating Very Deep Neural Networks (ICCV'17)

Channel Pruning for Accelerating Very Deep Neural Networks (ICCV'17)

Yihui He 1k Jan 03, 2023
My published benchmark for a Kaggle Simulations Competition

Lux AI Working Title Bot Please refer to the Kaggle notebook for the comment section. The comment section contains my explanation on my code structure

Tong Hui Kang 29 Aug 22, 2022
Pytorch0.4.1 codes for InsightFace

InsightFace_Pytorch Pytorch0.4.1 codes for InsightFace 1. Intro This repo is a reimplementation of Arcface(paper), or Insightface(github) For models,

1.5k Jan 01, 2023
Attempt at implementation of a simple GAN using Keras

Simple GAN This is my attempt to make a wrapper class for a GAN in keras which can be used to abstract the whole architecture process. Simple GAN Over

Deven96 7 May 23, 2019
Reporting and Visualization for Hazardous Events

Reporting and Visualization for Hazardous Events

Jv Kyle Eclarin 2 Oct 03, 2021
A weakly-supervised scene graph generation codebase. The implementation of our CVPR2021 paper ``Linguistic Structures as Weak Supervision for Visual Scene Graph Generation''

README.md shall be finished soon. WSSGG 0 Overview 1 Installation 1.1 Faster-RCNN 1.2 Language Parser 1.3 GloVe Embeddings 2 Settings 2.1 VG-GT-Graph

Keren Ye 35 Nov 20, 2022
Project page for the paper Semi-Supervised Raw-to-Raw Mapping 2021.

Project page for the paper Semi-Supervised Raw-to-Raw Mapping 2021.

Mahmoud Afifi 22 Nov 08, 2022
Face detection using deep learning.

Face Detection Docker Solution Using Faster R-CNN Dockerface is a deep learning face detector. It deploys a trained Faster R-CNN network on Caffe thro

Nataniel Ruiz 181 Dec 19, 2022
Repository for "Exploring Sparsity in Image Super-Resolution for Efficient Inference", CVPR 2021

SMSR Reposity for "Exploring Sparsity in Image Super-Resolution for Efficient Inference" [arXiv] Highlights Locate and skip redundant computation in S

Longguang Wang 225 Dec 26, 2022
Raindrop strategy for Irregular time series

Graph-Guided Network For Irregularly Sampled Multivariate Time Series Overview This repository contains processed datasets and implementation code for

Zitnik Lab @ Harvard 74 Jan 03, 2023
Anomaly detection in multi-agent trajectories: Code for training, evaluation and the OpenAI highway simulation.

Anomaly Detection in Multi-Agent Trajectories for Automated Driving This is the official project page including the paper, code, simulation, baseline

12 Dec 02, 2022
Provide baselines and evaluation metrics of the task: traffic flow prediction

Note: This repo is adpoted from https://github.com/UNIMIBInside/Smart-Mobility-Prediction. Due to technical reasons, I did not fork their code. Introd

Zhangzhi Peng 11 Nov 02, 2022
Implementation for the paper 'YOLO-ReT: Towards High Accuracy Real-time Object Detection on Edge GPUs'

YOLO-ReT This is the original implementation of the paper: YOLO-ReT: Towards High Accuracy Real-time Object Detection on Edge GPUs. Prakhar Ganesh, Ya

69 Oct 19, 2022