Spaces:
Runtime error
Runtime error
File size: 1,727 Bytes
9fb8195 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
#!/usr/bin/env python3
"""
Gradio Compatibility Test
========================
Quick test to verify Gradio interface compatibility.
"""
import gradio as gr
import numpy as np
def test_interface():
"""Test basic Gradio interface creation."""
def simple_predict(text):
return f"Processed: {text}"
# Test interface creation with modern Gradio
with gr.Blocks(title="Test Interface") as interface:
gr.Markdown("# Test Interface")
with gr.Row():
text_input = gr.Textbox(label="Input")
output = gr.Textbox(label="Output")
btn = gr.Button("Process")
# Test examples
gr.Examples(
examples=[["Test 1"], ["Test 2"]],
inputs=[text_input],
outputs=[output],
fn=simple_predict
)
# Test event handlers
btn.click(
fn=simple_predict,
inputs=[text_input],
outputs=[output],
show_progress="minimal"
)
print("β
Gradio interface test passed!")
return interface
if __name__ == "__main__":
print("π§ͺ Testing Gradio compatibility...")
try:
interface = test_interface()
print("π All Gradio features working correctly!")
# Don't launch, just test creation
print("π Interface created successfully with:")
print(" β’ Modern Blocks API")
print(" β’ Updated event handlers")
print(" β’ Compatible Examples component")
print(" β’ Proper show_progress values")
except Exception as e:
print(f"β Gradio compatibility test failed: {e}")
exit(1)
|