Spaces:
Sleeping
Sleeping
Commit
·
2c64b23
1
Parent(s):
e5d9d3a
worse
Browse files
app.py
CHANGED
@@ -1,13 +1,8 @@
|
|
1 |
import gradio as gr
|
2 |
-
from collections import Counter
|
3 |
import re
|
4 |
import textstat
|
5 |
from transformers import pipeline
|
6 |
from langdetect import detect
|
7 |
-
import os
|
8 |
-
|
9 |
-
# Disable GPU usage for TensorFlow
|
10 |
-
os.environ["CUDA_VISIBLE_DEVICES"] = "-1"
|
11 |
|
12 |
# Load a summarization model
|
13 |
summarizer = pipeline("summarization")
|
@@ -36,7 +31,7 @@ def text_summarization(text):
|
|
36 |
summary = summarizer(text, max_length=130, min_length=30, do_sample=False)[0]['summary_text']
|
37 |
return summary
|
38 |
|
39 |
-
# Define interfaces for
|
40 |
text_analysis_interface = gr.Interface(fn=text_analysis,
|
41 |
inputs=gr.Textbox(lines=4, placeholder="Type something here..."),
|
42 |
outputs=gr.JSON(label="Text Analysis"))
|
@@ -45,9 +40,10 @@ text_summarization_interface = gr.Interface(fn=text_summarization,
|
|
45 |
inputs=gr.Textbox(lines=4, placeholder="Type something here..."),
|
46 |
outputs="text")
|
47 |
|
48 |
-
#
|
49 |
-
|
|
|
50 |
|
51 |
-
# Launch the
|
52 |
if __name__ == "__main__":
|
53 |
-
|
|
|
1 |
import gradio as gr
|
|
|
2 |
import re
|
3 |
import textstat
|
4 |
from transformers import pipeline
|
5 |
from langdetect import detect
|
|
|
|
|
|
|
|
|
6 |
|
7 |
# Load a summarization model
|
8 |
summarizer = pipeline("summarization")
|
|
|
31 |
summary = summarizer(text, max_length=130, min_length=30, do_sample=False)[0]['summary_text']
|
32 |
return summary
|
33 |
|
34 |
+
# Define interfaces for text analysis and text summarization
|
35 |
text_analysis_interface = gr.Interface(fn=text_analysis,
|
36 |
inputs=gr.Textbox(lines=4, placeholder="Type something here..."),
|
37 |
outputs=gr.JSON(label="Text Analysis"))
|
|
|
40 |
inputs=gr.Textbox(lines=4, placeholder="Type something here..."),
|
41 |
outputs="text")
|
42 |
|
43 |
+
# Launch the text analysis interface
|
44 |
+
if __name__ == "__main__":
|
45 |
+
text_analysis_interface.launch()
|
46 |
|
47 |
+
# Launch the text summarization interface
|
48 |
if __name__ == "__main__":
|
49 |
+
text_summarization_interface.launch()
|