-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Breaking Changes in Gradio 4.0 #6339
Comments
This was referenced Nov 8, 2023
Closed
1 task
1 task
Hi @abidlabs Are there any alternatives to |
Hi @hieu-blackbox you can just create a wrapper function which internally calls two or more models, and then returns their values -- and similarly, you can have a list of output components. |
Closed
1 task
1 task
Closed
1 task
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Gradio 4.0 is a new major version, and includes breaking changes from 3.x. Here's a list of all the breaking changes, along with migration steps where appropriate. You can also find this information in our changelog: https://www.gradio.app/changelog
Breaking changes related to components:
**kwarg
from every component, meaning that components cannot accept arbitrary (unused) parameters. Previously, warnings would be thrown.plain
is no longer an alias forsecondary
for thevariant
argument in thegr.Button
classCarousel
class andStatusTracker
class andBox
layout classVariable
alias forState
.style()
methods from component classes.update()
method from component classes. Instead, you can now just return an instance of a component from your function. I.e. returngr.Textbox(lines=4)
instead ofgr.Textbox.update(lines=4)
get_interpretation_neighbors()
andget_interpretation_scores()
from component classesdeprecation.py
-- this was designed for internal usage so unlikely to break gradio appssource
param ingr.Audio
andgr.Video
tosources
show_edit_button
param from `gr.Audio``Other changes related to the
gradio
library:status_tracker
parameter from eventsHuggingFaceDatasetJSONSaver
classBlocks.load()
can only be use an is instance method to attach an event that runs when the page loads. To use the class method, usegr.load()
insteadInterface.load()
has been removedgr.load
a Space that is running Gradio 3.x. However, you can still use the client libraries (see changes to the client libraries below).enable_queue
fromlaunch()
gr.Series
andgr.Parallel
api_name=None
, the api name is the name of the python function.Changes related to the Client libraries:
gr.Chatbot
,gr.Label
, andgr.JSON
), the data would get saved to a file and the filepath would be returned. Similarly, you would have to pass input JSON as a filepath. Now, the JSON data is passed and returned directly, making it easier to work with these components using the clients.Migrating to Gradio 4.0
Here are some concrete tips to help migrate to Gradio 4.0:
allowed_paths
Since the working directory is now not served by default, if you reference local files within your CSS or in a
gr.HTML
component using the/file=
route, you will need to explicitly allow access to those files (or their parent directories) using theallowed_paths
parameter inlaunch()
For example, if your code looks like this:
In order for the HTML component to be able to serve
image.png
, you will need to addimage.png
inallowed_paths
like this:or if you want to expose all files in your working directory as was the case in Gradio 3.x (not recommended if you plan to share your app with others), you could do:
concurrency_limit
instead ofconcurrency_count
Previously, in Gradio 3.x, there was a single global
concurrency_count
parameter that controlled how many threads could execute tasks from the queue simultaneously. By defaultconcurrency_count
was 1, which meant that only a single event could be executed at a time (to avoid OOM errors when working with prediction functions that utilized a large amount of memory or GPU usage). You could bypass the queue by settingqueue=False
.In Gradio 4.0, the
concurrency_count
parameter has been removed. You can still control the number of total threads by using themax_threads
parameter. The default value of this parameter is40
, but you don't have worry (as much) about OOM errors, because even though there are 40 threads, we use a single-worker-single-event model, which means each worker thread only executes a specific function. So effectively, each function has its own "concurrency count" of 1. If you'd like to change this behavior, you can do so by setting a parameterconcurrency_limit
, which is now a parameter of each event, not a global parameter. By default this is1
for each event, but you can set it to a higher value, or toNone
if you'd like to allow an arbitrary number of executions of this event simultaneously. Events can also be grouped together using theconcurrency_id
parameter so that they share the same limit, and by default, events that call the same function share the sameconcurrency_id
.To summarize migration:
concurrency_limit=None
in Gradio 4.0. (Previously you would setqueue=False
.)X
executions of this function at a time, you should setconcurrency_limit=X
parameter in the event trigger.(Previously you would set a globalconcurrency_count=X
.)The text was updated successfully, but these errors were encountered: