| import gradio as gr | |
| import transformers | |
| # Load the GPT-2 model | |
| model_1 = transformers.AutoModelForSequenceClassification.from_pretrained("gpt2-medium") | |
| # Load the GPT-3 model | |
| model_2 = transformers.AutoModelForSequenceClassification.from_pretrained("gpt3-medium") | |
| # Create a Gradio interface | |
| app = gr.Interface( | |
| inputs=[gr.TextInput(label="Enter text")], | |
| outputs=[gr.Output(label="Prediction")], | |
| models=[model_1, model_2], | |
| fn=lambda input, model: model.predict(input), | |
| ) | |
| # Run the app | |
| app.launch() | |