Sayiqa7 commited on
Commit
c1118cb
·
verified ·
1 Parent(s): 33b2d9b

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline, AutoTokenizer, AutoModelForSeq2SeqLM
2
+ import gradio as gr
3
+
4
+ # Load the model and tokenizer
5
+ tokenizer = AutoTokenizer.from_pretrained("machinelearningzuu/youtube-content-summarization")
6
+ model = AutoModelForSeq2SeqLM.from_pretrained("machinelearningzuu/youtube-content-summarization")
7
+
8
+ # Define a function for summarization
9
+ def summarize_youtube_content(input_text):
10
+ # Use the pipeline for summarization
11
+ summarizer = pipeline("text2text-generation", model=model, tokenizer=tokenizer)
12
+ summary = summarizer(input_text, max_length=150, min_length=30, do_sample=False)
13
+ return summary[0]['generated_text']
14
+
15
+ # Create a Gradio interface
16
+ interface = gr.Interface(
17
+ fn=summarize_youtube_content,
18
+ inputs=gr.Textbox(lines=10, placeholder="Paste YouTube transcript here..."),
19
+ outputs=gr.Textbox(lines=5, label="Summarized Content"),
20
+ title="YouTube Content Summarizer",
21
+ description="Paste the transcript of a YouTube video to generate a concise summary.",
22
+ )
23
+
24
+ # Launch the Gradio app
25
+ if __name__ == "__main__":
26
+ interface.launch()