Getting started¶
Installation¶
GEQIE requires Python 3.10 or newer.
Quick start¶
Encode an image with FRQI, simulate the circuit, and reconstruct the image from the measurement counts:
import numpy as np
from PIL import Image
import geqie
from geqie.encodings import frqi
image = np.asarray(Image.open("assets/test_images/grayscale/test_image_4x4.png"))
circuit = geqie.encode(frqi.init_function, frqi.data_function, frqi.map_function, image)
counts = geqie.simulate(circuit, n_shots=1024)
reconstructed = geqie.retrieve(frqi.retrieve_function, counts)
The workflow always consists of the same three steps:
geqie.encodebuilds the encoding circuit from the encoding'sinit,data, andmapfunctions.geqie.simulateruns it locally with Qiskit Aer, orgeqie.executeruns it on IBM Quantum hardware.geqie.retrievereconstructs the image from the measurement counts.
Encoding parameters¶
Extra keyword arguments are forwarded to all encoding functions via encoding_params:
from geqie.encodings import neqr
circuit = geqie.encode(
neqr.init_function, neqr.data_function, neqr.map_function, image,
encoding_params={"bitrate": 4},
)
counts = geqie.simulate(circuit, n_shots=1024)
reconstructed = geqie.retrieve(neqr.retrieve_function, counts, encoding_params={"bitrate": 4})
Multidimensional and color images¶
image_dimensionality sets how many leading image axes are treated as spatial coordinates; the remaining axes (e.g. RGB channels) are left for the encoding to interpret. Grayscale encodings convert color images with ensure_grayscale (controlled by the grayscale_strategy encoding parameter).
Logging¶
Pass logging_level to any API function to inspect what GEQIE is doing. Besides the standard logging levels, GEQIE defines more verbose ones in geqie.logging_utils.levels: MATH (encoding matrices), STATE (per-pixel states and operators), and TRACE.