Spaces:
Build error
Build error
freemt
commited on
Commit
•
a1b70da
1
Parent(s):
891b83b
enable_queue moved to gr.interface rather than in launch
Browse files- img/plt.png +0 -0
- radiobee/__main__.py +8 -3
- radiobee/gradiobee.py +9 -1
- requirements.in +0 -0
- requirements.txt +2 -1
img/plt.png
CHANGED
radiobee/__main__.py
CHANGED
@@ -17,6 +17,7 @@ from sklearn.cluster import DBSCAN # noqa
|
|
17 |
|
18 |
import joblib
|
19 |
from varname import nameof
|
|
|
20 |
import logzero
|
21 |
from logzero import logger
|
22 |
|
@@ -39,6 +40,11 @@ import gradio as gr
|
|
39 |
from radiobee.process_upload import process_upload
|
40 |
from radiobee.gradiobee import gradiobee
|
41 |
|
|
|
|
|
|
|
|
|
|
|
42 |
sns.set()
|
43 |
sns.set_style("darkgrid")
|
44 |
fastlid.set_languages = ["en", "zh"]
|
@@ -237,7 +243,6 @@ if __name__ == "__main__":
|
|
237 |
[
|
238 |
"data/test-dual.txt",
|
239 |
"data/empty.txt",
|
240 |
-
# None, # does not work
|
241 |
"linear",
|
242 |
"None",
|
243 |
"None",
|
@@ -248,7 +253,6 @@ if __name__ == "__main__":
|
|
248 |
[
|
249 |
"data/test-zh-ja.txt",
|
250 |
"data/empty.txt",
|
251 |
-
# None, # does not work
|
252 |
"linear",
|
253 |
"None",
|
254 |
"None",
|
@@ -423,6 +427,7 @@ if __name__ == "__main__":
|
|
423 |
"excelsior",
|
424 |
], # "paragon"],
|
425 |
css=f"{css_image} {css_input_file} {css_output_file}",
|
|
|
426 |
)
|
427 |
|
428 |
iface.launch(
|
@@ -433,7 +438,7 @@ if __name__ == "__main__":
|
|
433 |
# server_name="127.0.0.1",
|
434 |
server_port=server_port,
|
435 |
# show_tips=True,
|
436 |
-
enable_queue=True,
|
437 |
# height=150, # 500
|
438 |
width=900, # 900
|
439 |
)
|
|
|
17 |
|
18 |
import joblib
|
19 |
from varname import nameof
|
20 |
+
from icecream import install as ic_install, ic
|
21 |
import logzero
|
22 |
from logzero import logger
|
23 |
|
|
|
40 |
from radiobee.process_upload import process_upload
|
41 |
from radiobee.gradiobee import gradiobee
|
42 |
|
43 |
+
ic_install()
|
44 |
+
ic.configureOutput(includeContext=True)
|
45 |
+
ic.enable()
|
46 |
+
# ic.disenable() # to turn off
|
47 |
+
|
48 |
sns.set()
|
49 |
sns.set_style("darkgrid")
|
50 |
fastlid.set_languages = ["en", "zh"]
|
|
|
243 |
[
|
244 |
"data/test-dual.txt",
|
245 |
"data/empty.txt",
|
|
|
246 |
"linear",
|
247 |
"None",
|
248 |
"None",
|
|
|
253 |
[
|
254 |
"data/test-zh-ja.txt",
|
255 |
"data/empty.txt",
|
|
|
256 |
"linear",
|
257 |
"None",
|
258 |
"None",
|
|
|
427 |
"excelsior",
|
428 |
], # "paragon"],
|
429 |
css=f"{css_image} {css_input_file} {css_output_file}",
|
430 |
+
enable_queue=True,
|
431 |
)
|
432 |
|
433 |
iface.launch(
|
|
|
438 |
# server_name="127.0.0.1",
|
439 |
server_port=server_port,
|
440 |
# show_tips=True,
|
441 |
+
# enable_queue=True,
|
442 |
# height=150, # 500
|
443 |
width=900, # 900
|
444 |
)
|
radiobee/gradiobee.py
CHANGED
@@ -7,9 +7,10 @@ from itertools import zip_longest
|
|
7 |
|
8 |
# import tempfile
|
9 |
|
10 |
-
from logzero import logger
|
11 |
from sklearn.cluster import DBSCAN
|
12 |
from fastlid import fastlid
|
|
|
|
|
13 |
|
14 |
import numpy as np
|
15 |
import pandas as pd
|
@@ -304,6 +305,7 @@ def gradiobee(
|
|
304 |
ylim, xlim = len1, len2
|
305 |
|
306 |
# does not seem to show up
|
|
|
307 |
logger.debug(" len1 (ylim): %s, len2 (xlim): %s", len1, len2)
|
308 |
if debug:
|
309 |
print(f" len1 (ylim): {len1}, len2 (xlim): {len2}")
|
@@ -360,6 +362,7 @@ def gradiobee(
|
|
360 |
)
|
361 |
|
362 |
plt_loc = "img/plt.png"
|
|
|
363 |
plt.savefig(plt_loc)
|
364 |
|
365 |
# clustered
|
@@ -381,6 +384,8 @@ def gradiobee(
|
|
381 |
df_aligned = df_aligned[["text2", "text1", "likelihood"]]
|
382 |
df_aligned.columns = ["text1", "text2", "likelihood"]
|
383 |
|
|
|
|
|
384 |
# round the last column to 2
|
385 |
# df_aligned.likelihood = df_aligned.likelihood.round(2)
|
386 |
# df_aligned = df_aligned.round({"likelihood": 2})
|
@@ -430,6 +435,9 @@ def gradiobee(
|
|
430 |
# output_plot: gr.outputs.Image(type="auto", label="...")
|
431 |
# return df_trimmed, output_plot, file_dl, file_dl_xlsx, df_aligned
|
432 |
# return df_trimmed, output_plot, file_dl, file_dl_xlsx, styled, df_html # gradio cant handle style
|
|
|
|
|
|
|
433 |
return df_trimmed, output_plot, file_dl, file_dl_xlsx, df_aligned, df_html
|
434 |
|
435 |
# modi outputs
|
|
|
7 |
|
8 |
# import tempfile
|
9 |
|
|
|
10 |
from sklearn.cluster import DBSCAN
|
11 |
from fastlid import fastlid
|
12 |
+
from logzero import logger
|
13 |
+
from icecream import ic
|
14 |
|
15 |
import numpy as np
|
16 |
import pandas as pd
|
|
|
305 |
ylim, xlim = len1, len2
|
306 |
|
307 |
# does not seem to show up
|
308 |
+
ic(f" len1 (ylim): {len1}, len2 (xlim): {len2}")
|
309 |
logger.debug(" len1 (ylim): %s, len2 (xlim): %s", len1, len2)
|
310 |
if debug:
|
311 |
print(f" len1 (ylim): {len1}, len2 (xlim): {len2}")
|
|
|
362 |
)
|
363 |
|
364 |
plt_loc = "img/plt.png"
|
365 |
+
ic(f" plotting to {plt_loc}")
|
366 |
plt.savefig(plt_loc)
|
367 |
|
368 |
# clustered
|
|
|
384 |
df_aligned = df_aligned[["text2", "text1", "likelihood"]]
|
385 |
df_aligned.columns = ["text1", "text2", "likelihood"]
|
386 |
|
387 |
+
ic(df_aligned.head())
|
388 |
+
|
389 |
# round the last column to 2
|
390 |
# df_aligned.likelihood = df_aligned.likelihood.round(2)
|
391 |
# df_aligned = df_aligned.round({"likelihood": 2})
|
|
|
435 |
# output_plot: gr.outputs.Image(type="auto", label="...")
|
436 |
# return df_trimmed, output_plot, file_dl, file_dl_xlsx, df_aligned
|
437 |
# return df_trimmed, output_plot, file_dl, file_dl_xlsx, styled, df_html # gradio cant handle style
|
438 |
+
|
439 |
+
ic("returning outputs")
|
440 |
+
|
441 |
return df_trimmed, output_plot, file_dl, file_dl_xlsx, df_aligned, df_html
|
442 |
|
443 |
# modi outputs
|
requirements.in
ADDED
File without changes
|
requirements.txt
CHANGED
@@ -23,4 +23,5 @@ pyicu
|
|
23 |
pycld2
|
24 |
tqdm
|
25 |
polyglot
|
26 |
-
sentence_splitter
|
|
|
|
23 |
pycld2
|
24 |
tqdm
|
25 |
polyglot
|
26 |
+
sentence_splitter
|
27 |
+
icecream
|