ffreemt commited on
Commit
927848d
1 Parent(s): 8018fb1

Update app.py

Browse files
Files changed (5) hide show
  1. app.py +32 -3
  2. gradiobee/seg_text.py +2 -2
  3. requirements-bk.txt +205 -0
  4. requirements.txt +5 -204
  5. ttw-hf-spaces.loc +0 -0
app.py CHANGED
@@ -22,7 +22,7 @@ import gradio as gr
22
  import logzero
23
  from logzero import logger
24
 
25
- from gradiobee.seg_text import seg_text
26
 
27
  matplotlib.use("Agg") # non-interactive for plt.savefig
28
  sns.set()
@@ -32,6 +32,34 @@ logzero.loglevel() # default to 10
32
 
33
  # def greet(command):
34
  def process(command) -> Tuple[str, Optional[str]]:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  """Probe vm."""
36
  # single line: command
37
  # logger.info("input:\n\t %s", command)
@@ -50,7 +78,7 @@ def process(command) -> Tuple[str, Optional[str]]:
50
  return "gimme something to start with...", None
51
 
52
  is_command = True
53
- is_command = command.strip().splitlines().__len__() < 2 and len(command.strip()) < 500
54
 
55
  if is_command:
56
  try:
@@ -142,7 +170,8 @@ iface = gr.Interface(
142
  # outputs=["text", "html"],
143
  outputs=[
144
  "text",
145
- gr.outputs.Image("auto"),
 
146
  ],
147
  examples=[
148
  "python -m site",
22
  import logzero
23
  from logzero import logger
24
 
25
+ # from gradiobee.seg_text import seg_text
26
 
27
  matplotlib.use("Agg") # non-interactive for plt.savefig
28
  sns.set()
32
 
33
  # def greet(command):
34
  def process(command) -> Tuple[str, Optional[str]]:
35
+ """Probe vm."""
36
+ logger.info("input: %s", command)
37
+
38
+ try:
39
+ command = str(command).strip()
40
+ except Exception as e:
41
+ _ = str(e)
42
+ return _, None
43
+
44
+ if not command:
45
+ return "gimme something to start with...", None
46
+
47
+ try:
48
+ # out = sp.check_output(split(command), encoding="utf8", stderr=STDOUT)
49
+ proc = sp.Popen(
50
+ split(command), encoding="utf8", stdout=-1, stderr=-1
51
+ ) # sp.PIPE: -1
52
+ out, err = proc.communicate()
53
+ # success = True
54
+ return f"[{out}], [{err}]", None
55
+ except Exception as e:
56
+ out, err = "", str(e)
57
+ # success = False
58
+ # return f"[{out}]", f"[{err}]"
59
+ return f"[{out}], [{err}]", None
60
+
61
+
62
+ def process1(command) -> Tuple[str, Optional[str]]:
63
  """Probe vm."""
64
  # single line: command
65
  # logger.info("input:\n\t %s", command)
78
  return "gimme something to start with...", None
79
 
80
  is_command = True
81
+ # is_command = command.strip().splitlines().__len__() < 2 and len(command.strip()) < 500
82
 
83
  if is_command:
84
  try:
170
  # outputs=["text", "html"],
171
  outputs=[
172
  "text",
173
+ # gr.outputs.Image("auto"),
174
+ gr.outputs.Image('pil'),
175
  ],
176
  examples=[
177
  "python -m site",
gradiobee/seg_text.py CHANGED
@@ -13,14 +13,14 @@ from typing import List, Optional, Union
13
 
14
  import re
15
  from tqdm.auto import tqdm
16
- from polyglot.detect.base import logger as polyglot_logger
17
  from polyglot.text import Detector, Text
18
  from sentence_splitter import split_text_into_sentences
19
 
20
  from logzero import logger
21
 
22
  # turn of polyglot.text.Detector warning
23
- polyglot_logger.setLevel("ERROR")
24
 
25
 
26
  # fmt: off
13
 
14
  import re
15
  from tqdm.auto import tqdm
16
+ # from polyglot.detect.base import logger as polyglot_logger
17
  from polyglot.text import Detector, Text
18
  from sentence_splitter import split_text_into_sentences
19
 
20
  from logzero import logger
21
 
22
  # turn of polyglot.text.Detector warning
23
+ # polyglot_logger.setLevel("ERROR")
24
 
25
 
26
  # fmt: off
requirements-bk.txt ADDED
@@ -0,0 +1,205 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #
2
+ # This file is autogenerated by pip-compile with python 3.8
3
+ # To update, run:
4
+ #
5
+ # pip-compile requirements.in
6
+ #
7
+ altair==4.2.0
8
+ # via -r requirements.in
9
+ attrs==21.4.0
10
+ # via jsonschema
11
+ blis==0.7.5
12
+ # via
13
+ # spacy
14
+ # thinc
15
+ cachetools==5.0.0
16
+ # via textacy
17
+ catalogue==2.0.6
18
+ # via
19
+ # spacy
20
+ # srsly
21
+ # thinc
22
+ certifi==2021.10.8
23
+ # via requests
24
+ charset-normalizer==2.0.9
25
+ # via requests
26
+ click==8.0.3
27
+ # via typer
28
+ colorama==0.4.4
29
+ # via
30
+ # logzero
31
+ # tqdm
32
+ cycler==0.11.0
33
+ # via matplotlib
34
+ cymem==2.0.6
35
+ # via
36
+ # preshed
37
+ # spacy
38
+ # thinc
39
+ cytoolz==0.11.2
40
+ # via textacy
41
+ entrypoints==0.3
42
+ # via altair
43
+ fonttools==4.28.5
44
+ # via matplotlib
45
+ idna==3.3
46
+ # via requests
47
+ importlib-resources==5.4.0
48
+ # via jsonschema
49
+ jellyfish==0.8.9
50
+ # via textacy
51
+ jinja2==3.0.3
52
+ # via
53
+ # altair
54
+ # spacy
55
+ joblib==1.1.0
56
+ # via
57
+ # scikit-learn
58
+ # textacy
59
+ jsonschema==4.3.3
60
+ # via altair
61
+ kiwisolver==1.3.2
62
+ # via matplotlib
63
+ langcodes==3.3.0
64
+ # via spacy
65
+ logzero==1.7.0
66
+ # via -r requirements.in
67
+ markupsafe==2.0.1
68
+ # via jinja2
69
+ matplotlib==3.5.1
70
+ # via seaborn
71
+ more-itertools==8.12.0
72
+ # via -r requirements.in
73
+ morfessor==2.0.6
74
+ # via -r requirements.in
75
+ murmurhash==1.0.6
76
+ # via
77
+ # preshed
78
+ # spacy
79
+ # thinc
80
+ networkx==2.6.3
81
+ # via textacy
82
+ numpy==1.21.5
83
+ # via
84
+ # altair
85
+ # blis
86
+ # matplotlib
87
+ # pandas
88
+ # scikit-learn
89
+ # scipy
90
+ # seaborn
91
+ # spacy
92
+ # textacy
93
+ # thinc
94
+ packaging==21.3
95
+ # via
96
+ # matplotlib
97
+ # spacy
98
+ pandas==1.3.5
99
+ # via
100
+ # altair
101
+ # seaborn
102
+ pathy==0.6.1
103
+ # via spacy
104
+ pillow==8.4.0
105
+ # via matplotlib
106
+ polyglot==16.7.4
107
+ # via -r requirements.in
108
+ preshed==3.0.6
109
+ # via
110
+ # spacy
111
+ # thinc
112
+ psutil==5.8.0
113
+ # via -r requirements.in
114
+ pycld2==0.41
115
+ # via -r requirements.in
116
+ pydantic==1.8.2
117
+ # via
118
+ # spacy
119
+ # thinc
120
+ pyparsing==3.0.6
121
+ # via
122
+ # matplotlib
123
+ # packaging
124
+ pyphen==0.12.0
125
+ # via textacy
126
+ pyrsistent==0.18.0
127
+ # via jsonschema
128
+ python-dateutil==2.8.2
129
+ # via
130
+ # matplotlib
131
+ # pandas
132
+ pytz==2021.3
133
+ # via pandas
134
+ regex==2021.11.10
135
+ # via sentence-splitter
136
+ requests==2.26.0
137
+ # via
138
+ # spacy
139
+ # textacy
140
+ scikit-learn==1.0.2
141
+ # via
142
+ # sklearn
143
+ # textacy
144
+ scipy==1.7.3
145
+ # via
146
+ # scikit-learn
147
+ # seaborn
148
+ # textacy
149
+ seaborn==0.11.2
150
+ # via -r requirements.in
151
+ sentence-splitter==1.4
152
+ # via -r requirements.in
153
+ six==1.16.0
154
+ # via python-dateutil
155
+ sklearn==0.0
156
+ # via -r requirements.in
157
+ smart-open==5.2.1
158
+ # via pathy
159
+ spacy==3.2.1
160
+ # via textacy
161
+ spacy-legacy==3.0.8
162
+ # via spacy
163
+ spacy-loggers==1.0.1
164
+ # via spacy
165
+ srsly==2.4.2
166
+ # via
167
+ # spacy
168
+ # thinc
169
+ textacy==0.11.0
170
+ # via -r requirements.in
171
+ thinc==8.0.13
172
+ # via spacy
173
+ threadpoolctl==3.0.0
174
+ # via scikit-learn
175
+ toolz==0.11.2
176
+ # via
177
+ # altair
178
+ # cytoolz
179
+ tqdm==4.62.3
180
+ # via
181
+ # -r requirements.in
182
+ # spacy
183
+ # textacy
184
+ typer==0.4.0
185
+ # via
186
+ # pathy
187
+ # spacy
188
+ typing-extensions==3.10.0.2
189
+ # via pydantic
190
+ urllib3==1.26.7
191
+ # via requests
192
+ wasabi==0.9.0
193
+ # via
194
+ # spacy
195
+ # spacy-loggers
196
+ # thinc
197
+ zipp==3.7.0
198
+ # via importlib-resources
199
+
200
+ # The following packages are considered to be unsafe in a requirements file:
201
+ # setuptools
202
+ altair_saver
203
+ pyicu
204
+ alive-progress
205
+ sentence_transformers
requirements.txt CHANGED
@@ -1,205 +1,6 @@
1
- #
2
- # This file is autogenerated by pip-compile with python 3.8
3
- # To update, run:
4
- #
5
- # pip-compile requirements.in
6
- #
7
- altair==4.2.0
8
- # via -r requirements.in
9
- attrs==21.4.0
10
- # via jsonschema
11
- blis==0.7.5
12
- # via
13
- # spacy
14
- # thinc
15
- cachetools==5.0.0
16
- # via textacy
17
- catalogue==2.0.6
18
- # via
19
- # spacy
20
- # srsly
21
- # thinc
22
- certifi==2021.10.8
23
- # via requests
24
- charset-normalizer==2.0.9
25
- # via requests
26
- click==8.0.3
27
- # via typer
28
- colorama==0.4.4
29
- # via
30
- # logzero
31
- # tqdm
32
- cycler==0.11.0
33
- # via matplotlib
34
- cymem==2.0.6
35
- # via
36
- # preshed
37
- # spacy
38
- # thinc
39
- cytoolz==0.11.2
40
- # via textacy
41
- entrypoints==0.3
42
- # via altair
43
- fonttools==4.28.5
44
- # via matplotlib
45
- idna==3.3
46
- # via requests
47
- importlib-resources==5.4.0
48
- # via jsonschema
49
- jellyfish==0.8.9
50
- # via textacy
51
- jinja2==3.0.3
52
- # via
53
- # altair
54
- # spacy
55
- joblib==1.1.0
56
- # via
57
- # scikit-learn
58
- # textacy
59
- jsonschema==4.3.3
60
- # via altair
61
- kiwisolver==1.3.2
62
- # via matplotlib
63
- langcodes==3.3.0
64
- # via spacy
65
- logzero==1.7.0
66
- # via -r requirements.in
67
- markupsafe==2.0.1
68
- # via jinja2
69
- matplotlib==3.5.1
70
- # via seaborn
71
- more-itertools==8.12.0
72
- # via -r requirements.in
73
- morfessor==2.0.6
74
- # via -r requirements.in
75
- murmurhash==1.0.6
76
- # via
77
- # preshed
78
- # spacy
79
- # thinc
80
- networkx==2.6.3
81
- # via textacy
82
- numpy==1.21.5
83
- # via
84
- # altair
85
- # blis
86
- # matplotlib
87
- # pandas
88
- # scikit-learn
89
- # scipy
90
- # seaborn
91
- # spacy
92
- # textacy
93
- # thinc
94
- packaging==21.3
95
- # via
96
- # matplotlib
97
- # spacy
98
- pandas==1.3.5
99
- # via
100
- # altair
101
- # seaborn
102
- pathy==0.6.1
103
- # via spacy
104
- pillow==8.4.0
105
- # via matplotlib
106
- polyglot==16.7.4
107
- # via -r requirements.in
108
- preshed==3.0.6
109
- # via
110
- # spacy
111
- # thinc
112
- psutil==5.8.0
113
- # via -r requirements.in
114
- pycld2==0.41
115
- # via -r requirements.in
116
- pydantic==1.8.2
117
- # via
118
- # spacy
119
- # thinc
120
- pyparsing==3.0.6
121
- # via
122
- # matplotlib
123
- # packaging
124
- pyphen==0.12.0
125
- # via textacy
126
- pyrsistent==0.18.0
127
- # via jsonschema
128
- python-dateutil==2.8.2
129
- # via
130
- # matplotlib
131
- # pandas
132
- pytz==2021.3
133
- # via pandas
134
- regex==2021.11.10
135
- # via sentence-splitter
136
- requests==2.26.0
137
- # via
138
- # spacy
139
- # textacy
140
- scikit-learn==1.0.2
141
- # via
142
- # sklearn
143
- # textacy
144
- scipy==1.7.3
145
- # via
146
- # scikit-learn
147
- # seaborn
148
- # textacy
149
- seaborn==0.11.2
150
- # via -r requirements.in
151
- sentence-splitter==1.4
152
- # via -r requirements.in
153
- six==1.16.0
154
- # via python-dateutil
155
- sklearn==0.0
156
- # via -r requirements.in
157
- smart-open==5.2.1
158
- # via pathy
159
- spacy==3.2.1
160
- # via textacy
161
- spacy-legacy==3.0.8
162
- # via spacy
163
- spacy-loggers==1.0.1
164
- # via spacy
165
- srsly==2.4.2
166
- # via
167
- # spacy
168
- # thinc
169
- textacy==0.11.0
170
- # via -r requirements.in
171
- thinc==8.0.13
172
- # via spacy
173
- threadpoolctl==3.0.0
174
- # via scikit-learn
175
- toolz==0.11.2
176
- # via
177
- # altair
178
- # cytoolz
179
- tqdm==4.62.3
180
- # via
181
- # -r requirements.in
182
- # spacy
183
- # textacy
184
- typer==0.4.0
185
- # via
186
- # pathy
187
- # spacy
188
- typing-extensions==3.10.0.2
189
- # via pydantic
190
- urllib3==1.26.7
191
- # via requests
192
- wasabi==0.9.0
193
- # via
194
- # spacy
195
- # spacy-loggers
196
- # thinc
197
- zipp==3.7.0
198
- # via importlib-resources
199
 
200
- # The following packages are considered to be unsafe in a requirements file:
201
- # setuptools
202
- altair_saver
203
- pyicu
204
- alive-progress
205
- sentence_transformers
1
+ gradio
2
+ # anyio, uc-micro-py, multidict, mdurl, httpcore, frozenlist, yarl, websockets, starlette, markdown-it-py, linkify-it-py, httpx, fsspec, async-timeout, aiosignal, uvicorn, semantic-version, python-multipart, pydub, orjson, mdit-py-plugins, gradio-client, ffmpy, fastapi, aiohttp, aiofiles, gradio 3.27.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
 
4
+ typing_extensions
5
+ polyglot
6
+ logzero
 
 
 
ttw-hf-spaces.loc ADDED
File without changes