Spaces:
Sleeping
Sleeping
update
Browse files
app.py
CHANGED
|
@@ -6,7 +6,11 @@ model = pipeline("summarization", model="luisotorres/bart-finetuned-samsum")
|
|
| 6 |
|
| 7 |
def summarize_text(text):
|
| 8 |
try:
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
return summary[0]["summary_text"]
|
| 11 |
except Exception as e:
|
| 12 |
return str(e)
|
|
@@ -23,5 +27,5 @@ iface = gr.Interface(
|
|
| 23 |
]
|
| 24 |
)
|
| 25 |
|
| 26 |
-
# Launch the interface
|
| 27 |
-
iface.launch()
|
|
|
|
| 6 |
|
| 7 |
def summarize_text(text):
|
| 8 |
try:
|
| 9 |
+
# Dynamically set max_length based on input length
|
| 10 |
+
input_length = len(text.split())
|
| 11 |
+
max_length = min(130, max(30, input_length // 2))
|
| 12 |
+
|
| 13 |
+
summary = model(text, max_length=max_length, min_length=30)
|
| 14 |
return summary[0]["summary_text"]
|
| 15 |
except Exception as e:
|
| 16 |
return str(e)
|
|
|
|
| 27 |
]
|
| 28 |
)
|
| 29 |
|
| 30 |
+
# Launch the interface with public URL enabled
|
| 31 |
+
iface.launch(share=True)
|