File size: 562 Bytes
ac4b355
9f88fa2
ac4b355
9f88fa2
 
ef67cf9
9f88fa2
 
 
 
 
ac4b355
 
 
 
9f88fa2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import gradio as gr
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer

model = AutoModelForSeq2SeqLM.from_pretrained("Mbilal755/Radiology_Bart") 
tokenizer = AutoTokenizer.from_pretrained("Mbilal755/Radiology_Bart")

def summarize(input):
    inputs = tokenizer(input, return_tensors="pt")
    output = model.generate(inputs["input_ids"]) 
    summary = tokenizer.decode(output[0], skip_special_tokens=True)
    return summary

iface = gr.Interface(fn=summarize, inputs="text", outputs="text")

if __name__ == "__main__":
    iface.launch(share=True)