Streamlit component that allows you to do zoom and select parts of an image.
Project description
zoom-select-image-component
Streamlit component that allows you to select parts of an image by panning and zooming.
Installation instructions
pip install zoom-select-image-component
Usage instructions
import streamlit as st
from PIL import Image
from zoom_select_image_component import zoom_select_image_component
image = Image.open('image.png')
rectangles = zoom_select_image_component(image)
The variable rectangles will contain an array of selected rectangles.
Each rectangle is a dictionary with the following keys:
left: int # number of horizontal pixels from top left corner of image to top left corner of rectangle
top: int # number of vertical pixels from top left corner of image to top left corner of rectangle
width: int # width of rectangle in pixels
height: int # height of rectangle in pixels
is_enabled: bool # whether the checkbox in the rectangle is checked or not
cropped_image: PIL.Image # the part of the image covered by this rectangle
Look at the files zoom_select_image_component/example.py and zoom_select_image_component/example_sa.py for complete
usage examples.
The latter file runs the segment anything model on the selected parts of the image.
Development instructions
Set _RELEASE = False in __init__.py.
Enter zoom_select_image_component/frontend and run npm update followed by npm run start.
In another terminal window, create a virtual environment by running python -m venv venv.
Run . venv/bin/activate and run pip install -e . to install this component as a local package.
Run streamlit run zoom_select_image_component/example.py.
Deployment instructions
Set _RELEASE = True in __init__.py.
Run npm run build in zoom_select_image_component/frontend.
Create a Python wheel by running pip wheel --no-deps -w dist . in the root directory.
Upload to pypi using python -m twine upload --repository pypi dist/*.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file zoom_select_image_component-0.0.2-py3-none-any.whl.
File metadata
- Download URL: zoom_select_image_component-0.0.2-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9b861ef6fa7e4cffc823b2f4881e91da90d8e5aa7f9349c89f85d83d1c6b9127
|
|
| MD5 |
2680f743a8233082124ce120be10945f
|
|
| BLAKE2b-256 |
ef69e2a5d9ec48dd57a19ed9e1b59c2159fae8c7483439eae74f53959b455942
|