Python library for easily interacting with trained machine learning models
Project description
tags: [gradio-custom-component, Number] title: gradio_folium short_description: A gradio custom component colorFrom: blue colorTo: yellow sdk: gradio pinned: false app_file: space.py
gradio_folium
Python library for easily interacting with trained machine learning models
Installation
pip install gradio_folium
Usage
import gradio as gr
from gradio_folium import Folium
from folium import Map
import pandas as pd
import pathlib
df = pd.read_csv(pathlib.Path(__file__).parent / "cities.csv")
def select(df, data: gr.SelectData):
row = df.iloc[data.index[0], :]
return Map(location=[row['Latitude'], row['Longitude']])
with gr.Blocks() as demo:
gr.Markdown(("# 🗺️ Explore World Capitals with Gradio and Folium\n"
"Install this custom component with `pip install gradio_folium`"))
map = Folium(value=Map(location=[25.7617, -80.1918]))
data = gr.DataFrame(value=df)
data.select(select, data, map)
if __name__ == "__main__":
demo.launch()
Folium
Initialization
| name | type | default | description |
|---|---|---|---|
value |
typing.Any
|
None |
None |
height |
int | None
|
None |
None |
label |
str | None
|
None |
None |
container |
bool
|
True |
None |
scale |
int | None
|
None |
None |
min_width |
int | None
|
None |
None |
visible |
bool
|
True |
None |
elem_id |
str | None
|
None |
None |
elem_classes |
list[str] | str | None
|
None |
None |
render |
bool
|
True |
None |
load_fn |
typing.Optional[typing.Callable[..., typing.Any]][
typing.Callable[..., typing.Any][Ellipsis, typing.Any],
None,
]
|
None |
None |
every |
float | None
|
None |
None |
User function
The impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both).
- When used as an Input, the component only impacts the input signature of the user function.
- When used as an output, the component only impacts the return signature of the user function.
The code snippet below is accurate in cases where the component is used as both an input and an output.
- As input: Should return, the output data received by the component from the user's function in the backend.
def predict(
value: Unknown
) -> folium.folium.Map:
return value
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 gradio_folium-0.0.7-py3-none-any.whl.
File metadata
- Download URL: gradio_folium-0.0.7-py3-none-any.whl
- Upload date:
- Size: 1.1 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7f0850b151b01702ed3e6b80aa4ba62f4e7b5a207cb77816fb528f2a2f54a3e7
|
|
| MD5 |
10a5f7a990904c724e57bf0b424913e8
|
|
| BLAKE2b-256 |
44aeb6f0a44cb8dbb315e717db8f4a882cb853f89f9ef4306f201dca11ddf4a7
|