codeteach commited on
Commit
f05ba0b
1 Parent(s): 23659c4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -13
app.py CHANGED
@@ -16,9 +16,9 @@ translation_models = {
16
  }
17
 
18
  # Initialize summarization pipeline with a specified model
19
- model_name = "sshleifer/distilbart-cnn-12-6"
20
- summarizer = pipeline("summarization", model=model_name)
21
- tokenizer = AutoTokenizer.from_pretrained(model_name)
22
 
23
  # Initialize translation pipeline
24
  def get_translator(language):
@@ -78,19 +78,17 @@ def process_text(input_text, language):
78
  print(f"Translated Text: {translated_text}")
79
  return bullet_points, translated_text
80
 
81
- def generate_bullet_points(text):
82
- print("Original Text:", text)
83
- sentences = sent_tokenize(text)
84
- print("Sentences:", sentences)
85
 
86
- bullet_points = []
87
- for sentence in sentences:
88
- bullet_points.append(sentence.strip())
89
 
90
- result = "\n".join(f"- {point}" for point in bullet_points)
91
- print("Bullet Points:", result)
92
 
93
- return result
94
 
95
  # Create Gradio interface
96
  iface = gr.Interface(
@@ -116,3 +114,4 @@ iface.launch()
116
 
117
 
118
 
 
 
16
  }
17
 
18
  # Initialize summarization pipeline with a specified model
19
+ summarization_model = "facebook/bart-large-cnn"
20
+ summarizer = pipeline("summarization", model=summarization_model, device=0) # Ensure it runs on GPU for better performance
21
+ tokenizer = AutoTokenizer.from_pretrained(summarization_model)
22
 
23
  # Initialize translation pipeline
24
  def get_translator(language):
 
78
  print(f"Translated Text: {translated_text}")
79
  return bullet_points, translated_text
80
 
81
+ def generate_bullet_points(summary):
82
+ print("Summary Text:", summary)
 
 
83
 
84
+ # Extract key sentences
85
+ sentences = sent_tokenize(summary)
86
+ key_sentences = sentences[:3] # Extract the first three sentences as key points
87
 
88
+ bullet_points = "\n".join(f"- {sentence}" for sentence in key_sentences)
89
+ print("Bullet Points:", bullet_points)
90
 
91
+ return bullet_points
92
 
93
  # Create Gradio interface
94
  iface = gr.Interface(
 
114
 
115
 
116
 
117
+