Spaces:
Sleeping
Sleeping
app.py
CHANGED
@@ -70,7 +70,13 @@ def summarize_text(input_text, model_label, char_limit):
|
|
70 |
do_sample=False
|
71 |
)
|
72 |
|
|
|
73 |
summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
|
|
|
|
|
|
|
|
|
|
|
74 |
return summary[:char_limit] # Enforce character limit
|
75 |
|
76 |
# Gradio UI
|
|
|
70 |
do_sample=False
|
71 |
)
|
72 |
|
73 |
+
# Decode the summary while skipping special tokens and cleaning unwanted characters
|
74 |
summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
|
75 |
+
|
76 |
+
# Remove unwanted characters like pipes or any unwanted symbols
|
77 |
+
summary = summary.replace("|", "") # Remove pipes
|
78 |
+
summary = summary.strip() # Remove leading/trailing whitespace
|
79 |
+
|
80 |
return summary[:char_limit] # Enforce character limit
|
81 |
|
82 |
# Gradio UI
|