Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -7,6 +7,8 @@ import pandas as pd
|
|
7 |
import random
|
8 |
import string
|
9 |
import re
|
|
|
|
|
10 |
|
11 |
# 2. Constants
|
12 |
# Translation
|
@@ -40,7 +42,11 @@ NAMES = pd.DataFrame({
|
|
40 |
})
|
41 |
|
42 |
|
43 |
-
|
|
|
|
|
|
|
|
|
44 |
|
45 |
# 3. Upload
|
46 |
# Dictionary
|
@@ -403,7 +409,7 @@ def translateDisp(text, from_, to, dialect):
|
|
403 |
to = "".join(LANGUAGE[LANGUAGE.language == to].token.to_list())
|
404 |
dialect = "".join(DIALECT[DIALECT.dialect == dialect].short_name.to_list())
|
405 |
|
406 |
-
print(f'Input text: {text}')
|
407 |
|
408 |
text = text.strip()
|
409 |
|
@@ -429,7 +435,7 @@ def translateDisp(text, from_, to, dialect):
|
|
429 |
if to == 'krc_Cyrl':
|
430 |
str_ = fromModel(str_, dialect = dialect)
|
431 |
|
432 |
-
print(f'Translated text: {str_}')
|
433 |
|
434 |
return str_
|
435 |
|
|
|
7 |
import random
|
8 |
import string
|
9 |
import re
|
10 |
+
from datetime import datetime
|
11 |
+
import pytz
|
12 |
|
13 |
# 2. Constants
|
14 |
# Translation
|
|
|
42 |
})
|
43 |
|
44 |
|
45 |
+
DEVICE = 'gpu' if torch.cuda.is_available() else 'cpu'
|
46 |
+
|
47 |
+
device = torch.device(DEVICE)
|
48 |
+
|
49 |
+
TZ = pytz.timezone('Europe/Moscow')
|
50 |
|
51 |
# 3. Upload
|
52 |
# Dictionary
|
|
|
409 |
to = "".join(LANGUAGE[LANGUAGE.language == to].token.to_list())
|
410 |
dialect = "".join(DIALECT[DIALECT.dialect == dialect].short_name.to_list())
|
411 |
|
412 |
+
print(f'Input text: {text} - Time: {datetime.now(tz=TZ)}')
|
413 |
|
414 |
text = text.strip()
|
415 |
|
|
|
435 |
if to == 'krc_Cyrl':
|
436 |
str_ = fromModel(str_, dialect = dialect)
|
437 |
|
438 |
+
print(f'Translated text: {str_} - Time: {datetime.now(tz=TZ)}')
|
439 |
|
440 |
return str_
|
441 |
|