What's New in Gradio 4.0?

What's New in Gradio 4.0?

Introduction and Welcome

The speaker welcomes everyone to the Gradio 4.0 launch event and expresses gratitude for their presence. They introduce themselves as Abu Bakr Abid, the leader of the Gradio team at Hugging Face. The purpose of the event is to discuss recent developments in Gradio.

Recent Developments in Gradio

  • The Gradio team has observed how the community has been using Gradio to build incredible applications.
  • Based on user feedback and usage patterns, they have incorporated new features into Gradio.
  • The speaker and colleagues will share these features during the event.

Audience Proficiency with Gradio

  • The speaker asks if attendees are new to Gradio or already proficient with it.
  • Attendees can indicate their proficiency level in the chat.
  • A mix of proficiency levels is observed among attendees.

Historic Moment in Machine Learning Usage

The speaker discusses how machine learning usage has reached a historic moment, paralleling the development of personal computers. They highlight the accessibility of machine learning models through demos and GUIs.

Accessibility of Machine Learning

  • In the past, building machine learning models was niche and targeted towards other ML engineers and scientists.
  • With advancements like Hugging Face's Transformers library, software engineers without ML expertise can now use ML models.
  • Recently, anyone with a browser can access state-of-the-art ML models through demos and GUIs.

Importance of Machine Learning Demos

The speaker explains why machine learning demos are important, emphasizing their role in increasing accessibility, exposing biases in models, and driving interesting developments.

Significance of Machine Learning Demos

  • Machine learning demos make ML accessible to individuals regardless of their background or experience.
  • They help identify hidden biases in ML models when tested with diverse examples.
  • By making models accessible, improvements can be made to address biases and weaknesses.
  • Machine learning demos have led to interesting developments, although increased scrutiny and regulation are also observed.

Conclusion

The speaker concludes the introduction by summarizing the importance of machine learning demos in increasing accessibility, exposing biases, and driving development.

Key Takeaways

  • Machine learning demos increase accessibility for users regardless of their ML expertise.
  • They uncover biases and weaknesses in models when exposed to diverse examples.
  • Machine learning demos have driven interesting developments but also face increased scrutiny and regulation.

The Importance of User Experience in AI Models

In this section, the speaker discusses the importance of capturing user preferences and needs when developing AI models.

User Satisfaction and Consistency in Generated Images

  • The speaker gives an example of a trending demo called the "latent consistency model" on Hugging Face.
  • This model generates images that are stylistically and character-wise consistent from one to another.
  • While it may be challenging to capture user satisfaction quantitatively, it is crucial to consider their preferences.
  • Users who want to use AI-generated images for comic books or visual graphics value consistency in the generated graphics.

Aligning Machine Learning Research with User Interests

  • By allowing users to try out models through demos, developers can understand what users are interested in.
  • This helps align machine learning research with user needs and preferences.
  • At Gradio and Hugging Face, they emphasize the importance of demos or "spaces" as one of the pillars of machine learning.

Simplifying Demo Building Process with Gradio

This section focuses on simplifying the process of building demos for machine learning models using Gradio.

Challenges in Building Demos

  • Many individuals who want to build demos for their ML models face challenges such as having to learn Flask, Docker, JavaScript, CSS, etc.
  • The complexity involved in wrapping ML models into web or mobile apps can discourage developers from showcasing their work.

Introducing Gradio: Easy Demo Creation

  • Gradio was developed to make it easy for anyone to create a GUI (Graphical User Interface) for their ML model using just a few lines of Python code.
  • The core class in Gradio is called the "interface class," which takes three inputs: function, input components, and output components.
  • Input components refer to built-in features like text boxes, galleries, charts, and data frames provided by Gradio.
  • By defining the function and input/output components, a GUI is automatically created for the ML model.

Simplified Deployment with Gradio

  • With one additional command, "gradio.Interface.launch(share=True)," a queuing system is created to handle incoming requests.
  • Adding "share=True" generates a public link where anyone can try out the ML model while it runs locally on the developer's computer.
  • This eliminates the need for web hosting or server setup and allows easy sharing of demos with colleagues, collaborators, or others.

Success and Adoption of Gradio

This section highlights the success and adoption of Gradio as a tool for building and launching ML applications.

Impressive Statistics

  • Gradio was released in 2019 and has gained significant traction since then.
  • Currently, there are over 50,000 unique monthly active developers using Gradio.
  • More than 15 million Gradio apps have been built and launched by users worldwide.

Examples of Complex Applications Built with Gradio

  • The speaker mentions an example called "automatic1111 repo," which showcases a very complex GUI built using Gradio.
  • This demonstrates that even highly sophisticated applications can be developed using Gradio's capabilities.
  • Hugging Face Spaces also provides a platform for deploying Gradio applications with additional social features for discussion and sharing outputs.

Timestamps may not align perfectly due to differences in transcription.

Principles for Gradio 4.0

The speaker introduces two broad principles that will guide the conversation throughout the presentation. These principles aim to provide more control and customization options for users of Gradio.

Exposing More Control to Users

  • The Gradio team acknowledges that they cannot anticipate all the use cases and customizations users may want.
  • In response, they have decided to expose more control to users in Gradio 4.0.
  • This will allow users to customize Gradio apps in ways that were not possible before.

Building Custom Components

  • Gradio comes with built-in components, but if users need something beyond those components, they can now build custom components in Gradio 4.0.
  • Custom components offer flexibility and enable users to create interfaces tailored to their specific needs.

Robust Foundation and Best Practices

  • While encouraging customization, the Gradio team also ensures that the built-in components are a solid foundation for web app development.
  • They have integrated best practices, including accessibility features, into these components.

Topics Covered in the Presentation

The speaker outlines four main topics that will be covered in the presentation regarding Gradio 4.0: custom components, media components redesign, accessibility improvements, server-side events, and custom share servers.

Custom Components

  • Users can now build their own custom input and output components for machine learning models.
  • Examples include an image comparison slider and a 3D molecule viewer.

Media Components Redesign

  • Media components have been redesigned from scratch in Gradio 4.0.
  • This redesign aims to enhance user experience when working with media inputs and outputs.

Accessibility Improvements

  • The speaker briefly mentions that accessibility features have been incorporated into the Gradio components.
  • More details will be provided later in the presentation.

Server-side Events

  • The concept of server-side events will be discussed, offering an interesting feature for Gradio users.

Custom Share Servers

  • The speaker mentions the introduction of custom share servers in Gradio 4.0.
  • Unfortunately, due to time constraints, these topics may not be covered extensively in the presentation.

Introduction to Custom Components

The speaker introduces custom components as a response to the increasing demand for bespoke interfaces and specific visualizations in Gradio.

Limitless Customization with Custom Components

  • Users can now build custom input and output components for their machine learning models.
  • This allows for limitless customization within certain bounds defined by Gradio.

Example: Image Comparison Slider

  • An example of a custom component is an image comparison slider.
  • Users can drag and drop two images, upload them to the Gradio server, and compare them side by side.
  • This component was not available in the core Gradio components but demonstrates how custom components can seamlessly integrate with existing ones.

Example: 3D Molecule Viewer

  • Another example is a 3D molecule viewer built as a custom component by a user named Simoner during pre-release testing.
  • This complex visualization tool showcases the potential of custom components to create unique and specialized interfaces.

Conclusion

The presentation introduces two principles guiding Gradio 4.0 development: exposing more control to users and enabling customization through custom components. Four main topics are covered: custom components, media component redesign, accessibility improvements, server-side events, and custom share servers. The concept of building custom input and output components is explained with examples such as an image comparison slider and a 3D molecule viewer.

[t=0:17:29] Gradio 4.0 Launch Event

This section introduces the Gradio 4.0 launch event and highlights the achievements of the Gradio team at Hugging Face in building a community around their application.

Introduction to Gradio and Community Building

  • The Gradio team at Hugging Face is excited to share their progress and achievements with the community.
  • The community has been incredible in using Gradio for various applications.
  • The team will discuss how people are using Gradio and share some interesting examples.

Historic Moment in Machine Learning Usage

  • Machine learning usage has reached a historic moment, similar to the rise of personal computers.
  • Previously, using machine learning models was niche, but now anyone can access and use them through tools like Transformers library.
  • Machine learning demos have become popular as they allow users to try out state-of-the-art models without needing expertise in building them.

Importance of Machine Learning Demos

  • Machine learning demos increase accessibility by allowing anyone to try out models regardless of their experience level.
  • They help identify biases or offensive outputs that may arise from trained models.
  • Demos also provide valuable insights for researchers by understanding user preferences and needs.

Introducing Gradio for Building ML Demos

  • Gradio simplifies the process of building machine learning demos without requiring extensive knowledge of web development technologies like Flask, JavaScript, or CSS.
  • It provides core classes and interfaces for defining input and output functions for machine learning models.
  • Built-in components such as text boxes, charts, and data inputs make it easy to create interactive demos.

Easy Deployment with Gradio

  • Deploying machine learning demos with Gradio is straightforward, as it handles incoming requests and can handle multiple simultaneous users.
  • By setting share=True, others can try out your demo locally on their computers without the need for web hosting or server costs.
  • Gradio has gained popularity, with over 50,000 users and millions of complex web applications built using the platform.

Collaboration with Hugging Face Spaces

  • Gradio is an extension system that integrates with Hugging Face Spaces, providing additional features and social interaction for demos.
  • Users can deploy their demos for free and receive feedback and engagement from others.

[t=0:59] Understanding User Adoption of Gradio

This section discusses the user adoption of Gradio and how it has been used in various contexts.

User Engagement on LinkedIn

  • The discussion is mirrored on both LinkedIn and the chat platform, allowing participants to comment and engage in both spaces.

Diverse User Proficiency

  • Users of Gradio have varying levels of proficiency, ranging from beginners to experts.
  • The community consists of a mix of individuals with different backgrounds and skill sets.

Showcasing Use Cases

  • The team shares examples of how people are using Gradio in different domains.
  • They highlight the versatility and wide range of applications that can be built using Gradio.

[t=1:37] Importance of Machine Learning Demos

This section emphasizes the importance of machine learning demos in academia and industry.

Increased Accessibility to State-of-the-Art Models

  • Machine learning demos make it possible for anyone to access state-of-the-art models without needing expertise in building them.
  • This accessibility has led to increased usage in academia as well as other industries.

Shifting Focus to User Needs

  • Machine learning demos help shift the focus from quantitative benchmarks to understanding user preferences and needs.
  • They provide valuable insights into what users find useful or interesting beyond traditional metrics.

[t=2:30] Evolution of Machine Learning Model Usage

This section discusses the evolution of machine learning model usage over time.

From Niche to Mainstream

  • Machine learning model usage has transitioned from being niche and limited to a few experts to becoming mainstream.
  • Previously, models were built for specific purposes, but now there is a shift towards making them accessible for broader use.

Rise of Transformers Library

  • The introduction of the Transformers library around five or six years ago enabled engineers without machine learning backgrounds to start using models.
  • This accessibility has led to the widespread adoption of machine learning models in various applications.

[t=3:12] Benefits of Machine Learning Demos

This section highlights the benefits of machine learning demos and their impact on users and researchers.

Enabling User Interaction with Models

  • Machine learning demos allow users to interact with models and explore their capabilities.
  • Users can try out different inputs and understand how the model responds, providing valuable insights for both users and researchers.

Identifying Biases and Offensive Outputs

  • Demos help identify biases or offensive outputs that may arise from trained models.
  • Users can provide feedback on problematic outputs, leading to improvements in model performance.

Shifting Research Focus

  • Machine learning demos refocus researchers on understanding user needs rather than solely relying on quantitative benchmarks.
  • User feedback provides qualitative insights that complement traditional metrics.

[t=4:14] Importance of Gradio for Building ML Demos

This section emphasizes the importance of Gradio as a tool for building machine learning demos easily.

Simplified Demo Creation Process

  • Gradio simplifies the process of building machine learning demos by eliminating the need to learn web development technologies like Flask, JavaScript, or CSS.
  • With just a few lines of code, users can define input and output functions for their models using Gradio's core classes and interfaces.

Built-in Components for Interactivity

  • Gradio provides built-in components such as text boxes, charts, and data inputs, making it easy to create interactive demos.
  • Users can leverage these components without the need for additional coding or customization.

Easy Deployment and Scalability

  • Gradio handles incoming requests and can handle multiple simultaneous users, making deployment and scalability effortless.
  • By setting share=True, others can try out demos locally without the need for web hosting or server costs.

[t=5:24] Impact of Gradio on User Adoption

This section discusses the impact of Gradio on user adoption and showcases trending demos.

Increased Accessibility to ML Models

  • Gradio has made machine learning models more accessible to a wider audience, leading to increased user adoption.
  • Users with varying levels of experience can now easily try out models and explore their capabilities.

User Feedback and Engagement

  • Demos built using Gradio receive feedback and engagement from users, providing valuable insights for developers.
  • Trending demos like "latent" demonstrate the popularity and impact of Gradio in generating consistent images.

[t=6:42] Building ML Demos with Gradio

This section provides an overview of how to build machine learning demos using Gradio.

Simplified Demo Creation Process

  • Gradio simplifies the process of building machine learning demos by eliminating the need for extensive web development knowledge.
  • Users can define input and output functions for their models using just a few lines of code with Gradio's core classes.

Deploying Demos with Ease

  • Deploying machine learning demos with Gradio is straightforward, as it handles incoming requests and supports many simultaneous users.
  • Setting share=True allows others to try out demos locally without requiring web hosting or server costs.

Collaboration with Hugging Face Spaces

  • Integration with Hugging Face Spaces provides additional features and social interaction for machine learning demos built using Gradio.
  • Users can deploy their demos for free and receive feedback and engagement from the community.

[t=7:50] Conclusion

This section concludes the Gradio 4.0 launch event and expresses gratitude to the developers and participants.

Acknowledgment

  • The team expresses gratitude to Ali Abdullah, the developer of Gradio, for his contributions.
  • They thank all the developers and participants for their support and engagement in building a vibrant community around Gradio.

Custom Components Overview

In this section, the speaker introduces the concept of custom components in Gradio and explains their importance. They discuss the use of keyword arguments to define data structures, pre and post-process methods, and examples for custom components.

Introduction to Custom Components

  • Custom components allow users to create their own interactive interfaces in Gradio.
  • Keyword arguments can be used to define the data structure that users receive in their function.
  • Pre and post-process methods are frequently used in custom components.
  • Examples are optional but can enhance the user experience by providing custom examples for rendering.

Creating Examples for Custom Components

  • Every component has an example component associated with it.
  • Users can provide a custom example component that receives the example being set.
  • Examples can be rendered differently based on the component's requirements.
  • Examples also receive all keyword arguments provided to the component.

Building a Custom Component

  • The process of building a custom component is explained by Freddy.
  • The main way to create custom components is through the command-line interface (CLI) tool called "gradio CC".
  • The first step is to create the scaffolding of the project using the "create" command.
  • Freddy demonstrates building a custom component for displaying map data using Folium library.

Creating a Custom Component with Gradio CC

Freddy explains how to create a custom component using Gradio CC command-line interface. He demonstrates creating a directory structure, installing dependencies, and configuring backend and frontend code.

Using Gradio CC Command-Line Interface

  • Gradio CC is a CLI tool for creating custom components in Gradio.
  • Use "gradio CC help" command to see available commands.

Creating Scaffolding for Custom Component

  • Use "gradio CC create" command followed by desired name to create scaffolding for the custom component.
  • The command creates a directory with backend and frontend code, demo files, and a TOML configuration file.
  • The TOML file is used to configure the project and list dependencies.

Backend and Frontend Code

  • Backend code is implemented in a Python file with the same name as the custom component.
  • Frontend code is located in the frontend folder of the project.

Demo and Project Configuration

  • The demo folder contains files to showcase and test the custom component.
  • The TOML configuration file allows specifying package name, version number, and dependencies.

Conclusion

The transcript provides an overview of custom components in Gradio, explaining their importance and how to create them using Gradio CC. It covers topics such as keyword arguments, pre and post-process methods, examples, creating scaffolding for custom components, configuring backend and frontend code, and showcasing demos.

Defining Events for Your Component

In this section, the speaker discusses defining events for a component.

Events for Components

  • Define events for your component to add functionality and interactivity.
  • Events allow users to interact with the component and trigger specific actions.
  • Examples of events include button clicks, form submissions, or any other user input.

Publishing Components with Gradio

This section covers the process of publishing components using Gradio.

Publishing with Gradio

  • Use the publish command in Gradio to easily share your component.
  • The publish command guides you through the process of sharing your component.
  • You can upload your component to Pipi and Hugging Face Spaces simultaneously.
  • To upload to Pipi, you need a Pipi account. Follow the provided link to create one.
  • After providing your credentials, Gradio uploads your component to Pipi.
  • You can also upload a demo to Hugging Face Spaces. By default, it uses the locally created demo directory.
  • Choose whether or not to share your source code so others can view and modify it on Hugging Face.

Media Components - Video, Image, and Audio

This section introduces media components in Gradio - video, image, and audio.

Video Component Updates

  • The video component now includes functionality to trim videos by selecting a specific portion.
  • Users can upload a video file and select a segment for running predictions or revert back to the original state.
  • Source selection has been added, allowing users to choose between uploading a file or using their webcam as input.

Image Component Updates

  • The image component has been refreshed with changes made to the source selection.
  • Users can now upload an image file, capture via webcam, or copy and paste into the component.

Audio Component Updates

  • The audio component now includes a waveform view for visualizing the audio.
  • Users can trim, edit, and change the playback speed of audio files.
  • Source selection options include uploading a file or capturing via microphone.

Accessibility and Bug Fixes

This section highlights accessibility improvements and bug fixes in Gradio's media components.

Accessibility Enhancements

  • Media components are now navigable using keyboard controls for improved accessibility.
  • Users can trim videos using handles on either side without relying on a mouse.

Bug Fixes and Improvements

  • Several bug fixes have been implemented for media components to enhance their functionality.
  • Improved accessibility and user experience (UX).
  • Additional features include copying images from clipboard into the image component and supporting multiple sources.

The summary has been provided based on the available transcript.

Fine Grain Control over Queue Workers

In this section, the speaker discusses the need for finer control over queue workers in order to optimize performance and prevent blocking of requests.

Controlling Number of Workers

  • Previously, there was limited control over the number of workers in a shared queue.
  • This could lead to issues where heavy processing requests would block other quick requests.
  • The new approach allows specifying the number of workers dedicated to each task/event listener.
  • For example, a machine learning model may have a maximum of two threads working at once, while file system tasks may have up to 10 workers.

Per Event Listener Control

  • With the new system, it is possible to set the number of workers per event listener.
  • This prevents one heavy event from blocking other events in the queue.
  • Fine-grained control over worker allocation improves overall flow and queue management.

Custom Share Servers

This section introduces custom share servers in Gradio 4.0, allowing users to set up their own domain for sharing Gradio apps.

How Share Links Work

  • Previously, Gradio provided public links for sharing demos by running locally on a server and using fast reverse proxy.
  • The public link exposed the local port on a public server with an IP address that forwarded requests back and forth between users and the local machine.

Introducing Custom Share Servers

  • In Gradio 4.0, users can now set up their own share servers on their own domains.
  • This means that instead of using Gradio's share server, users can use their own domain (e.g., mygptrapper.com) as a share server.
  • The code for Gradio's share server has been open-sourced so that users can customize it according to their needs.

Benefits of Custom Share Servers

  • Setting up a custom share server allows users to have full control over the code and remove any time limitations.
  • Instructions are provided on how to set up a custom share server, giving users more flexibility in sharing their Gradio applications.

The transcript is already in English, so there is no need to respond in another language.

New Section

The speaker discusses the task of creating a comprehensive and informative markdown file from a given transcript. The goal is to structure the markdown file in a clear and concise manner, utilizing timestamps when available to aid in studying the transcript.

Creating Comprehensive Markdown Notes

  • Use bullet points to summarize key points and insights from the transcript.
  • Each bullet point should be linked to the corresponding timestamp in the video using format.
  • Ensure that each section has no more than 4 bullet points, with each bullet point containing no more than 25 words.
  • Organize notes using subheadings and bullet points for clarity.
  • Follow the chronological order of the transcript and avoid mixing sections.

Remember to adhere to these formatting tips while summarizing the content accurately and succinctly.

Video description

Join us as we launch Gradio 4.0, discuss new features (such as building custom components in your Gradio apps), as well as answer questions