Skip to content

Conversation

@Ahmadalzin95
Copy link

Summary

This PR fixes a compatibility issue with newer Gradio versions (>= 4.x).

In main_demo, gradio.Blocks is currently called with a css keyword argument:

with gradio.Blocks(css=""".gradio-container {margin: 0 !important; min-width: 100%};""", title="DUSt3R Demo") as demo:

In Gradio>=4, Blocks no longer accepts a css keyword, which results in:

TypeError: BlockContext.init() got an unexpected keyword argument 'css'

Fix

The fix simply moves the css argument from the Blocks constructor to demo.launch, which is supported in both Gradio 3 and >=4:

with gradio.Blocks(title="DUSt3R Demo") as demo:
    ...
demo.launch(
    share=False,
    server_name=server_name,
    server_port=server_port,
    css=""".gradio-container {margin: 0 !important; min-width: 100%};""",
)

Notes

Tested locally with:

  • Python 3.11
  • torch 2.5.1
  • gradio 6.0.1

This change remains backward-compatible with Gradio 3.x and 4.x, because the launch(css=...) argument is supported across versions, while css= in Blocks() has been removed in Gradio 4+.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant