Metadata-Version: 2.4
Name: pattern-discovery-kit
Version: 0.1.0
Summary: Pattern Discovery Kit
Author-email: Mansour Benbakoura <mansour.benbakoura@inria.fr>
License-Expression: BSD-3-Clause
Requires-Python: >=3.8
Description-Content-Type: text/x-rst
License-File: LICENSE
Requires-Dist: imageio
Requires-Dist: ipykernel
Requires-Dist: matplotlib
Requires-Dist: moviepy<2
Requires-Dist: numpy
Requires-Dist: osfclient
Requires-Dist: PyYAML
Requires-Dist: torch
Requires-Dist: torchaudio
Requires-Dist: torchvision
Requires-Dist: tqdm
Provides-Extra: dev
Requires-Dist: ruff; extra == "dev"
Provides-Extra: doc
Requires-Dist: sphinx; extra == "doc"
Provides-Extra: test
Requires-Dist: pytest; extra == "test"
Requires-Dist: pytest-cov; extra == "test"
Dynamic: license-file

PATtern discoveRY Kit (PATRYK)
-------------------------------

|Build Status| |Code Coverage|

Welcome to the Pattern Discovery Kit!

This library provides tools to discover, detect, and track meaningful patterns
in physical signals. These signals can be of various forms:

1. Time series,
2. Images,
3. Movies,
4. Any other type of n-dimensional data.

Installation
------------

You can install ``patryk`` from the source code by doing the following::

    git clone https://github.com/mansour-b/patryk.git
    cd patryk
    pip install .

Quickstart
----------

Here is an example to briefly present the API:

.. code:: python

    import numpy as np

    from patryk.core import Box, Frame, Model, Movie, Tracker
    from patryk.display import plot_frame

    # Define the dimensions of the problem
    frame_width = 5
    frame_height = 5
    movie_length = 3
    gif_frames_per_second = 2

    # Define a concrete model class, just for the example
    class DumbModel(Model):
        def predict(self, frame: Frame) -> Frame:
            frame_id = int(frame.name)
            frame.annotations.append(
                Box(label="noise_in_a_square", x=frame_id, y=frame_id, width=1, height=1)
            )
            return frame

    model = DumbModel()

    # Our data for this short tutorial
    frames = [
        Frame(
            name=str(10 * i),
            width=frame_width,
            height=frame_height,
            annotations=[],
            image_array=np.random.random(frame_height, frame_width),
        )
        for i in range(movie_length)
    ]

    movie = Movie(name="some_noise", frames=frames, tracks=[])

    # Run the detection model on individual frames
    analysed_frames = [model(frame) for frame in movie.frames]
    analysed_movie = Movie(
        name="some_noise_with_boxes", frames=analysed_frames, tracks=[]
    )

    # TBD: run tracker on detections
    analysed_movie = tracker.make_tracks(analysed_movie)
    analysed_movie.name = "some_noise_with_boxes_and_tracks"

    # Plot individual frames with detections
    for frame in analysed_movie:
        plot_frame(frame)

    # TBD: make a GIF to show the tracks
    export_to_gif(analysed_movie, fps=gif_frames_per_seconds)

.. |Build Status| image:: https://github.com/mansour-b/patryk/actions/workflows/pytest.yaml/badge.svg
   :target: https://github.com/mansour-b/patryk/actions/workflows/pytest.yaml

.. |Code Coverage| image:: https://codecov.io/github/mansour-b/patryk/graph/badge.svg?token=E37XYKWFWT
   :target: https://codecov.io/github/mansour-b/patryk
