Fix: Update Gradio API for compatibility with Gradio 4.x+

#44
by akseljoonas HF Staff - opened

Summary

This PR fixes the Space to work with modern Gradio versions (4.x and above).

Changes

app.py

  • gr.Image(source="upload") โ†’ gr.Image(sources=["upload"]) - The source parameter was renamed to sources and now accepts a list
  • gr.Audio(source="upload") โ†’ gr.Audio(sources=["upload"]) - Same change for Audio component
  • gr.Video(source="upload") โ†’ gr.Video(sources=["upload"]) - Same change for Video component
  • Removed deprecated api_open parameter from demo.queue()

requirements.txt

  • Updated gradio to a recent stable version
  • Updated numpy to a compatible version (1.x series for compatibility with other deps)
  • Updated torch, torchvision, torchaudio to more recent versions

Breaking Changes in Gradio 4.x+

The Gradio library underwent significant API changes in version 4.0:

  • The source parameter in media components was renamed to sources and changed from a string to a list
  • The .style() method was removed from components
  • Queue parameters were simplified

Testing

These changes align with the current Gradio documentation and examples.

Publish this branch
This branch is in draft mode, publish it to be able to merge.

Sign up or log in to comment