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
Metadata
Release files for gradio-folium 0.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| gradio_folium-0.0.7-py3-none-any.whl | Python 3 | none | any | Details |
Release files / gradio_folium-0.0.7-py3-none-any.whl
| Download URL | gradio_folium-0.0.7-py3-none-any.whl |
|---|---|
| Size | 1.1 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7f0850b151b01702ed3e6b80aa4ba62f4e7b5a207cb77816fb528f2a2f54a3e7
|
|
BLAKE2b-256 checksum How to use checksums |
44aeb6f0a44cb8dbb315e717db8f4a882cb853f89f9ef4306f201dca11ddf4a7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.8
|