File size: 611 Bytes
b882201
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Import necessary libraries
import gradio as gr
import torch
import json
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
from model import TranslationModel

# Load pre-trained model and tokenizer
model = AutoModelForSeq2SeqLM.from_pretrained("t5-small")
tokenizer = AutoTokenizer.from_pretrained("t5-small")

# Load custom model
custom_model = TranslationModel()

# Define Gradio app
app = gr.Interface(
    fn=custom_model.translate,
    inputs=["text", "text"],
    outputs="text",
    title="Translation App",
    description="A Gradio app for translation"
)

# Launch Gradio app
app.launch()