Brief IA

Gradio: gr.Workflow Turns Every Flow into an API and Deploys on Spaces

🔬 Research·Tom Levy·

Gradio: gr.Workflow Turns Every Flow into an API and Deploys on Spaces

Gradio: gr.Workflow Turns Every Flow into an API and Deploys on Spaces
Key Takeaways
1gr.Workflow allows the creation of AI pipelines as typed node graphs
2Each flow becomes a REST API and can be deployed with a single command on Hugging Face Spaces
3The nodes cover Python, models, Spaces, datasets, with possible GPU execution
4Public demos illustrate image editing, multimedia, generative art, and data analysis
💡Why it mattersGradio simplifies the creation, execution, and deployment of AI workflows, making these tools accessible without complex development.
Le brief IA que lisent les pros

Le brief IA que les pros lisent chaque soir

Les 7 actus IA du jour, décryptées en 5 min. Gratuit.

Inclus dès l'inscription : notre sélection des meilleurs guides & comparatifs IA.

Choisis ton rythme

Gratuit · Pas de spam · Désabonnement en 1 clic

📄
Full Analysis

Gradio introduces gr.Workflow, a pipeline system described as typed node graphs, executable step-by-step with visible intermediate results. Each workflow automatically becomes a REST API and can be deployed with a single command on Hugging Face Spaces. The nodes cover Python functions, models via Inference Providers, other Spaces, and dataset lines. Public demos and on-the-fly GPU support complete the offering.

Call and Deploy Live: REST Endpoints and Spaces

Each constructed workflow also becomes an API, with no extra work required, and each output exposes a REST endpoint named after its label. These endpoints can be called from Python using the Gradio client, as in the example targeting “ysharma/gr-workflow-multi-endpoint-API” without a token, addressing paths such as /word_count or /fahrenheit. When the endpoint invokes a model or a Space, the execution occurs under a Hugging Face token, which must be provided when creating the client, as seen in “ysharma/gr-workflow-image-editor.” A call can thus transmit an image file and an instruction, for example, handle_file("dog.jpg") with "turn it into a snowy winter scene" to /edited_image. The same graph can be deployed with a single command on Hugging Face Spaces, and the quickest way to get started is to open a demo, duplicate it, and rewire.

What Connects the Nodes: Inputs, Operators, and Outputs

A workflow is structured into three types of nodes: references for inputs, operators for processing, and subjects for outputs. An operator can be a Python function, a model via Hugging Face Inference Providers, another Gradio Space, or a line from a dataset in the Hub. Links are created by dragging between typed ports, and then the user triggers execution using a button, with each result displayed in the designated location. The steps take the form of a graph made up of typed nodes on a drag-and-drop interface, with each node being executable and each intermediate result displayed; in Gradio, the pipeline thus serves as the interface.

Run Your Own Model on GPU On Demand

A node of type fn is Python and can execute a model on GPU directly within a Space. By decorating the linked function with @spaces.GPU, the execution of the node triggers ZeroGPU, which allocates a GPU for the call, executes the model, and then releases the resource. This capability avoids the need to consistently rely on existing Inference Providers or Spaces.

Four Public Demos Illustrate Processing Chains

Several demonstrations are available as live Hugging Face Spaces, open for execution and duplication. An image editor allows users to upload a photo, specify a modification, and retrieve the modified version; it relies on a single node calling Qwen-Image-Edit via Inference Providers. An AI Multimedia Studio brings together three pipelines: image generation with FLUX, transformation into a sticker via a background removal Space, voiceover from the same subject with a text-to-speech Space, and production of an episode title via an LLM. A Generative Art Lab transforms an idea into a base FLUX image, two reinterpretations (soft watercolor and cyberpunk neon), and a gallery title written by an LLM. Finally, a Data Detective takes a dataset ID (for example, stanfordnlp/imdb or mteb/tweet_sentiment_extraction), distributes it into four operator nodes, and analyzes the dataset live via the Datasets Server API.

Getting Started and Going Further: Guide, Minimal Model, and Suite

A minimal example in Python links a function to gr.Workflow and then launches the application. An official guide presents the types of operators, the JSON schema, and reusable templates. According to Gradio, it is possible to build an application as complex as AUTOMATIC1111 with gr.Workflow. A forthcoming article is announced to detail this construction step-by-step, with a preview shown.

Brief IA — L'actualité IA en français

L'essentiel de l'actualité de l'intelligence artificielle, décrypté et expliqué chaque jour.