Skip to content

v2.4.0

Compare
Choose a tag to compare
@abidlabs abidlabs released this 19 Oct 21:31
· 2256 commits to master since this release

Gradio version 2.4.0 includes several enhancements to the library:

1. Ability to load Huggingface Spaces as Interfaces

You can now load any Huggingface gradio Space as an Interface in one line of code.

Here's an example:

import gradio as gr
io = gr.Interface.load("spaces/akhaliq/T0pp")
io.launch()

Which produces this interface:

image

This works across all Interface types and is tests for this are included in the test_external.py file.

2. Ability to __call__() an Interface as a regular python function

Related to this is the ability to call Interfaces as regular functions. You can now do the following for example:

io = gr.Interface.load("models/EleutherAI/gpt-neo-2.7B")
io("It was the best of times")
>> 'It was the best of times, the bad of times, the ugly of times, the best of times. To each his time.'
io = gr.Interface.load("spaces/akhaliq/T0pp")
io("What is the capital of Pakistan?")
>> `Islamabad`

This works for images, audio, etc. by passing in filepaths or URLs:

io = gr.Interface.load("spaces/abidlabs/image-identity")
io(r"C:\Users\abubakar\Downloads\cars.png")
>> 'C:\\Users\\islam\\AppData\\Local\\Temp\\tmpik1238zy.jpg'

3. Error logging in the front end
Gradio now supports piping errors to the console for you to see. The show_error flag in the launch method is True by default, allowing you to see any errors caused by your prediction in the console. For example, in the image below there was a division by zero error.

Screen Shot 2021-10-27 at 5 59 24 PM

4. API docs for every interface

Gradio supports a REST API for every interface. This release brings interface specific docs for using that API. You will now see a link at the bottom of the interface that will take you to its API docs page:

Screen Shot 2021-10-26 at 5 49 16 PM

The docs page contains information on the input and output types, payload, endpoint, response as well as ready-to-copy code snippets for Python, JS and cURL.

Screen.Recording.2021-10-26.at.5.51.05.PM.mov

5. Crop Audio

Want to select a subrange of the audio file provided? Now we support editing for audio with the cropping tool:
cropaudio