gradio-app / gradio

Build and share delightful machine learning apps, all in Python. 🌟 Star to support our work!
http://www.gradio.app
Apache License 2.0
31.82k stars 2.37k forks source link

Allow users to share app + settings via a URL #2269

Open pngwn opened 1 year ago

pngwn commented 1 year ago

Is your feature request related to a problem? Please describe.
People are manually sharing prompts + settings for stable diffusion

image

Describe the solution you'd like
A way for users to easily share settings just by sharing a URL.

Some options
We could use query params to do this for the most part. Each component has a unique id so it would be easy to map the values contained within url/?1=hi&2=hi2 to the correct settings for components. The only thing we really need to think about it URL length limits which are different for different browsers but are something like 2000+ at minimum. We are unlikely to hit this for most standard inputs but anything involving media or longform text could cause issues.

We would probably need to omit media and long text from this implementation.

There other alternative is to store them in a database and generate a unique short url, we could then look up the config in the DB and send that down for a given URL, this is more complex and less responsive but we would be able to cache the whole state of the page (including media + outputs). Query params can update without reloading the page and in realtime if needed (as those inputs are changed), shorturls would need to be sent off for processing.

Concerns Query params should be pretty safe but I don't know if adding subpaths to Gradio apps would cause any issues for users, if so we could add this functionality under a shareable_links=Bool flag that be get passed to .launch()

freddyaboulton commented 1 year ago

I wonder if we can use datasets on the hub as the "Database" for this. Regardless of the implementation, we should consolidate this issue with #1452, no?

abidlabs commented 1 year ago

Yes let me close #1452 as this issue is more descriptive and suggests some possible approaches

abidlabs commented 1 year ago

I wonder if we can use datasets on the hub as the "Database" for this

That would be pretty cool, and we have most of the logic already in place via the HuggingFaceDatasetSaver class.

abidlabs commented 1 year ago

So what about the following UX:

DX:

pngwn commented 1 year ago

Coming back to this, using a database seem like a lot of effort. You would need to pass a token, so it would basically not be available on many interfaces, the user would have to go through a number of steps in order to actually share their parameters, further cluttering the UI. It is also gives us more to maintain + an external service as a dependency which we will need to keep track of (we currently have no testing in place to notify us when external services change).

Using the url would just be a simple copy/ paste, doesn't require permissions/ a token, is faster because there are no network requests involved and is simpler because the url would just be waiting to be copied with no additional steps for the user. Plus the maintenance benefits noted above.

We could allow the author of the space to fine tune what gets saved by adding save=True|False to each component, but if they default to True sharing params will be easier and more common.

abidlabs commented 1 year ago

If it's using a HF Dataset as the backend, the user of the app wouldn't have to pass in a token. Only the developer of the app would have to pass in an HF token so that a HF Dataset can be created from the Space. It wouldn't change the UI at all. I like the URL approach too for its simplicity, but the only problem is that it wouldn't work for images or any media component as you discussed above

flozi00 commented 1 year ago

The database approach needs the users trust for the developer for sensible data. For example private images which get stored on third party storages. An made by mistake public, HF dataset could share private data without agreement by data owner. Example in mind: "Hey mom, check what this AI made with our family picture"

sashavor commented 1 year ago

This would be super cool for our Stable Diffusion bias Spaces, where we would like to share Spaces with people saying something like: check out this cool result with these values and they would have the Space show those, instead of the default ones

abidlabs commented 1 year ago

@sashavor in your case, do you need to share images/audio/etc or just numerical parameters that could be encoded into a URL?

sashavor commented 1 year ago

Just the numerical parameters!

pngwn commented 2 weeks ago

2654 has some implications on this and is a pre-requisite