| import matplotlib | |
| matplotlib.use('Agg') | |
| import matplotlib.pyplot as plt | |
| import numpy as np | |
| import gradio as gr | |
| dummy_data = [1, 2, 3, 4] | |
| def get_plot(model_name): | |
| plt.plot(dummy_data) | |
| plt.legend(model_name) | |
| return plt.gcf() | |
| demo = gr.Blocks() | |
| with demo: | |
| with gr.Tabs(): | |
| with gr.TabItem("Greedy Search"): | |
| model_selector = gr.Dropdown( | |
| choices=["DistilGPT2", "GPT2", "OPT 1.3B", "GPTJ-6B", "T5 Small", "T5 Base", "T5 Large", "T5 3B"], | |
| value="T5 Small", | |
| label="Model", | |
| interactive=True, | |
| ) | |
| model_selector.change(fn=get_plot, inputs=model_selector, outputs="plot") | |
| with gr.TabItem("Sample"): | |
| gr.Button("New Tiger") | |
| with gr.TabItem("Beam Search"): | |
| gr.Button("New Tiger") | |
| with gr.TabItem("Benchmark Information"): | |
| gr.Dataframe( | |
| headers=["Parameter", "Value"], | |
| value=[ | |
| ["Transformers Version", "4.22.dev0"], | |
| ["TensorFlow Version", "2.9.1"], | |
| ["Pytorch Version", "1.11.0"], | |
| ["OS", "22.04 LTS (3090) / Debian 10 (other GPUs)"], | |
| ["CUDA", "11.6 (3090) / 11.3 (others GPUs)"], | |
| ["Number of runs", "100 (the first run was discarded to ignore compilation time)"], | |
| ["Is there code to reproduce?", "Yes -- https://gist.github.com/gante/f0017e3f13ac11b0c02e4e4db351f52f"], | |
| ], | |
| ) | |
| demo.launch() | |