Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -103,61 +103,37 @@ css = """
|
|
| 103 |
#qwen-md .katex-display>.katex { display: inline; }
|
| 104 |
#qwen-md .katex-display>.katex>.katex-html { display: inline; }
|
| 105 |
"""
|
|
|
|
| 106 |
def tabs_select(e: gr.SelectData, _state):
|
| 107 |
_state["tab_index"] = e.index
|
|
|
|
| 108 |
|
| 109 |
with gr.Blocks(css=css) as demo:
|
| 110 |
-
|
| 111 |
state = gr.State({"tab_index": 0})
|
|
|
|
| 112 |
with gr.Row():
|
| 113 |
with gr.Column():
|
| 114 |
with gr.Tabs() as input_tabs:
|
| 115 |
with gr.Tab("Upload"):
|
| 116 |
-
input_image = gr.Image(type="pil", label="Upload")
|
| 117 |
with gr.Tab("Sketch"):
|
| 118 |
input_sketchpad = gr.Sketchpad(type="pil", label="Sketch", layers=False)
|
| 119 |
-
|
| 120 |
-
|
|
|
|
|
|
|
| 121 |
with gr.Row():
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
with gr.Column():
|
| 126 |
-
submit_btn = gr.Button("Submit", variant="primary")
|
| 127 |
with gr.Column():
|
| 128 |
-
output_md = gr.Markdown(label="
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
}, {
|
| 138 |
-
"left": "\\begin\{align\}",
|
| 139 |
-
"right": "\\end\{align\}",
|
| 140 |
-
"display": True
|
| 141 |
-
}, {
|
| 142 |
-
"left": "\\begin\{alignat\}",
|
| 143 |
-
"right": "\\end\{alignat\}",
|
| 144 |
-
"display": True
|
| 145 |
-
}, {
|
| 146 |
-
"left": "\\begin\{gather\}",
|
| 147 |
-
"right": "\\end\{gather\}",
|
| 148 |
-
"display": True
|
| 149 |
-
}, {
|
| 150 |
-
"left": "\\begin\{CD\}",
|
| 151 |
-
"right": "\\end\{CD\}",
|
| 152 |
-
"display": True
|
| 153 |
-
}, {
|
| 154 |
-
"left": "\\[",
|
| 155 |
-
"right": "\\]",
|
| 156 |
-
"display": True
|
| 157 |
-
}],
|
| 158 |
-
elem_id="qwen-md")
|
| 159 |
-
submit_btn.click(
|
| 160 |
-
fn=math_chat_bot,
|
| 161 |
-
inputs=[*input_image, input_sketchpad, input_text, state],
|
| 162 |
-
outputs=output_md)
|
| 163 |
demo.launch()
|
|
|
|
| 103 |
#qwen-md .katex-display>.katex { display: inline; }
|
| 104 |
#qwen-md .katex-display>.katex>.katex-html { display: inline; }
|
| 105 |
"""
|
| 106 |
+
|
| 107 |
def tabs_select(e: gr.SelectData, _state):
|
| 108 |
_state["tab_index"] = e.index
|
| 109 |
+
return _state
|
| 110 |
|
| 111 |
with gr.Blocks(css=css) as demo:
|
|
|
|
| 112 |
state = gr.State({"tab_index": 0})
|
| 113 |
+
|
| 114 |
with gr.Row():
|
| 115 |
with gr.Column():
|
| 116 |
with gr.Tabs() as input_tabs:
|
| 117 |
with gr.Tab("Upload"):
|
| 118 |
+
input_image = gr.Image(type="pil", label="Upload")
|
| 119 |
with gr.Tab("Sketch"):
|
| 120 |
input_sketchpad = gr.Sketchpad(type="pil", label="Sketch", layers=False)
|
| 121 |
+
|
| 122 |
+
input_tabs.select(fn=tabs_select, inputs=[state], outputs=[state])
|
| 123 |
+
|
| 124 |
+
input_text = gr.Textbox(label="Input your question")
|
| 125 |
with gr.Row():
|
| 126 |
+
clear_btn = gr.ClearButton([input_image, input_sketchpad, input_text])
|
| 127 |
+
submit_btn = gr.Button("Submit", variant="primary")
|
| 128 |
+
|
|
|
|
|
|
|
| 129 |
with gr.Column():
|
| 130 |
+
output_md = gr.Markdown(label="Answer", elem_id="qwen-md")
|
| 131 |
+
|
| 132 |
+
submit_btn.click(
|
| 133 |
+
fn=math_chat_bot,
|
| 134 |
+
inputs=[input_image, input_sketchpad, input_text, state],
|
| 135 |
+
outputs=output_md,
|
| 136 |
+
streaming=True
|
| 137 |
+
)
|
| 138 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
demo.launch()
|