Spaces:
Runtime error
Runtime error
fix
Browse files
app.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import numpy as np
|
2 |
import gradio as gr
|
3 |
import paddlehub as hub
|
4 |
-
|
5 |
|
6 |
|
7 |
model = hub.Module(name='ernie_vilg')
|
@@ -10,7 +10,7 @@ language_model = hub.Module(name='baidu_translate')
|
|
10 |
style_list = ['水彩','油画', '粉笔画', '卡通', '蜡笔画', '儿童画', '探索无限']
|
11 |
language_list = ['zh', 'en', 'jp', 'kor']
|
12 |
def inference(text_prompts, language_indx, style_indx):
|
13 |
-
print(datetime.now()
|
14 |
try:
|
15 |
style = style_list[style_indx]
|
16 |
if language_indx != 0:
|
@@ -18,11 +18,11 @@ def inference(text_prompts, language_indx, style_indx):
|
|
18 |
text_prompts = language_model.translate(text_prompts, language, 'zh')
|
19 |
results = model.generate_image(
|
20 |
text_prompts=text_prompts, style=style, visualization=False)
|
21 |
-
print(datetime.now()
|
22 |
return 'Success', results[:6]
|
23 |
except Exception as e:
|
24 |
error_text = str(e)
|
25 |
-
print(datetime.now()
|
26 |
return error_text, None
|
27 |
return
|
28 |
|
|
|
1 |
import numpy as np
|
2 |
import gradio as gr
|
3 |
import paddlehub as hub
|
4 |
+
import datetime
|
5 |
|
6 |
|
7 |
model = hub.Module(name='ernie_vilg')
|
|
|
10 |
style_list = ['水彩','油画', '粉笔画', '卡通', '蜡笔画', '儿童画', '探索无限']
|
11 |
language_list = ['zh', 'en', 'jp', 'kor']
|
12 |
def inference(text_prompts, language_indx, style_indx):
|
13 |
+
print(datetime.datetime.now())
|
14 |
try:
|
15 |
style = style_list[style_indx]
|
16 |
if language_indx != 0:
|
|
|
18 |
text_prompts = language_model.translate(text_prompts, language, 'zh')
|
19 |
results = model.generate_image(
|
20 |
text_prompts=text_prompts, style=style, visualization=False)
|
21 |
+
print(datetime.datetime.now())
|
22 |
return 'Success', results[:6]
|
23 |
except Exception as e:
|
24 |
error_text = str(e)
|
25 |
+
print(datetime.datetime.now())
|
26 |
return error_text, None
|
27 |
return
|
28 |
|