File size: 897 Bytes
0fd4c0d
 
 
115e650
94304ce
0fd4c0d
 
 
 
 
 
 
 
 
 
 
387773c
 
0fd4c0d
 
 
 
 
36fd279
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
from transformers import pipeline, AutoTokenizer, AutoModelForSeq2SeqLM
import gradio as gr

# Load the model and tokenizer
model_path = '.'  # Path to the current directory where files are located

tokenizer = AutoTokenizer.from_pretrained(model_path)
model = AutoModelForSeq2SeqLM.from_pretrained(model_path)
summarizer = pipeline('summarization', model=model, tokenizer=tokenizer)

def summarize_text(text):
    result = summarizer(text, max_length=150, min_length=30, do_sample=False)
    return result[0]['summary_text']

gr_interface = gr.Interface(
    fn=summarize_text,
    inputs=gr.Textbox(lines=5, placeholder="Enter text to summarize here..."),
    outputs=gr.Textbox(),
    title="Text Summarization with Fine-Tuned Model",
    description="Enter text to generate a summary using the fine-tuned summarization model."
)

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