streamlit-overlay


Namestreamlit-overlay JSON
Version 0.0.1 PyPI version JSON
download
home_pageNone
SummaryStreamlit component that allows you add overlays to images
upload_time2024-08-05 09:17:24
maintainerNone
docs_urlNone
authorJens Rahnfeld
requires_python>=3.8
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <div align="center">
    <h2>
        Streamlit-Overlay 🖼️🖌️
    </h2>
    <p><b>👌 Simplify adding overlays to images in Streamlit </b></p>
    <img src="https://github.com/JensRahnfeld/streamlit-overlay/blob/main/assets/streamlit-overlay.gif">
</div>

## Installation

```
pip install streamlit-overlay
```

## Quick Start

In your `app.py` insert the following lines of code.

```python
from streamlit_overlay import overlay

images = ... # np.narray of shape (#frames, height, width, 3)
masks = ... # np.array of shape (#frames, height, width, 3)
overlay(images, masks, key="example_overlay")
```

Running your app via

```
streamlit run app.py
```

will then render a customizable video demo.

## API

### `streamlit_overlay.overlay(images, masks=[], alpha=0.5, key=None, toggle_label="Display Overlay", fps=30, autoplay=False)`

Creates an instance of the "overlay" component for use in a Streamlit app. It allows for the overlaying of masks on images, with customizable options for transparency, display controls, and playback settings.

<b>Parameters</b>

- `images`: np.ndarray or List[Image]

  The images to display. This can be a single image or a sequence of images (for video). The shape should be (height, width, 3) for a single image or (num_frames, height, width, 3) for a sequence.

- `masks`: np.ndarray or List[Image], optional

  The masks to overlay on the images. This should match the shape of the images parameter. If not provided, the function will only display the images.

- `alpha`: float, optional

  The transparency level for the mask overlay. A value of 0 means the mask is fully transparent, while 1 means it is fully opaque.

- `key`: str or None, optional

  An optional key that uniquely identifies this component. If this is
  None, and the component's arguments are changed, the component will
  be re-mounted in the Streamlit frontend and lose its current state.

- `toggle_label`: str, optional

  The label for the toggle button that controls the visibility of the overlay.

- `fps`: int, optional
  Frames per second for displaying a video.

- `autoplay`: bool, optional

  Whether to automatically start playing the video upon loading. This setting is only relevant if images and masks represent a sequence of frames.

### `streamlit_overlay.heatmap_overlay(images, masks, colormap=cv2.COLORMAP_JET, toggle_label="Display Heatmap", *args, **kwargs)`

Creates an instance of the "heatmap_overlay" component for overlaying heatmaps, e.g. of attribution maps, over images within a Streamlit app. This component processes the provided masks by applying a colormap, enhancing the visualization of data overlays.

<b>Parameters</b>

- `images`: np.ndarray or List[Image]

  The images to display. This can be a single image or a sequence of images (for video). The shape should be (height, width, 3) for a single image or (num_frames, height, width, 3) for a sequence.

- `masks`: np.ndarray or List[Image], optional

  The masks to overlay on the images. The shape should be (height, width) for a single mask or (num_frames, height, width) for a sequence. These masks will be processed using the specified colormap.

- `colormap`: int, optional

  The OpenCV colormap identifier to use for applying color to the masks. This allows for a more vivid and informative visualization of the mask data.

- `toggle_label`: str, optional

  The label for the toggle button that controls the visibility of the overlay.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "streamlit-overlay",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "Jens Rahnfeld",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/d7/18/d22be1e2c420614e2fc300dd53e2d643998f2d0fed1aa0ef97cfa338b233/streamlit_overlay-0.0.1.tar.gz",
    "platform": null,
    "description": "<div align=\"center\">\r\n    <h2>\r\n        Streamlit-Overlay \ud83d\uddbc\ufe0f\ud83d\udd8c\ufe0f\r\n    </h2>\r\n    <p><b>\ud83d\udc4c Simplify adding overlays to images in Streamlit </b></p>\r\n    <img src=\"https://github.com/JensRahnfeld/streamlit-overlay/blob/main/assets/streamlit-overlay.gif\">\r\n</div>\r\n\r\n## Installation\r\n\r\n```\r\npip install streamlit-overlay\r\n```\r\n\r\n## Quick Start\r\n\r\nIn your `app.py` insert the following lines of code.\r\n\r\n```python\r\nfrom streamlit_overlay import overlay\r\n\r\nimages = ... # np.narray of shape (#frames, height, width, 3)\r\nmasks = ... # np.array of shape (#frames, height, width, 3)\r\noverlay(images, masks, key=\"example_overlay\")\r\n```\r\n\r\nRunning your app via\r\n\r\n```\r\nstreamlit run app.py\r\n```\r\n\r\nwill then render a customizable video demo.\r\n\r\n## API\r\n\r\n### `streamlit_overlay.overlay(images, masks=[], alpha=0.5, key=None, toggle_label=\"Display Overlay\", fps=30, autoplay=False)`\r\n\r\nCreates an instance of the \"overlay\" component for use in a Streamlit app. It allows for the overlaying of masks on images, with customizable options for transparency, display controls, and playback settings.\r\n\r\n<b>Parameters</b>\r\n\r\n- `images`: np.ndarray or List[Image]\r\n\r\n  The images to display. This can be a single image or a sequence of images (for video). The shape should be (height, width, 3) for a single image or (num_frames, height, width, 3) for a sequence.\r\n\r\n- `masks`: np.ndarray or List[Image], optional\r\n\r\n  The masks to overlay on the images. This should match the shape of the images parameter. If not provided, the function will only display the images.\r\n\r\n- `alpha`: float, optional\r\n\r\n  The transparency level for the mask overlay. A value of 0 means the mask is fully transparent, while 1 means it is fully opaque.\r\n\r\n- `key`: str or None, optional\r\n\r\n  An optional key that uniquely identifies this component. If this is\r\n  None, and the component's arguments are changed, the component will\r\n  be re-mounted in the Streamlit frontend and lose its current state.\r\n\r\n- `toggle_label`: str, optional\r\n\r\n  The label for the toggle button that controls the visibility of the overlay.\r\n\r\n- `fps`: int, optional\r\n  Frames per second for displaying a video.\r\n\r\n- `autoplay`: bool, optional\r\n\r\n  Whether to automatically start playing the video upon loading. This setting is only relevant if images and masks represent a sequence of frames.\r\n\r\n### `streamlit_overlay.heatmap_overlay(images, masks, colormap=cv2.COLORMAP_JET, toggle_label=\"Display Heatmap\", *args, **kwargs)`\r\n\r\nCreates an instance of the \"heatmap_overlay\" component for overlaying heatmaps, e.g. of attribution maps, over images within a Streamlit app. This component processes the provided masks by applying a colormap, enhancing the visualization of data overlays.\r\n\r\n<b>Parameters</b>\r\n\r\n- `images`: np.ndarray or List[Image]\r\n\r\n  The images to display. This can be a single image or a sequence of images (for video). The shape should be (height, width, 3) for a single image or (num_frames, height, width, 3) for a sequence.\r\n\r\n- `masks`: np.ndarray or List[Image], optional\r\n\r\n  The masks to overlay on the images. The shape should be (height, width) for a single mask or (num_frames, height, width) for a sequence. These masks will be processed using the specified colormap.\r\n\r\n- `colormap`: int, optional\r\n\r\n  The OpenCV colormap identifier to use for applying color to the masks. This allows for a more vivid and informative visualization of the mask data.\r\n\r\n- `toggle_label`: str, optional\r\n\r\n  The label for the toggle button that controls the visibility of the overlay.\r\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Streamlit component that allows you add overlays to images",
    "version": "0.0.1",
    "project_urls": {
        "Homepage": "https://github.com/JensRahnfeld/streamlit-overlay",
        "Issues": "https://github.com/JensRahnfeld/streamlit-overlay/issues"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "799fc905329c41d99f52c27447034f414cc2a318d5ee3debaada0a4c62b812d5",
                "md5": "ca02a6751e98dbd26d2ddfb78b990b19",
                "sha256": "86906386b74a88728034b8a81e6833def9a177cc379f0a28b1fc386201b3ab99"
            },
            "downloads": -1,
            "filename": "streamlit_overlay-0.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ca02a6751e98dbd26d2ddfb78b990b19",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 124536,
            "upload_time": "2024-08-05T09:17:22",
            "upload_time_iso_8601": "2024-08-05T09:17:22.499319Z",
            "url": "https://files.pythonhosted.org/packages/79/9f/c905329c41d99f52c27447034f414cc2a318d5ee3debaada0a4c62b812d5/streamlit_overlay-0.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d718d22be1e2c420614e2fc300dd53e2d643998f2d0fed1aa0ef97cfa338b233",
                "md5": "b9e256c9e368cdd1325e0fe9f574bf99",
                "sha256": "d41c65e600943e41a04d3932b8f480332f0d243cbf7344a6218dcd4ab7c207a0"
            },
            "downloads": -1,
            "filename": "streamlit_overlay-0.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "b9e256c9e368cdd1325e0fe9f574bf99",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 125197,
            "upload_time": "2024-08-05T09:17:24",
            "upload_time_iso_8601": "2024-08-05T09:17:24.789578Z",
            "url": "https://files.pythonhosted.org/packages/d7/18/d22be1e2c420614e2fc300dd53e2d643998f2d0fed1aa0ef97cfa338b233/streamlit_overlay-0.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-05 09:17:24",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "JensRahnfeld",
    "github_project": "streamlit-overlay",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "streamlit-overlay"
}
        
Elapsed time: 0.32206s