streamlit components for image annotation
Project description
Streamlit Image Annotation
Streamlit component for image annotation.
Features
- You can easily launch an image annotation tool using streamlit.
- By customizing the pre- and post-processing, you can achieve your preferred annotation workflow.
- Currently supports classification, detection, point detection tasks.
- Simple UI that is easy to navigate.
Install
pip install streamlit-image-annotation
Example Usage
If you want to see other use cases, please check inside the examples folder.
from glob import glob
import pandas as pd
import streamlit as st
from streamlit_image_annotation import classification
label_list = ['deer', 'human', 'dog', 'penguin', 'framingo', 'teddy bear']
image_path_list = glob('image/*.jpg')
if 'result_df' not in st.session_state:
st.session_state['result_df'] = pd.DataFrame.from_dict({'image': image_path_list, 'label': [0]*len(image_path_list)}).copy()
num_page = st.slider('page', 0, len(image_path_list)-1, 0)
label = classification(image_path_list[num_page],
label_list=label_list,
default_label_index=int(st.session_state['result_df'].loc[num_page, 'label']))
if label is not None and label['label'] != st.session_state['result_df'].loc[num_page, 'label']:
st.session_state['result_df'].loc[num_page, 'label'] = label_list.index(label['label'])
st.table(st.session_state['result_df'])
API
classification(
image_path: str,
label_list: List[str],
default_label_index: Optional[int] = None,
height: int = 512,
width: int = 512,
key: Optional[str] = None
)
-
image_path: Image path.
-
label_list: List of label candidates.
-
default_label_index: Initial label index.
-
height: The maximum height of the displayed image.
-
width: The maximum width of the displayed image.
-
key: An optional string to use as the unique key for the widget. Assign a key so the component is not remount every time the script is rerun.
-
Component Value: {'label': label_name}
Example: example code
detection(
image_path: str,
label_list: List[str],
bboxes: Optional[List[List[int, int, int, int]]] = None,
labels: Optional[List[int]] = None,
height: int = 512,
width: int = 512,
key: Optional[str] = None
)
-
image_path: Image path.
-
label_list: List of label candidates.
-
bboxes: Initial list of bounding boxes, where each bbox is in the format [x, y, w, h].
-
labels: List of label for each initial bbox.
-
height: The maximum height of the displayed image.
-
width: The maximum width of the displayed image.
-
key: An optional string to use as the unique key for the widget. Assign a key so the component is not remount every time the script is rerun.
-
Component Value: [{'bbox':[x,y,width, height], 'label_id': label_id, 'label': label_name},...]
Example: example code
pointdet(
image_path: str,
label_list: List[str],
points: Optional[List[List[int, int]]] = None,
labels: Optional[List[int]] = None,
height: int = 512,
width: int = 512,
key: Optional[str] = None
)
-
image_path: Image path.
-
label_list: List of label candidates.
-
points: Initial list of points, where each point is in the format [x, y].
-
labels: List of label for each initial bbox.
-
height: The maximum height of the displayed image.
-
width: The maximum width of the displayed image.
-
key: An optional string to use as the unique key for the widget. Assign a key so the component is not remount every time the script is rerun.
-
Component Value: [{'bbox':[x,y], 'label_id': label_id, 'label': label_name},...]
Example: example code
Future Work
- Addition of component for segmentation task.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for streamlit_image_annotation-0.3.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b1c753eb0c43dab2d2d3053ab4610bd2bcc071155091bbd8c41608536166692 |
|
MD5 | 55d960d92f238e64f8c7b0116da74a5a |
|
BLAKE2b-256 | eeef510c5ebc9da097320a497e6d0fe2ba9a039cf644089ffb7bd82616198c69 |
Hashes for streamlit_image_annotation-0.3.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85bf75feb3212c9057e1956e76371f03dd69acd17bb02344f7528f87c0c36d26 |
|
MD5 | a5ee532f3e6363257ced73448f2d5dfa |
|
BLAKE2b-256 | 7545f040e466e812dc45934309e9d365f2c490b3a47ae6a06fd795597bd55d52 |