Skip to main content

piQture: A QML library for Image Processing

Project description

piQture: QML Library for Image Processing

Static Badge Static Badge Coverage Status DOI

piQture is an open-source Python toolkit designed to simplify the development, execution, and training of Quantum Machine Learning (QML) models tailored for image processing tasks. This library seamlessly integrates with the Qiskit SDK, providing a convenient and user-friendly workflow for leveraging the potential of quantum computing for advanced image processing.

Getting Started

Setup

Begin by creating a new Python environment or activating an existing one for working with the piQture library. You set up a Python virtual environment venv or a Conda environment and use pip or conda to install the piQture package.

Here's how you can create a conda environment and manage a Python environment:

# Create a new conda environment
conda create -n piqture_env python=3.x

# Activate the conda environment
conda activate piqture_env

Installation

Once the Python environment is activated, the required piQture package can be installed using pip. You can install the latest version directly from PyPI.

pip install piqture

To create a development environment, and install piQture from source, you can refer to section Installation from Source.

Installation from Source

To set up a development environment and install piQture from source, follow these steps:

  1. Start by cloning the piQture repository from GitHub.
# Clone the GitHub repository.
git clone https://github.com/SaashaJoshi/piQture.git
  1. Activate the Python environment and navigate to the piQture repository directory. Then, inside the Python environment, install the required dependencies from the requirements.txt configuration file.
# Install the required dependencies
pip install -r requirements.txt
  1. Install piQture in editable mode to make changes to the source code.
# Install from source in editable mode
pip install -e .

Your development environment is set up, and piQture is installed from source. You can now start making changes to the code, running tests, and contributing to the project as a developer.

First program with piQture

Let's build a Quantum Image Representation with the Improved Novel Enhanced Quantum Representation (INEQR) encoding method.

# INEQR Encoding Method
import torch.utils.data
from piqture.data_loader.mnist_data_loader import load_mnist_dataset
from piqture.embeddings.image_embeddings.ineqr import INEQR

# Load MNIST dataset
train_dataset, test_dataset = load_mnist_dataset()

# Retrieve a single image from the dataset
image, label = train_dataset[0]
image_size = tuple(image.squeeze().size())

# Change pixel values from float to integer
pixel_vals = (image * 255).round().to(torch.uint8)
pixel_vals = pixel_vals.tolist()

embedding = INEQR(image_size, pixel_vals).ineqr()

# Display circuit.
embedding.draw()

Further examples

Let's build a Quantum Convolutional Neural Network (QCNN) with Convolutional, Pooling, and Fully-Connected layers.

from piqture.neural_networks.layers import (
    QuantumConvolutionalLayer,
    QuantumPoolingLayer2,
    FullyConnectedLayer,
)
from piqture.neural_networks import QCNN

# Initializing a QCNN circuit with given image dimensions.
image_dims = 4
qcnn_circuit = QCNN(image_dims)

# Gathering parameters for layer objects.
mera_params = {"layer_depth": 1, "mera_instance": 0, "complex_structure": False}
convolutional_params = {"mera_args": mera_params}

# Build QCNN circuit.
qcnn_circuit = qcnn_circuit.sequence(
    [
        (QuantumConvolutionalLayer, convolutional_params),
        (QuantumPoolingLayer2, {}),
        (FullyConnectedLayer, {})
    ]
)

# Display circuit.
qcnn_circuit.draw()

Contribution Guidelines

We welcome contributions! Whether you're a quantum enthusiast or a Python developer, your input is valuable. Check out our Contribution Guidelines to get started.

Authors and Citation

Saasha Joshi

License

This project is licensed under the Apache License - see the LICENSE file for details.

Acknowledgments

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

piqture-0.1.1.tar.gz (35.2 kB view details)

Uploaded Source

Built Distribution

piqture-0.1.1-py3-none-any.whl (71.7 kB view details)

Uploaded Python 3

File details

Details for the file piqture-0.1.1.tar.gz.

File metadata

  • Download URL: piqture-0.1.1.tar.gz
  • Upload date:
  • Size: 35.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for piqture-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b2d2b917c6a4251a905a9f600b47688ee4b581da4eacc3228b554ac4618578ae
MD5 e27ab2cfaa7b381da1a6f7999380f6e3
BLAKE2b-256 b25dd1bdb67571203ab26bbefc1583383265ee3996e7151cc1c90015cd73772c

See more details on using hashes here.

File details

Details for the file piqture-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: piqture-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 71.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for piqture-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1ee3ce731cf0be8476b6bdadd9d93d1ca0e5303ea40a94c8e1922b48a6375e93
MD5 7de19d81656d130579ac8e433daa1beb
BLAKE2b-256 732e9dd65e71dfe2f586ec4a01a3afaadc581f522645dcc00ce87ac9a2f54875

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page