Spaces:
Running
Running
update ui
Browse files
app.py
CHANGED
@@ -9,9 +9,10 @@ import time
|
|
9 |
|
10 |
DESCRIPTION = '''# <a href="https://github.com/THUDM/VisualGLM">VisualGLM</a>'''
|
11 |
|
12 |
-
|
|
|
13 |
|
14 |
-
NOTES = 'This app is adapted from <a href="https://github.com/THUDM/VisualGLM">https://github.com/THUDM/VisualGLM</a>. It would be recommended to check out the repo if you want to see the detail of our model
|
15 |
|
16 |
import json
|
17 |
import requests
|
@@ -109,6 +110,13 @@ def clear_fn2(value):
|
|
109 |
return [("", "Hi, What do you want to know about this image?")]
|
110 |
|
111 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
def main():
|
113 |
gr.close_all()
|
114 |
examples = []
|
@@ -119,13 +127,9 @@ def main():
|
|
119 |
|
120 |
|
121 |
with gr.Blocks(css='style.css') as demo:
|
122 |
-
|
123 |
-
gr.Markdown(DESCRIPTION)
|
124 |
-
gr.Markdown(MAINTENANCE_NOTICE)
|
125 |
-
|
126 |
|
127 |
with gr.Row():
|
128 |
-
with gr.Column():
|
129 |
with gr.Group():
|
130 |
input_text = gr.Textbox(label='Input Text', placeholder='Please enter text prompt below and press ENTER.')
|
131 |
with gr.Row():
|
@@ -136,8 +140,15 @@ def main():
|
|
136 |
with gr.Row():
|
137 |
temperature = gr.Slider(maximum=1, value=0.95, minimum=0, label='Temperature')
|
138 |
top_p = gr.Slider(maximum=1, value=0.7, minimum=0, label='Top P')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
|
140 |
-
result_text = gr.components.Chatbot(label='Multi-round conversation History', value=[("", "Hi, What do you want to know about this image?")])
|
141 |
|
142 |
|
143 |
gr_examples = gr.Examples(examples=[[example["text"], example["image"]] for example in examples],
|
@@ -155,6 +166,8 @@ def main():
|
|
155 |
clear_button.click(fn=clear_fn, inputs=clear_button, outputs=[input_text, result_text, image_prompt])
|
156 |
image_prompt.change(fn=clear_fn2, inputs=clear_button, outputs=[result_text])
|
157 |
|
|
|
|
|
158 |
print(gr.__version__)
|
159 |
|
160 |
|
|
|
9 |
|
10 |
DESCRIPTION = '''# <a href="https://github.com/THUDM/VisualGLM">VisualGLM</a>'''
|
11 |
|
12 |
+
MAINTENANCE_NOTICE1 = 'Hint 1: If the app report "Something went wrong, connection error out", please turn off your proxy and retry.\nHint 2: If you upload a large size of image like 10MB, it may take some time to upload and process. Please be patient and wait.'
|
13 |
+
MAINTENANCE_NOTICE2 = '提示1: 如果应用报了“Something went wrong, connection error out”的错误,请关闭代理并重试。\n提示2: 如果你上传了很大的图片,比如10MB大小,那将需要一些时间来上传和处理,请耐心等待。'
|
14 |
|
15 |
+
NOTES = 'This app is adapted from <a href="https://github.com/THUDM/VisualGLM">https://github.com/THUDM/VisualGLM</a>. It would be recommended to check out the repo if you want to see the detail of our model.'
|
16 |
|
17 |
import json
|
18 |
import requests
|
|
|
110 |
return [("", "Hi, What do you want to know about this image?")]
|
111 |
|
112 |
|
113 |
+
def change_language(value):
|
114 |
+
if value == "Change hint to English":
|
115 |
+
return "提示变为中文", MAINTENANCE_NOTICE1
|
116 |
+
else:
|
117 |
+
return "Change hint to English", MAINTENANCE_NOTICE2
|
118 |
+
|
119 |
+
|
120 |
def main():
|
121 |
gr.close_all()
|
122 |
examples = []
|
|
|
127 |
|
128 |
|
129 |
with gr.Blocks(css='style.css') as demo:
|
|
|
|
|
|
|
|
|
130 |
|
131 |
with gr.Row():
|
132 |
+
with gr.Column(scale=4.5):
|
133 |
with gr.Group():
|
134 |
input_text = gr.Textbox(label='Input Text', placeholder='Please enter text prompt below and press ENTER.')
|
135 |
with gr.Row():
|
|
|
140 |
with gr.Row():
|
141 |
temperature = gr.Slider(maximum=1, value=0.95, minimum=0, label='Temperature')
|
142 |
top_p = gr.Slider(maximum=1, value=0.7, minimum=0, label='Top P')
|
143 |
+
with gr.Group():
|
144 |
+
with gr.Row():
|
145 |
+
with gr.Column(scale=7):
|
146 |
+
maintenance_notice = gr.Markdown(MAINTENANCE_NOTICE1)
|
147 |
+
with gr.Column(scale=2):
|
148 |
+
change_button = gr.Button('Change hint to English', visible=False)
|
149 |
+
with gr.Column(scale=5.5):
|
150 |
+
result_text = gr.components.Chatbot(label='Multi-round conversation History', value=[("", "Hi, What do you want to know about this image?")]).style(height=550)
|
151 |
|
|
|
152 |
|
153 |
|
154 |
gr_examples = gr.Examples(examples=[[example["text"], example["image"]] for example in examples],
|
|
|
166 |
clear_button.click(fn=clear_fn, inputs=clear_button, outputs=[input_text, result_text, image_prompt])
|
167 |
image_prompt.change(fn=clear_fn2, inputs=clear_button, outputs=[result_text])
|
168 |
|
169 |
+
change_button.click(fn=change_language, inputs=change_button, outputs=[change_button, maintenance_notice])
|
170 |
+
|
171 |
print(gr.__version__)
|
172 |
|
173 |
|