streamlit-image-comparison


Namestreamlit-image-comparison JSON
Version 0.0.4 PyPI version JSON
download
home_pagehttps://github.com/fcakyon/streamlit-image-comparison
SummaryA Streamlit Component to compare images with a slider in Streamlit apps.
upload_time2023-03-14 14:25:43
maintainer
docs_urlNone
authorfcakyon
requires_python>=3.7
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <div align="center">
<h2>
    Streamlit Image Comparison Component
</h2>
</div>

<div align="center">
    <a href="https://badge.fury.io/py/streamlit-image-comparison"><img src="https://badge.fury.io/py/streamlit-image-comparison.svg" alt="pypi version"></a>
    <a href="https://pepy.tech/project/streamlit-image-comparison"><img src="https://pepy.tech/badge/streamlit-image-comparison" alt="total downloads"></a>
    <a href="https://huggingface.co/spaces/fcakyon/streamlit-image-comparison"><img src="https://raw.githubusercontent.com/fcakyon/streamlit-image-comparison/main/resources/hf_spaces_badge.svg" alt="HuggingFace Spaces"></a>
    <a href="https://twitter.com/fcakyon"><img src="https://img.shields.io/badge/twitter-fcakyon_-blue?logo=twitter&style=flat" alt="fcakyon twitter"></a>
</div>

A simple Streamlit Component to compare images with a slider in Streamlit apps using [Knightlab's JuxtaposeJS](https://juxtapose.knightlab.com/). It accepts images in any format and makes it possible to set all parameters of the JS component via Python. Live demo at [Huggingface Spaces](https://huggingface.co/spaces/fcakyon/streamlit-image-comparison)

<p align="center">
<a href='https://huggingface.co/spaces/fcakyon/streamlit-image-comparison' target='_blank'> <img src="https://user-images.githubusercontent.com/34196005/143328163-2976a3b6-91d0-47c5-b872-c92dd6ea404e.gif" width="600"></a>

</p>

## Installation
- Install via pip:

```bash
pip install streamlit
pip install streamlit-image-comparison
```

## Example

```python
# Streamlit Image-Comparison Component Example

import streamlit as st
from streamlit_image_comparison import image_comparison

# set page config
st.set_page_config(page_title="Image-Comparison Example", layout="centered")

# render image-comparison
image_comparison(
    img1="image1.jpg",
    img2="image2.jpg",
)
```

## Supported Image Formats

```python

# image path
image = "image.jpg"

# image url
image = "https://some-url.com/image.jpg"

# pil image
from PIL import Image
image = Image.open("image.jpg")

# opencv image
import cv2
image = cv2.cvtColor(cv2.imread("image.jpg"), cv2.COLOR_BGR2RGB)

# render image-comparison
image_comparison(
    img1=image,
    img2=image,
)
```

## Customization

```python
image_comparison(
    img1="image1.jpg",
    img2="image2.jpg",
    label1="text1",
    label2="text1",
    width=700,
    starting_position=50,
    show_labels=True,
    make_responsive=True,
    in_memory=True,
)
```

## Improvements

What is the difference between this repo and [robmarkcole's](https://github.com/robmarkcole/streamlit-image-juxtapose)?

- This is a pypi installable package
- This does not require the images to be saved under `site-packages/streamlit/static/`
- This accepts any type of image as input (doesn't have to be present in local)
- This can utilize all parameters of the JS component
- This has an additional dependency `sahi`

## References
- https://juxtapose.knightlab.com/
- https://github.com/robmarkcole/streamlit-image-juxtapose

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/fcakyon/streamlit-image-comparison",
    "name": "streamlit-image-comparison",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "",
    "author": "fcakyon",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/68/bf/c163952ff3ccca0672474ac96e95c2e5abee7af63b9e49c194145e68ed05/streamlit-image-comparison-0.0.4.tar.gz",
    "platform": null,
    "description": "<div align=\"center\">\n<h2>\n    Streamlit Image Comparison Component\n</h2>\n</div>\n\n<div align=\"center\">\n    <a href=\"https://badge.fury.io/py/streamlit-image-comparison\"><img src=\"https://badge.fury.io/py/streamlit-image-comparison.svg\" alt=\"pypi version\"></a>\n    <a href=\"https://pepy.tech/project/streamlit-image-comparison\"><img src=\"https://pepy.tech/badge/streamlit-image-comparison\" alt=\"total downloads\"></a>\n    <a href=\"https://huggingface.co/spaces/fcakyon/streamlit-image-comparison\"><img src=\"https://raw.githubusercontent.com/fcakyon/streamlit-image-comparison/main/resources/hf_spaces_badge.svg\" alt=\"HuggingFace Spaces\"></a>\n    <a href=\"https://twitter.com/fcakyon\"><img src=\"https://img.shields.io/badge/twitter-fcakyon_-blue?logo=twitter&style=flat\" alt=\"fcakyon twitter\"></a>\n</div>\n\nA simple Streamlit Component to compare images with a slider in Streamlit apps using [Knightlab's JuxtaposeJS](https://juxtapose.knightlab.com/). It accepts images in any format and makes it possible to set all parameters of the JS component via Python. Live demo at [Huggingface Spaces](https://huggingface.co/spaces/fcakyon/streamlit-image-comparison)\n\n<p align=\"center\">\n<a href='https://huggingface.co/spaces/fcakyon/streamlit-image-comparison' target='_blank'> <img src=\"https://user-images.githubusercontent.com/34196005/143328163-2976a3b6-91d0-47c5-b872-c92dd6ea404e.gif\" width=\"600\"></a>\n\n</p>\n\n## Installation\n- Install via pip:\n\n```bash\npip install streamlit\npip install streamlit-image-comparison\n```\n\n## Example\n\n```python\n# Streamlit Image-Comparison Component Example\n\nimport streamlit as st\nfrom streamlit_image_comparison import image_comparison\n\n# set page config\nst.set_page_config(page_title=\"Image-Comparison Example\", layout=\"centered\")\n\n# render image-comparison\nimage_comparison(\n    img1=\"image1.jpg\",\n    img2=\"image2.jpg\",\n)\n```\n\n## Supported Image Formats\n\n```python\n\n# image path\nimage = \"image.jpg\"\n\n# image url\nimage = \"https://some-url.com/image.jpg\"\n\n# pil image\nfrom PIL import Image\nimage = Image.open(\"image.jpg\")\n\n# opencv image\nimport cv2\nimage = cv2.cvtColor(cv2.imread(\"image.jpg\"), cv2.COLOR_BGR2RGB)\n\n# render image-comparison\nimage_comparison(\n    img1=image,\n    img2=image,\n)\n```\n\n## Customization\n\n```python\nimage_comparison(\n    img1=\"image1.jpg\",\n    img2=\"image2.jpg\",\n    label1=\"text1\",\n    label2=\"text1\",\n    width=700,\n    starting_position=50,\n    show_labels=True,\n    make_responsive=True,\n    in_memory=True,\n)\n```\n\n## Improvements\n\nWhat is the difference between this repo and [robmarkcole's](https://github.com/robmarkcole/streamlit-image-juxtapose)?\n\n- This is a pypi installable package\n- This does not require the images to be saved under `site-packages/streamlit/static/`\n- This accepts any type of image as input (doesn't have to be present in local)\n- This can utilize all parameters of the JS component\n- This has an additional dependency `sahi`\n\n## References\n- https://juxtapose.knightlab.com/\n- https://github.com/robmarkcole/streamlit-image-juxtapose\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A Streamlit Component to compare images with a slider in Streamlit apps.",
    "version": "0.0.4",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4beb8c1f2f32f9fb201197ae8882e084b455356222ed5d9ba0f19c789e7a549e",
                "md5": "6ae77dc6bc3ba1f0185519a1fc6c80c2",
                "sha256": "84bb4bc8c9e66fd7ab28fdcd76cf87f0f27941e7288160fb9832c9322bd1f085"
            },
            "downloads": -1,
            "filename": "streamlit_image_comparison-0.0.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6ae77dc6bc3ba1f0185519a1fc6c80c2",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 6301,
            "upload_time": "2023-03-14T14:25:42",
            "upload_time_iso_8601": "2023-03-14T14:25:42.091459Z",
            "url": "https://files.pythonhosted.org/packages/4b/eb/8c1f2f32f9fb201197ae8882e084b455356222ed5d9ba0f19c789e7a549e/streamlit_image_comparison-0.0.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "68bfc163952ff3ccca0672474ac96e95c2e5abee7af63b9e49c194145e68ed05",
                "md5": "a7e400f5c3ce70644ac7cdc6398eea40",
                "sha256": "3932875978151eb89b65a2da5ca293fc15da12a322632214d96ce0146d9154b4"
            },
            "downloads": -1,
            "filename": "streamlit-image-comparison-0.0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "a7e400f5c3ce70644ac7cdc6398eea40",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 6027,
            "upload_time": "2023-03-14T14:25:43",
            "upload_time_iso_8601": "2023-03-14T14:25:43.460134Z",
            "url": "https://files.pythonhosted.org/packages/68/bf/c163952ff3ccca0672474ac96e95c2e5abee7af63b9e49c194145e68ed05/streamlit-image-comparison-0.0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-03-14 14:25:43",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "fcakyon",
    "github_project": "streamlit-image-comparison",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "streamlit-image-comparison"
}
        
Elapsed time: 0.04386s