Spaces:
Runtime error
Runtime error
File size: 862 Bytes
a801860 1540bea a801860 1540bea |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
import gradio as gr
import torch
from transformers import MBartForConditionalGeneration, MBart50TokenizerFast
description = "Telugu Abstractive Summarization"
title = "TeSum"
model = MBartForConditionalGeneration.from_pretrained("ashokurlana/mBART-TeSum")
device = "cuda" if torch.cuda.is_available() else "cpu"
model.to(device)
model.eval()
tokenizer = MBart50TokenizerFast.from_pretrained("ashokurlana/mBART-TeSum", src_lang="te_IN", tgt_lang="te_IN")
def summarize(text):
model_inputs = tokenizer(src_text, return_tensors="pt")
with tokenizer.as_target_tokenizer():
labels = tokenizer(tgt_text, return_tensors="pt").input_ids
return model(**model_inputs, labels=labels)
interface = gr.Interface(transcribe, inputs='text', outputs='text')
interface.launch(share=True)
# gr.Interface.load("models/ashokurlana/mBART-TeSum").launch() |