Skip to main content

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

PyPI - Version

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

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gradio_folium-0.0.7-py3-none-any.whl (1.1 MB view details)

Uploaded Python 3

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

Hashes for gradio_folium-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 7f0850b151b01702ed3e6b80aa4ba62f4e7b5a207cb77816fb528f2a2f54a3e7
MD5 10a5f7a990904c724e57bf0b424913e8
BLAKE2b-256 44aeb6f0a44cb8dbb315e717db8f4a882cb853f89f9ef4306f201dca11ddf4a7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page