Update app.py
Browse files
app.py
CHANGED
@@ -16,9 +16,9 @@ translation_models = {
|
|
16 |
}
|
17 |
|
18 |
# Initialize summarization pipeline with a specified model
|
19 |
-
|
20 |
-
summarizer = pipeline("summarization", model=
|
21 |
-
tokenizer = AutoTokenizer.from_pretrained(
|
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(
|
82 |
-
print("
|
83 |
-
sentences = sent_tokenize(text)
|
84 |
-
print("Sentences:", sentences)
|
85 |
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
|
90 |
-
|
91 |
-
print("Bullet Points:",
|
92 |
|
93 |
-
return
|
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 |
+
|