gradio/demo/matrix_transpose/run.py

27 lines
549 B
Python
Raw Normal View History

2021-05-24 23:31:44 +08:00
import numpy as np
import gradio as gr
2021-05-24 23:31:44 +08:00
def transpose(matrix):
return matrix.T
iface = gr.Interface(
transpose,
gr.inputs.Dataframe(type="numpy", datatype="number", row_count=5, col_count=3),
"numpy",
examples=[
[np.zeros((3, 3)).tolist()],
[np.ones((2, 2)).tolist()],
[np.random.randint(0, 10, (3, 10)).tolist()],
[np.random.randint(0, 10, (10, 3)).tolist()],
[np.random.randint(0, 10, (10, 10)).tolist()],
],
2021-05-24 23:31:44 +08:00
)
iface.test_launch()
if __name__ == "__main__":
iface.launch()