streamlit-fesion


Namestreamlit-fesion JSON
Version 0.5.5 PyPI version JSON
download
home_pagehttps://github.com/whitphx/streamlit-webrtc
Summary
upload_time2024-03-11 16:20:32
maintainer
docs_urlNone
authorYuichiro Tachibana (Tsuchiya)
requires_python>=3.7, !=2.7.*, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, !=3.6.*, !=3.11.*, !=3.12.*
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            streamlit-fesion
===

Streamlit component for **f**ront**e**nd computer vi**sion** processing with Wasm/Pyodide.

Sister project: [`streamlit-webrtc`](https://github.com/whitphx/streamlit-webrtc)

---

You write an image filter function in Python that receives an image frame, transforms it, and returns a processed image frame.
**`streamlit-fesion` exports it to the frontend environment and executes it with [Pyodide](https://pyodide.org/) to process the WebCam video stream.**

Look at the code below. It is a grayscale filter example.

```python
from streamlit_fesion import streamlit_fesion


def image_filter(input_image):
    import skimage

    grayscale = skimage.color.rgb2gray(input_image)
    return skimage.color.gray2rgb(grayscale)


streamlit_fesion(image_filter, [], key="fesion")
```
`image_filter()` is the filter function.
`streamlit-fesion` will call it with an input image frame of type `np.ndarray` with 3 channels (RGB-ordered), and the filter function returns a processed image frame with the same type and shape.

Note that the `image_filter()` will be sent to the frontend environment and executed there, but any other parts of the code will not.
Therefore, the packages used in the filter function must be imported inside it, like `import skimage` in the example above.

`streamlit-fesion` automatically detects the imported packages and installs them to the frontend environment at the initialization time[^1].
However, if necessary, you can explicitly pass the requirements list to the second argument of `streamlit_fesion()`, where an empty list `[]` is passed in the example above.

[^1]:[`pyodide.loadPackagesFromImports`](https://pyodide.org/en/stable/usage/api/js-api.html#pyodide.loadPackagesFromImports) is used for it.


The signature of `streamlit_fesion()` follows.
```python
streamlit_fesion(
    filter_func: Callable[[np.ndarray], np.ndarray],
    dep_packages: Optional[List[str]] = None,
    key: Optional[str] = None,
)
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/whitphx/streamlit-webrtc",
    "name": "streamlit-fesion",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7, !=2.7.*, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, !=3.6.*, !=3.11.*, !=3.12.*",
    "maintainer_email": "",
    "keywords": "",
    "author": "Yuichiro Tachibana (Tsuchiya)",
    "author_email": "t.yic.yt@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/f1/47/429e6306d44671252d6b455de4d424bc163f5f9dea8dec7a00ee3e8d13a1/streamlit_fesion-0.5.5.tar.gz",
    "platform": null,
    "description": "streamlit-fesion\n===\n\nStreamlit component for **f**ront**e**nd computer vi**sion** processing with Wasm/Pyodide.\n\nSister project: [`streamlit-webrtc`](https://github.com/whitphx/streamlit-webrtc)\n\n---\n\nYou write an image filter function in Python that receives an image frame, transforms it, and returns a processed image frame.\n**`streamlit-fesion` exports it to the frontend environment and executes it with [Pyodide](https://pyodide.org/) to process the WebCam video stream.**\n\nLook at the code below. It is a grayscale filter example.\n\n```python\nfrom streamlit_fesion import streamlit_fesion\n\n\ndef image_filter(input_image):\n    import skimage\n\n    grayscale = skimage.color.rgb2gray(input_image)\n    return skimage.color.gray2rgb(grayscale)\n\n\nstreamlit_fesion(image_filter, [], key=\"fesion\")\n```\n`image_filter()` is the filter function.\n`streamlit-fesion` will call it with an input image frame of type `np.ndarray` with 3 channels (RGB-ordered), and the filter function returns a processed image frame with the same type and shape.\n\nNote that the `image_filter()` will be sent to the frontend environment and executed there, but any other parts of the code will not.\nTherefore, the packages used in the filter function must be imported inside it, like `import skimage` in the example above.\n\n`streamlit-fesion` automatically detects the imported packages and installs them to the frontend environment at the initialization time[^1].\nHowever, if necessary, you can explicitly pass the requirements list to the second argument of `streamlit_fesion()`, where an empty list `[]` is passed in the example above.\n\n[^1]:[`pyodide.loadPackagesFromImports`](https://pyodide.org/en/stable/usage/api/js-api.html#pyodide.loadPackagesFromImports) is used for it.\n\n\nThe signature of `streamlit_fesion()` follows.\n```python\nstreamlit_fesion(\n    filter_func: Callable[[np.ndarray], np.ndarray],\n    dep_packages: Optional[List[str]] = None,\n    key: Optional[str] = None,\n)\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "",
    "version": "0.5.5",
    "project_urls": {
        "Homepage": "https://github.com/whitphx/streamlit-webrtc",
        "Repository": "https://github.com/whitphx/streamlit-webrtc"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "25bfec37c4618108c7576b4e4c185faddc4743e85b7ff1775c926ca5ddd7e534",
                "md5": "bdb8f422a9cfc4675278dfbab0642fc0",
                "sha256": "59b512e1a44b8305e265c1d77780c47692906a3c256a439f41d5251f8f7bc925"
            },
            "downloads": -1,
            "filename": "streamlit_fesion-0.5.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "bdb8f422a9cfc4675278dfbab0642fc0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7, !=2.7.*, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, !=3.6.*, !=3.11.*, !=3.12.*",
            "size": 129520,
            "upload_time": "2024-03-11T16:20:31",
            "upload_time_iso_8601": "2024-03-11T16:20:31.312944Z",
            "url": "https://files.pythonhosted.org/packages/25/bf/ec37c4618108c7576b4e4c185faddc4743e85b7ff1775c926ca5ddd7e534/streamlit_fesion-0.5.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f147429e6306d44671252d6b455de4d424bc163f5f9dea8dec7a00ee3e8d13a1",
                "md5": "120aa04e4dc2d9022860e016225fcc12",
                "sha256": "da7ebd858d83f778b9626ad6b330eb3debec2efa3008d00b0dd23fe4795345d0"
            },
            "downloads": -1,
            "filename": "streamlit_fesion-0.5.5.tar.gz",
            "has_sig": false,
            "md5_digest": "120aa04e4dc2d9022860e016225fcc12",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7, !=2.7.*, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, !=3.6.*, !=3.11.*, !=3.12.*",
            "size": 129224,
            "upload_time": "2024-03-11T16:20:32",
            "upload_time_iso_8601": "2024-03-11T16:20:32.569983Z",
            "url": "https://files.pythonhosted.org/packages/f1/47/429e6306d44671252d6b455de4d424bc163f5f9dea8dec7a00ee3e8d13a1/streamlit_fesion-0.5.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-11 16:20:32",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "whitphx",
    "github_project": "streamlit-webrtc",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "streamlit-fesion"
}
        
Elapsed time: 0.18362s