Skip to main content

piQture: A QML library for Image Processing

Project description

piQture: QML Library for Image Processing

Static Badge Static Badge Static Badge Coverage Status

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.0.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

piqture-0.1.0-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for piqture-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ca9f2eeb3f0a0cd77191b37faf5dd5550d8f00e59c757a22fbc6807d4ff121d4
MD5 c1d472c6305909278cce210942ea99d3
BLAKE2b-256 81f8bbd64687cfba824d998bd09fc96d08a3da62b26e9809faa16789b1841064

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for piqture-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 306dcf7b7df9630227cfbd79040ffb197c04e89f7131f85ba7a8ba27d6b3f766
MD5 03079800d1d6861c608fa8547b675b1f
BLAKE2b-256 8535f7623727b9e457cb0b8e58b707be2bfa9fd178dd91fc92e20dacb70caffa

See more details on using hashes here.

Supported by

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