Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -121,7 +121,6 @@ nlp.add_pipe('sentencizer')
|
|
121 |
spacy_stop_words = spacy.lang.nb.stop_words.STOP_WORDS
|
122 |
|
123 |
summarization_model = AutoModel.from_pretrained("NbAiLab/nb-bert-large")
|
124 |
-
summarization_tokenizer = AutoTokenizer.from_pretrained("NbAiLab/nb-bert-large") # <--not sure if this is needed..is not the tokenizer already part of this model..?
|
125 |
# pipe = pipeline("fill-mask", model="NbAiLab/nb-bert-large")
|
126 |
|
127 |
@spaces.GPU()
|
@@ -150,10 +149,10 @@ def summarize_text(text, file_upload):
|
|
150 |
# ----add same if/elif logic as above here----
|
151 |
#
|
152 |
preprocessed_text = preprocess_text(text)
|
153 |
-
inputs =
|
154 |
inputs = inputs.to(device)
|
155 |
summary_ids = summarization_model.generate(inputs.input_ids, num_beams=5, max_length=150, early_stopping=True)
|
156 |
-
return
|
157 |
|
158 |
@spaces.GPU()
|
159 |
def build_similarity_matrix(sentences):
|
@@ -295,7 +294,7 @@ with iface:
|
|
295 |
summarize_uploaded_button_graph.click(fn=graph_based_summary(file_upload), inputs=[text_input_graph], outputs=[summary_output_graph])
|
296 |
|
297 |
with gr.TabItem("Summary | LexRank"):
|
298 |
-
|
299 |
text_output = gr.Textbox(label="Transcription Output")
|
300 |
text_input_lex = gr.Textbox(label="Input Text", placeholder="txt2summarize")
|
301 |
summary_output_lex = gr.Textbox(label="LexRank | cosine similarity")
|
|
|
121 |
spacy_stop_words = spacy.lang.nb.stop_words.STOP_WORDS
|
122 |
|
123 |
summarization_model = AutoModel.from_pretrained("NbAiLab/nb-bert-large")
|
|
|
124 |
# pipe = pipeline("fill-mask", model="NbAiLab/nb-bert-large")
|
125 |
|
126 |
@spaces.GPU()
|
|
|
149 |
# ----add same if/elif logic as above here----
|
150 |
#
|
151 |
preprocessed_text = preprocess_text(text)
|
152 |
+
inputs = summarization_model(preprocessed_text, max_length=1024, return_tensors="pt", truncation=True)
|
153 |
inputs = inputs.to(device)
|
154 |
summary_ids = summarization_model.generate(inputs.input_ids, num_beams=5, max_length=150, early_stopping=True)
|
155 |
+
return summarization_model.decode(summary_ids[0], skip_special_tokens=True)
|
156 |
|
157 |
@spaces.GPU()
|
158 |
def build_similarity_matrix(sentences):
|
|
|
294 |
summarize_uploaded_button_graph.click(fn=graph_based_summary(file_upload), inputs=[text_input_graph], outputs=[summary_output_graph])
|
295 |
|
296 |
with gr.TabItem("Summary | LexRank"):
|
297 |
+
with gr.Blocks():
|
298 |
text_output = gr.Textbox(label="Transcription Output")
|
299 |
text_input_lex = gr.Textbox(label="Input Text", placeholder="txt2summarize")
|
300 |
summary_output_lex = gr.Textbox(label="LexRank | cosine similarity")
|