Spaces:
Runtime error
Runtime error
freemt
commited on
Commit
·
8a677e1
1
Parent(s):
3b72fd4
Update gradio 3.0 Dataframe output no longer feasible
Browse files- .stignore +101 -0
- img/plt.png +0 -0
- install-nodemon.sh +4 -0
- okteto.yml +42 -0
- radiobee/__main__.py +11 -9
- radiobee/align_sents_pyc +0 -0
- radiobee/detect.py +1 -1
- radiobee/en2zh_tokens_pyc +0 -0
- radiobee/gradiobee.py +52 -2
- radiobee/paras2sents_pyc +0 -0
- radiobee/shuffle_sents_pyc +0 -0
- radiobee/trim_df.py +4 -7
- run-nodemon.sh +1 -0
.stignore
ADDED
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.git
|
2 |
+
# Byte-compiled / optimized / DLL files
|
3 |
+
__pycache__
|
4 |
+
*.py[cod]
|
5 |
+
*$py.class
|
6 |
+
|
7 |
+
# C extensions
|
8 |
+
*.so
|
9 |
+
|
10 |
+
# Distribution / packaging
|
11 |
+
.Python
|
12 |
+
build
|
13 |
+
develop-eggs
|
14 |
+
dist
|
15 |
+
downloads
|
16 |
+
eggs
|
17 |
+
.eggs
|
18 |
+
lib
|
19 |
+
lib64
|
20 |
+
parts
|
21 |
+
sdist
|
22 |
+
var
|
23 |
+
wheels
|
24 |
+
pip-wheel-metadata
|
25 |
+
share/python-wheels
|
26 |
+
*.egg-info
|
27 |
+
.installed.cfg
|
28 |
+
*.egg
|
29 |
+
MANIFEST
|
30 |
+
|
31 |
+
# PyInstaller
|
32 |
+
# Usually these files are written by a python script from a template
|
33 |
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
34 |
+
*.manifest
|
35 |
+
*.spec
|
36 |
+
|
37 |
+
# Installer logs
|
38 |
+
pip-log.txt
|
39 |
+
pip-delete-this-directory.txt
|
40 |
+
|
41 |
+
# Translations
|
42 |
+
*.mo
|
43 |
+
*.pot
|
44 |
+
|
45 |
+
# Django stuff:
|
46 |
+
*.log
|
47 |
+
local_settings.py
|
48 |
+
db.sqlite3
|
49 |
+
|
50 |
+
# Flask stuff:
|
51 |
+
instance
|
52 |
+
.webassets-cache
|
53 |
+
|
54 |
+
# Scrapy stuff:
|
55 |
+
.scrapy
|
56 |
+
|
57 |
+
# Sphinx documentation
|
58 |
+
docs/_build
|
59 |
+
|
60 |
+
# PyBuilder
|
61 |
+
target
|
62 |
+
|
63 |
+
# Jupyter Notebook
|
64 |
+
.ipynb_checkpoints
|
65 |
+
|
66 |
+
# IPython
|
67 |
+
profile_default
|
68 |
+
ipython_config.py
|
69 |
+
|
70 |
+
# pyenv
|
71 |
+
.python-version
|
72 |
+
|
73 |
+
# celery beat schedule file
|
74 |
+
celerybeat-schedule
|
75 |
+
|
76 |
+
# SageMath parsed files
|
77 |
+
*.sage.py
|
78 |
+
|
79 |
+
# Environments
|
80 |
+
.env
|
81 |
+
.venv
|
82 |
+
env
|
83 |
+
venv
|
84 |
+
ENV
|
85 |
+
env.bak
|
86 |
+
venv.bak
|
87 |
+
|
88 |
+
# Spyder project settings
|
89 |
+
.spyderproject
|
90 |
+
.spyproject
|
91 |
+
|
92 |
+
# Rope project settings
|
93 |
+
.ropeproject
|
94 |
+
|
95 |
+
# mypy
|
96 |
+
.mypy_cache
|
97 |
+
.dmypy.json
|
98 |
+
dmypy.json
|
99 |
+
|
100 |
+
# Pyre type checker
|
101 |
+
.pyre
|
img/plt.png
CHANGED
![]() |
![]() |
install-nodemon.sh
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
|
2 |
+
source .bashrc
|
3 |
+
nvm install node
|
4 |
+
npm install -g nodemon
|
okteto.yml
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: gradio-cmat
|
2 |
+
|
3 |
+
# The build section defines how to build the images of
|
4 |
+
# your development environment
|
5 |
+
# More info: https://www.okteto.com/docs/reference/manifest/#build
|
6 |
+
# build:
|
7 |
+
# my-service:
|
8 |
+
# context: .
|
9 |
+
|
10 |
+
# The deploy section defines how to deploy your development environment
|
11 |
+
# More info: https://www.okteto.com/docs/reference/manifest/#deploy
|
12 |
+
# deploy:
|
13 |
+
# commands:
|
14 |
+
# - name: Deploy
|
15 |
+
# command: echo 'Replace this line with the proper 'helm'
|
16 |
+
|
17 |
+
# or 'kubectl' commands to deploy your development environment'
|
18 |
+
|
19 |
+
# The dependencies section defines other git repositories to be
|
20 |
+
# deployed as part of your development environment
|
21 |
+
# More info: https://www.okteto.com/docs/reference/manifest/#dependencies
|
22 |
+
# dependencies:
|
23 |
+
# - https://github.com/okteto/sample
|
24 |
+
# The dev section defines how to activate a development container
|
25 |
+
# More info: https://www.okteto.com/docs/reference/manifest/#dev
|
26 |
+
dev:
|
27 |
+
gradio-cmat:
|
28 |
+
# image: okteto/dev:latest
|
29 |
+
# image: python:3.8.13-bullseye
|
30 |
+
# image: simbachain/poetry-3.8
|
31 |
+
image: python:3.8
|
32 |
+
command: bash
|
33 |
+
workdir: /usr/src/app
|
34 |
+
sync:
|
35 |
+
- .:/usr/src/app
|
36 |
+
environment:
|
37 |
+
- name=$USER
|
38 |
+
forward:
|
39 |
+
- 7861:7860
|
40 |
+
reverse:
|
41 |
+
- 9000:9000
|
42 |
+
autocreate: true
|
radiobee/__main__.py
CHANGED
@@ -45,6 +45,8 @@ import gradio as gr
|
|
45 |
from radiobee.process_upload import process_upload
|
46 |
from radiobee.gradiobee import gradiobee
|
47 |
|
|
|
|
|
48 |
ic_install()
|
49 |
ic.configureOutput(
|
50 |
includeContext=True,
|
@@ -360,7 +362,7 @@ if __name__ == "__main__":
|
|
360 |
out_df = gr.outputs.Dataframe(
|
361 |
headers=None,
|
362 |
max_rows=12, # 20
|
363 |
-
max_cols=
|
364 |
overflow_row_behaviour="paginate",
|
365 |
type="auto",
|
366 |
label="To be aligned",
|
@@ -373,6 +375,7 @@ if __name__ == "__main__":
|
|
373 |
type="auto",
|
374 |
label="aligned pairs",
|
375 |
)
|
|
|
376 |
out_file_dl = gr.outputs.File(
|
377 |
label="Click to download csv",
|
378 |
)
|
@@ -389,15 +392,15 @@ if __name__ == "__main__":
|
|
389 |
# modi outputs 1, definitions
|
390 |
|
391 |
# modi outputs 2, need to modify gradio error_msg
|
392 |
-
outputs = [ # tot. 8
|
393 |
-
|
394 |
out_file_dl,
|
395 |
out_file_dl_excel,
|
396 |
out_sents_dl,
|
397 |
out_sents_dl_excel,
|
398 |
-
out_df_aligned,
|
399 |
-
|
400 |
-
|
401 |
]
|
402 |
# outputs = ["dataframe", "plot", "plot"] # wont work
|
403 |
# outputs = ["dataframe"]
|
@@ -484,11 +487,10 @@ if __name__ == "__main__":
|
|
484 |
examples=examples,
|
485 |
examples_per_page=4,
|
486 |
# theme="darkgrass",
|
487 |
-
theme="grass",
|
488 |
# layout="vertical", # horizontal unaligned
|
489 |
allow_flagging="never", # "manual" "never" "auto"
|
490 |
-
|
491 |
-
# enable_queue=True, # moved to launch
|
492 |
)
|
493 |
|
494 |
iface.launch(
|
|
|
45 |
from radiobee.process_upload import process_upload
|
46 |
from radiobee.gradiobee import gradiobee
|
47 |
|
48 |
+
# pd.set_option('display.max_colwidth', 100)
|
49 |
+
|
50 |
ic_install()
|
51 |
ic.configureOutput(
|
52 |
includeContext=True,
|
|
|
362 |
out_df = gr.outputs.Dataframe(
|
363 |
headers=None,
|
364 |
max_rows=12, # 20
|
365 |
+
max_cols=2,
|
366 |
overflow_row_behaviour="paginate",
|
367 |
type="auto",
|
368 |
label="To be aligned",
|
|
|
375 |
type="auto",
|
376 |
label="aligned pairs",
|
377 |
)
|
378 |
+
out_html_aligned = gr.outputs.HTML(label="aligned")
|
379 |
out_file_dl = gr.outputs.File(
|
380 |
label="Click to download csv",
|
381 |
)
|
|
|
392 |
# modi outputs 1, definitions
|
393 |
|
394 |
# modi outputs 2, need to modify gradio error_msg
|
395 |
+
outputs = [ # tot. 8 or 7
|
396 |
+
gr.outputs.HTML(label="to be aligned"),
|
397 |
out_file_dl,
|
398 |
out_file_dl_excel,
|
399 |
out_sents_dl,
|
400 |
out_sents_dl_excel,
|
401 |
+
# out_df_aligned, # out_html_aligned,
|
402 |
+
gr.outputs.HTML(),
|
403 |
+
gr.outputs.Image(label="plot"),
|
404 |
]
|
405 |
# outputs = ["dataframe", "plot", "plot"] # wont work
|
406 |
# outputs = ["dataframe"]
|
|
|
487 |
examples=examples,
|
488 |
examples_per_page=4,
|
489 |
# theme="darkgrass",
|
490 |
+
# theme="grass",
|
491 |
# layout="vertical", # horizontal unaligned
|
492 |
allow_flagging="never", # "manual" "never" "auto"
|
493 |
+
css=f"{css_image} {css_input_file} {css_output_file}",
|
|
|
494 |
)
|
495 |
|
496 |
iface.launch(
|
radiobee/align_sents_pyc
ADDED
Binary file (1.56 kB). View file
|
|
radiobee/detect.py
CHANGED
@@ -76,6 +76,6 @@ def detect(text: str, set_languages: Optional[List[str]] = None) -> str:
|
|
76 |
|
77 |
# set_languages is set
|
78 |
if not isinstance(set_languages, (list, tuple)):
|
79 |
-
logger.warning("set_languages (%s) ought to be a list/tuple")
|
80 |
|
81 |
return def_lang
|
|
|
76 |
|
77 |
# set_languages is set
|
78 |
if not isinstance(set_languages, (list, tuple)):
|
79 |
+
logger.warning("set_languages (%s) ought to be a list/tuple", set_languages)
|
80 |
|
81 |
return def_lang
|
radiobee/en2zh_tokens_pyc
ADDED
Binary file (1.14 kB). View file
|
|
radiobee/gradiobee.py
CHANGED
@@ -47,6 +47,42 @@ debug = False
|
|
47 |
debug = True
|
48 |
|
49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
def gradiobee( # noqa
|
51 |
file1,
|
52 |
file2,
|
@@ -448,7 +484,12 @@ def gradiobee( # noqa
|
|
448 |
# return df_trimmed, file_dl, file_dl_xlsx, None, None, df_aligned, df_html
|
449 |
# return df_trimmed, file_dl, file_dl_xlsx, None, None, df_aligned, None
|
450 |
# return df_trimmed, file_dl, file_dl_xlsx, None, None, None, None
|
451 |
-
|
|
|
|
|
|
|
|
|
|
|
452 |
|
453 |
# ### proceed with sent align
|
454 |
if sent_ali_algo in ["fast"]:
|
@@ -510,4 +551,13 @@ def gradiobee( # noqa
|
|
510 |
|
511 |
# remove output_plot, need to modify all return and error_msg.error_msg
|
512 |
# return df_trimmed, file_dl, file_dl_xlsx, file_dl_sents, file_dl_xlsx_sents, df_aligned_sents, df_html
|
513 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
debug = True
|
48 |
|
49 |
|
50 |
+
def style0(df):
|
51 |
+
_ = df.style.set_properties(
|
52 |
+
**{
|
53 |
+
"font-size": "8pt",
|
54 |
+
"border-color": "green",
|
55 |
+
# "border": ".11px black solid !important",
|
56 |
+
'width': '1500px'
|
57 |
+
}
|
58 |
+
# border-color="black",
|
59 |
+
).set_table_styles([{
|
60 |
+
"selector": "", # noqs
|
61 |
+
"props": [("border", ".05px black solid !important")]}] # noqs
|
62 |
+
).format(
|
63 |
+
precision=2
|
64 |
+
)
|
65 |
+
return _.to_html()
|
66 |
+
|
67 |
+
|
68 |
+
def style1(df):
|
69 |
+
_ = df.style.set_properties(
|
70 |
+
**{
|
71 |
+
"font-size": "10pt",
|
72 |
+
"border-color": "green",
|
73 |
+
"border": "1px black solid !important",
|
74 |
+
'width': '1900px'
|
75 |
+
}
|
76 |
+
# border-color="black",
|
77 |
+
).set_table_styles([{
|
78 |
+
"selector": "", # noqs
|
79 |
+
"props": [("border", "1.2px black solid !important")]}] # noqs
|
80 |
+
).format(
|
81 |
+
precision=2
|
82 |
+
)
|
83 |
+
return _.to_html()
|
84 |
+
|
85 |
+
|
86 |
def gradiobee( # noqa
|
87 |
file1,
|
88 |
file2,
|
|
|
484 |
# return df_trimmed, file_dl, file_dl_xlsx, None, None, df_aligned, df_html
|
485 |
# return df_trimmed, file_dl, file_dl_xlsx, None, None, df_aligned, None
|
486 |
# return df_trimmed, file_dl, file_dl_xlsx, None, None, None, None
|
487 |
+
|
488 |
+
to_be_alinged = style0(df_trimmed)
|
489 |
+
done_alinged = style1(trim_df(df_aligned, 40))
|
490 |
+
|
491 |
+
# modi#
|
492 |
+
return to_be_alinged, file_dl, file_dl_xlsx, None, None, done_alinged, output_plot
|
493 |
|
494 |
# ### proceed with sent align
|
495 |
if sent_ali_algo in ["fast"]:
|
|
|
551 |
|
552 |
# remove output_plot, need to modify all return and error_msg.error_msg
|
553 |
# return df_trimmed, file_dl, file_dl_xlsx, file_dl_sents, file_dl_xlsx_sents, df_aligned_sents, df_html
|
554 |
+
|
555 |
+
|
556 |
+
to_be_alinged = style0(df_trimmed)
|
557 |
+
done_alinged = style1(trim_df(df_aligned_sents, 40))
|
558 |
+
|
559 |
+
ic(" checkpoint ")
|
560 |
+
|
561 |
+
# modi#
|
562 |
+
# return to_be_alinged, file_dl, file_dl_xlsx, file_dl_sents, file_dl_xlsx_sents, df_aligned_sents
|
563 |
+
return to_be_alinged, file_dl, file_dl_xlsx, file_dl_sents, file_dl_xlsx_sents, done_alinged, output_plot
|
radiobee/paras2sents_pyc
ADDED
Binary file (2.83 kB). View file
|
|
radiobee/shuffle_sents_pyc
ADDED
Binary file (2.02 kB). View file
|
|
radiobee/trim_df.py
CHANGED
@@ -6,6 +6,7 @@ import pandas as pd
|
|
6 |
def trim_df(
|
7 |
df1: pd.DataFrame,
|
8 |
len_: int = 4,
|
|
|
9 |
) -> pd.DataFrame:
|
10 |
# fmt: on
|
11 |
"""Trim df."""
|
@@ -14,17 +15,13 @@ def trim_df(
|
|
14 |
[
|
15 |
df1.iloc[:len_, :],
|
16 |
pd.DataFrame(
|
17 |
-
[
|
18 |
-
|
19 |
-
"...",
|
20 |
-
"...",
|
21 |
-
]
|
22 |
-
],
|
23 |
columns=df1.columns,
|
24 |
),
|
25 |
df1.iloc[-len_:, :],
|
26 |
],
|
27 |
-
ignore_index=
|
28 |
)
|
29 |
return df_trimmed
|
30 |
return df1
|
|
|
6 |
def trim_df(
|
7 |
df1: pd.DataFrame,
|
8 |
len_: int = 4,
|
9 |
+
ignore_index: bool = True,
|
10 |
) -> pd.DataFrame:
|
11 |
# fmt: on
|
12 |
"""Trim df."""
|
|
|
15 |
[
|
16 |
df1.iloc[:len_, :],
|
17 |
pd.DataFrame(
|
18 |
+
# [["...", "...",]],
|
19 |
+
[["..."] * len(df1.columns)],
|
|
|
|
|
|
|
|
|
20 |
columns=df1.columns,
|
21 |
),
|
22 |
df1.iloc[-len_:, :],
|
23 |
],
|
24 |
+
ignore_index=ignore_index,
|
25 |
)
|
26 |
return df_trimmed
|
27 |
return df1
|
run-nodemon.sh
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
nodemon -V -w radiobee -x python -m radiobee
|