Abstract
Accessibility is a major challenge of machine learning (ML). Typical ML models are built by specialists and require specialized hardware/software as well as ML experience to validate. This makes it challenging for non-technical collaborators and endpoint users (e.g. physicians) to easily provide feedback on model development and to gain trust in ML. The accessibility challenge also makes collaboration more difficult and limits the ML researcher's exposure to realistic data and scenarios that occur in the wild. To improve accessibility and facilitate collaboration, we developed an open-source Python package, Gradio, which allows researchers to rapidly generate a visual interface for their ML models. Gradio makes accessing any ML model as easy as sharing a URL. Our development of Gradio is informed by interviews with a number of machine learning researchers who participate in interdisciplinary collaborations. Their feedback identified that Gradio should support a variety of interfaces and frameworks, allow for easy sharing of the interface, allow for input manipulation and interactive inference by the domain expert, as well as allow embedding the interface in iPython notebooks. We developed these features and carried out a case study to understand Gradio's usefulness and usability in the setting of a machine learning collaboration between a researcher and a cardiologist.
Introduction
Machine learning (ML) development often occurs in isolation. Researchers typically build models using static, curated datasets on specialized hardware. Meanwhile, the domain experts intended to use these tools—such as physicians, physicists, or artists—are often excluded from the development process due to technical barriers. This "accessibility gap" results in a lack of trust in "black box" models, failures when models encounter "wild" uncurated data (domain shift), and poor feedback loops that prevent experts from identifying edge cases.
The Gradio Framework
To bridge this gap, we introduced Gradio, an open-source Python package that enables the rapid creation of visual interfaces for ML models. The core of the library is the Interface object, which allows developers to wrap models from frameworks like Keras, PyTorch, or Scikit-Learn with just a few lines of code.
As shown in the figure above, the workflow is streamlined:
- Definition: Specify input types (e.g., image, audio), output types (e.g., label), and the model function.
- Deployment: A single
launch()command generates a local web interface. - Sharing: Gradio can create a public URL via an SSH tunnel, allowing remote collaborators to access the model without local installation.
- Interaction: Built-in tools allow users to manipulate data (like cropping or adding noise) to test model robustness.
Case Study: Pacemaker Detection
We validated Gradio through a pilot study involving a collaboration between an ML researcher and a cardiologist. The goal was to develop a model to detect pacemakers in echocardiogram (ultrasound) videos. While the model achieved a high initial Area Under the Curve (AUC) of 0.93 on a private dataset, the cardiologist's interactive testing revealed critical insights.
Using Gradio's interactive tools, the expert acted as an "adversarial" tester. For instance, by using occlusion tools to hide the pacemaker, he could verify if the model's prediction changed appropriately. This real-time probing led to the discovery that flipping ultrasound images vertically significantly degraded accuracy—a specific vulnerability that standard validation metrics had missed.
Key Insights and Results
The study highlighted several qualitative and quantitative benefits. Beyond the technical discovery of model weaknesses, the researchers observed a psychological shift in the collaborators.
- Rapid Deployment: The researcher set up a shareable interface for a complex ultrasound model in approximately 10 minutes.
- Building Trust: The cardiologist reported significantly higher confidence in the model after personally probing it with his own data and manipulations. The interface provides clear, real-time visual feedback on model predictions.
- The "Relief" Metric: Both participants experienced a sense of "relief" when the model performed well on manipulated data, suggesting that interactive validation is crucial for psychological trust.
- Simplicity: Users preferred the simplest path—sharing a URL for use in a standard browser tab—over more complex integration options.
Limitations and Future Work
While the pilot study was successful, it was limited to a single pair of collaborators. Future work will focus on:
- Expanded Input Support: Adding support for tabular data and bulk processing.
- Explainability: Integrating "saliency maps" to help experts understand which features drive model predictions.
- Quantitative Metrics: Conducting larger studies to measure the long-term impact of interactive interfaces on model accuracy and user trust.
Summary updated