Spaces:
Running
Running
Merge branch 'main' of https://huggingface.co./spaces/yizhangliu/Text-to-Image
Browse files
app.py
CHANGED
@@ -7,27 +7,31 @@ import torch
|
|
7 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
8 |
from loguru import logger
|
9 |
|
|
|
10 |
import subprocess
|
11 |
|
12 |
result = subprocess.run(['pip', 'list'], check=True)
|
13 |
print(f'pip list = {result}')
|
14 |
|
15 |
-
|
|
|
|
|
16 |
def getTextTrans(text, source='zh', target='en'):
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
|
|
22 |
|
23 |
-
if not is_chinese(text) and target == 'en':
|
24 |
-
|
25 |
|
26 |
-
try:
|
27 |
-
|
28 |
-
|
29 |
-
except Exception as e:
|
30 |
-
|
31 |
|
32 |
space_ids = {
|
33 |
"spaces/stabilityai/stable-diffusion": "SD 2.1",
|
@@ -392,5 +396,4 @@ with gr.Blocks(title='Text-to-Image') as demo:
|
|
392 |
draw_btn_0.click(fn=prompt_draw_2, inputs=[prompt_input0], outputs=[prompt_work, prompt_work_zh])
|
393 |
draw_btn_1.click(fn=prompt_draw_2, inputs=[prompt_input1], outputs=[prompt_work, prompt_work_zh])
|
394 |
|
395 |
-
demo.queue()
|
396 |
-
demo.launch()
|
|
|
7 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
8 |
from loguru import logger
|
9 |
|
10 |
+
from utils import get_tmt_client, getTextTrans_tmt
|
11 |
import subprocess
|
12 |
|
13 |
result = subprocess.run(['pip', 'list'], check=True)
|
14 |
print(f'pip list = {result}')
|
15 |
|
16 |
+
tmt_client = get_tmt_client()
|
17 |
+
|
18 |
+
# language_translation_model = hub.Module(directory=f'./baidu_translate')
|
19 |
def getTextTrans(text, source='zh', target='en'):
|
20 |
+
return getTextTrans_tmt(tmt_client, text, source, target)
|
21 |
+
# def is_chinese(string):
|
22 |
+
# for ch in string:
|
23 |
+
# if u'\u4e00' <= ch <= u'\u9fff':
|
24 |
+
# return True
|
25 |
+
# return False
|
26 |
|
27 |
+
# if not is_chinese(text) and target == 'en':
|
28 |
+
# return text
|
29 |
|
30 |
+
# try:
|
31 |
+
# text_translation = language_translation_model.translate(text, source, target)
|
32 |
+
# return text_translation
|
33 |
+
# except Exception as e:
|
34 |
+
# return text
|
35 |
|
36 |
space_ids = {
|
37 |
"spaces/stabilityai/stable-diffusion": "SD 2.1",
|
|
|
396 |
draw_btn_0.click(fn=prompt_draw_2, inputs=[prompt_input0], outputs=[prompt_work, prompt_work_zh])
|
397 |
draw_btn_1.click(fn=prompt_draw_2, inputs=[prompt_input1], outputs=[prompt_work, prompt_work_zh])
|
398 |
|
399 |
+
demo.queue(concurrency_count=128).launch()
|
|