holoviz / param

Param: Make your Python code clearer and more reliable by declaring Parameters
https://param.holoviz.org
BSD 3-Clause "New" or "Revised" License
423 stars 73 forks source link

Support parameters used in machine learning and AI #576

Open MarcSkovMadsen opened 2 years ago

MarcSkovMadsen commented 2 years ago

Context

I have been trying to understand why I don't see a lot of adoption of Param and Panel for Machine Learning and AI.

I have looked at Gradio that create interfaces for models. And from that I believe that some Parameters are missing from Param. Gradio takes the approach of annotating your model with input widgets. From the input widgets the parameter types are inferred. That is the opposite of what Param/ Panel does.

Summary

If I take a look at the inputs of Gradio I believe the following could be missing from param

Analysis

image

class MyModel(param.Parameterized):
    textbox = param.String()
    number = param.Number()
    slider = param.Number()
    checkbox = param.Boolean()
    checkboxgroup = param.Selector()
    radio = param.Selector()
    dropdown = param.Selector()
    image = param.Image() # Does not exist
    video = param.Video() # Does not exist
    audio = param.Audio() # Does not exist
    file = param.File() # Does not exist
    dataframe = param.DataFrame()
    timeseries = param.TimeSeries() # Does not exist

Additional Context

Panel

In Panel we are then lacking the drag and drop inputs for Image, Video, Audio and File that displays the things that is dropped onto the input.

image

Interface

I am considering how we can make it as easy and powerful to create model interfaces with Panel as it is with Gradio. One approach is to get very inspired by its interface api. Another approach would be to stick to a Param/ Panel approach but make it as easy to use as possible.

jbednar commented 2 years ago

Gradio takes the approach of annotating your model with input widgets. From the input widgets the parameter types are inferred. That is the opposite of what Param/ Panel does.

Yes, that does sound backwards; a given model might or might not need widgets, but it always has parameters, so inferring parameters from widgets seems odd.

Image Video Audio

It seems to me that Image, Video, and Audio are underspecified; there can be many such objects, with as far as I know no standard Python representation or type. But it does seem like they are useful types to support, as long as (a) they avoid adding dependencies by using inline imports like in param.DataFrame, (b) they have corresponding widgets in a library like Panel that makes it clear how they could be specified by a user, and (c) they have some usable Python type that is appropriate to work with. So to add them to Param, I'd want to see a full application using them (even if it's fairly trivial) that connects the docs and thus pins down aspects of the behavior that are otherwise unconstrained.

File

Here you're making a distinction between a file and a filename or path, given that filenames are already supported? Presumably this is a Python file object? If so, sure, particularly if an HTML file requestor can return not just the name but the underlying object.

TimeSeries

Is this a subtype of param.DataFrame where the index is known to be time? If so, that seems fine as a subclass of param.DataFrame.