PyDirectML is an open source Python binding library for DirectML written to facilitate DirectML sample authoring in Python. It provides the following capabilities to Python sample authors:
- Simplified DirectML graph authoring and compilation with operator composition
- Wrapper of DirectML device and resource management
- Binding support through NumPy arrays
Prerequisite: requests
python setup.py install
In a Python file, import PyDirectML
import pydirectml
DirectML Python sample code is available under the samples folder. These samples require PyDirectML, which can be built and installed to a Python executing environment.
- MobileNet: Adapted from the ONNX MobileNet model. MobileNet classifies an image into 1000 different classes. It is highly efficient in speed and size, ideal for mobile applications.
- MNIST: Adapted from the ONNX MNIST model. MNIST predicts handwritten digits using a convolution neural network.
- SqueezeNet: Based on the ONNX SqueezeNet model. SqueezeNet performs image classification trained on the ImageNet dataset. It is highly efficient and provides results with good accuracy.
- FNS-Candy: Adapted from the Windows ML Style Transfer model sample, FNS-Candy re-applies specific artistic styles on regular images.
- Super Resolution: Adapted from the ONNX Super Resolution model, Super-Res upscales and sharpens the input images to refine the details and improve image quality.
One of the most effective ways to debug Python files is through Visual Studio Code with Visual Studio Code Python extension. Follow this instruction for more details on how to debug Python code in Visual Studio Code.
If mixed-mode debugging across the Python code and the Python binding C++ code becomes necessary, Visual Studio 2019 with Python provides an excellent support in a single package. You may also want to enable debug information for the Python binding C++ code by editing the setup.cfg
file and rebuild as follow.
[build_ext]
debug=1