gradio: š Community Feedback on Blocks
This issue is a place for the community to try Blocks š§± and give feedback on its development
What is Blocks?
Blocks allows you to build web-based demos in a flexible way using the gradio
library. Blocks is a more low-level and flexible alternative to the core Interface
class. Specifically, Blocks support:
- grouping together related demos using Tabs
- flexible positioning of components using Columns, Rows, etc. and the ability to add explanatory Markdown or Text at any point
- flexible data flows (e.g. any number of input and output components can be displayed on screen, and functions can define data flow between any subset of inputs and outputs)
- flexible event triggers (e.g. button clicks, element changes, etc.)
Hereās an example Block:
If youāve used Gradio before, youāll find that Blocks still allows you to build web apps:
- entirely in Python
- using the standard Python interpreter, which means it will run in Jupyter notebooks, colab notebooks, or any Python IDE
Getting Started with Blocks
- Blocks is just released with Gradio 3.0. Check here for the announcement.
- To use it, please install the latest release of Gradio:
pip install gradio
- TODO: Add [Blocks Introduction Guide Link]
You can also use Blocks in Spaces! See an example here.
Giving feedback: In the comments below, weād love to hear from you:
- Did Blocks allow you to build something cool? Share a screenshot or a link to a Blocks Demo!
- Does Blocks not support your use case? Let us know too so that we can support it!
- Did you find anything confusing or hard within the syntax or usage of Blocks? Letās improve it together!
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 28
- Comments: 36 (10 by maintainers)
I have tried out blocks now and have a few pieces of feedback. I found it easy to use and was able to make my desired layout quickly with one button outputting to multiple tabs with different views. Building an interface with rows/columns is intuitive to me, very HTML-like. I prefer the control compared to the previous āmagicā of the standard interface. I think this new UI type will be useful for multi-step processes and for making more app-like complex demos. Having this as a more advanced option is perfect, with the standard Gradio UI as default.
Areas to improve:
Have there been any discussions about an interface list as opposed to the context manager/blocks solution?
I think this sort of thing reads a bit better. It would sacrifice āsharedā components from the blocks, but it would make it easier to define inputs/outputs via the shortcuts as opposed to having to define each input class instance explicitly.
I found having to do 2 nested
with
s to be not so intuitive. This is just one opinion from one person though!The
blocks
syntax reminds me of the column/row management experience in streamlit, which I find for the most part to be confusing, and I see most folks (non-power users) just not using it - and if they do, the code is hard to read imho.At the end of the day, if the point/driving force behind this feature is to allow folks to have more than one interface in one hosted gradio app, I think we should make it as easy as possible to do just that.
Would really love some other community members to weigh in on this, so we can see what they think. š
Hi @abidlabs and team: 2 quick questions on using Parallel and Series with Blocks. Iāve deployed a new demo on Spaces so itāll be easier to see what I mean: https://huggingface.co/spaces/chinhon/headlines_blocks_parallel_series
For Parallel:
For Parallel and Series:
Overall, Iād say Blocks still works for me mostly as an organisatonal tool to put similar apps together. Iāve tried out a few version using blocks to combine different inputs and processing functions, but found myself bogged down with unnecessary complexities after a while - which detracts from the main draw of Gradio, in my view.
But thatās just me/my use case. Others might have better use cases for the other features.
Iām not sure if I am understanding blocks the right way, but what I feel users want is a way to dinamically load the different inputs from others. For example if you want to have 2 functionalities in the interface you can just put a gr.input.Radio and then depending and what you have clickedā¦ load other gr.input components.
In my case I would also love to see some way to reload individual components like in this case (see the image) . Iāve selected the class Staff and when I submit, I would love to be able to reload the component without the option Staff. Beware I am using Gradio as an input for different configurations to execute a model.
If you have any doubt about my use case you can reply me. Thank you for reading!
PS: I would like also to be able to locate examples above the options and change the text āExamplesā to -> āDefault settingsā or any other text.
Every theme will have a light and dark mode. This will be toggleable by the user but, by default, respect system preferences.
So in this case you would just select (
theme=peach
) and both light and dark variants of that theme will be available to users of the app.Thanks for the feedback @Lastly and @prakharrathi25! I have created an issue around the step-gating / visibility issue that you guys have mentioned: #784
Great question @brenden-connors! We are still working on themes with
Blocks
. We are planning on launching with adefault
and adark
theme next week, but then adding more themes over time. Right now, you wonāt find themes working correctly, but eventually something likegr.Blocks(theme="dark-peach")
should work! cc @pngwn @gary149@nateraw thanks for the feedback! letās continue the conversation on https://github.com/gradio-app/gradio/issues/640
Built a
block
that can convert text to either audio or an image, depending on userās choice.Demo
Code
Feedback A few issues I faced with this and other demos:
Interface
? https://github.com/gradio-app/gradio/issues/731live=True
behavior? Documented by @abidlabs in https://github.com/gradio-app/gradio/issues/723gr.outputs.<etc>
as an input to something https://github.com/gradio-app/gradio/issues/736