Skip to main content

Streamlit Image Comparison Component

pypi version total downloads HuggingFace Spaces fcakyon twitter

A simple Streamlit Component to compare images with a slider in Streamlit apps using Knightlab's JuxtaposeJS. 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

Installation

  • Install via pip:
pip install streamlit
pip install streamlit-image-comparison

Example

# 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

# 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

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?

  • 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

Release files for streamlit-image-comparison 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for streamlit-image-comparison 0.0.4
File Size Uploaded
streamlit-image-comparison-0.0.4.tar.gz 6.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for streamlit-image-comparison 0.0.4
File Interpreter ABI Platform
streamlit_image_comparison-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 12.3 kB

Release files / streamlit-image-comparison-0.0.4.tar.gz

Download URL streamlit-image-comparison-0.0.4.tar.gz
Size 6.0 kB
Tags Source
SHA-256 checksum
How to use checksums
3932875978151eb89b65a2da5ca293fc15da12a322632214d96ce0146d9154b4
BLAKE2b-256 checksum
How to use checksums
68bfc163952ff3ccca0672474ac96e95c2e5abee7af63b9e49c194145e68ed05
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.2

Release files / streamlit_image_comparison-0.0.4-py3-none-any.whl

Download URL streamlit_image_comparison-0.0.4-py3-none-any.whl
Size 6.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
84bb4bc8c9e66fd7ab28fdcd76cf87f0f27941e7288160fb9832c9322bd1f085
BLAKE2b-256 checksum
How to use checksums
4beb8c1f2f32f9fb201197ae8882e084b455356222ed5d9ba0f19c789e7a549e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.2

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page