Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -62,83 +62,101 @@ def generate_output(image, text, button_click):
|
|
| 62 |
print(f"Error: {e}")
|
| 63 |
yield f"Error occurred: {str(e)}"
|
| 64 |
|
| 65 |
-
|
| 66 |
-
#output-markdown {
|
| 67 |
-
overflow-y: auto;
|
| 68 |
-
white-space: pre-wrap;
|
| 69 |
-
word-wrap: break-word;
|
| 70 |
-
}
|
| 71 |
-
|
| 72 |
-
#output-markdown .math {
|
| 73 |
-
overflow-x: auto;
|
| 74 |
-
max-width: 100%;
|
| 75 |
-
}
|
| 76 |
-
.markdown-text {
|
| 77 |
-
white-space: pre-wrap;
|
| 78 |
-
word-wrap: break-word;
|
| 79 |
-
}
|
| 80 |
-
#qwen-md .katex-display { display: inline; }
|
| 81 |
-
#qwen-md .katex-display>.katex { display: inline; }
|
| 82 |
-
#qwen-md .katex-display>.katex>.katex-html { display: inline; }
|
| 83 |
-
"""
|
| 84 |
-
|
| 85 |
-
# UI 组件
|
| 86 |
-
with gr.Blocks(css=Css) as demo:
|
| 87 |
gr.HTML("""<center><font size=8>🦖 R1-OneVision Demo</center>""")
|
| 88 |
|
| 89 |
with gr.Row():
|
| 90 |
with gr.Column():
|
| 91 |
-
input_image = gr.Image(type="pil", label="Upload")
|
| 92 |
-
input_text = gr.Textbox(label="
|
| 93 |
with gr.Row():
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
with gr.Column():
|
| 97 |
-
submit_btn = gr.Button("Submit", variant="primary")
|
| 98 |
|
| 99 |
with gr.Column():
|
| 100 |
-
output_text = gr.Markdown(
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
demo.launch(share=True)
|
|
|
|
| 62 |
print(f"Error: {e}")
|
| 63 |
yield f"Error occurred: {str(e)}"
|
| 64 |
|
| 65 |
+
with gr.Blocks() as demo:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
gr.HTML("""<center><font size=8>🦖 R1-OneVision Demo</center>""")
|
| 67 |
|
| 68 |
with gr.Row():
|
| 69 |
with gr.Column():
|
| 70 |
+
input_image = gr.Image(type="pil", label="Upload") # **改回 PIL 处理**
|
| 71 |
+
input_text = gr.Textbox(label="Input your question")
|
| 72 |
with gr.Row():
|
| 73 |
+
clear_btn = gr.ClearButton([input_image, input_text])
|
| 74 |
+
submit_btn = gr.Button("Submit", variant="primary")
|
|
|
|
|
|
|
| 75 |
|
| 76 |
with gr.Column():
|
| 77 |
+
output_text = gr.Markdown(elem_id="qwen-md", container=True)
|
| 78 |
+
|
| 79 |
+
submit_btn.click(fn=generate_output, inputs=[input_image, input_text], outputs=output_text)
|
| 80 |
+
|
| 81 |
+
demo.launch(share=True)
|
| 82 |
+
|
| 83 |
+
# Css = """
|
| 84 |
+
# #output-markdown {
|
| 85 |
+
# overflow-y: auto;
|
| 86 |
+
# white-space: pre-wrap;
|
| 87 |
+
# word-wrap: break-word;
|
| 88 |
+
# }
|
| 89 |
+
|
| 90 |
+
# #output-markdown .math {
|
| 91 |
+
# overflow-x: auto;
|
| 92 |
+
# max-width: 100%;
|
| 93 |
+
# }
|
| 94 |
+
# .markdown-text {
|
| 95 |
+
# white-space: pre-wrap;
|
| 96 |
+
# word-wrap: break-word;
|
| 97 |
+
# }
|
| 98 |
+
# #qwen-md .katex-display { display: inline; }
|
| 99 |
+
# #qwen-md .katex-display>.katex { display: inline; }
|
| 100 |
+
# #qwen-md .katex-display>.katex>.katex-html { display: inline; }
|
| 101 |
+
# """
|
| 102 |
+
|
| 103 |
+
# # UI 组件
|
| 104 |
+
# with gr.Blocks(css=Css) as demo:
|
| 105 |
+
# gr.HTML("""<center><font size=8>🦖 R1-OneVision Demo</center>""")
|
| 106 |
+
|
| 107 |
+
# with gr.Row():
|
| 108 |
+
# with gr.Column():
|
| 109 |
+
# input_image = gr.Image(type="pil", label="Upload")
|
| 110 |
+
# input_text = gr.Textbox(label="input your question")
|
| 111 |
+
# with gr.Row():
|
| 112 |
+
# with gr.Column():
|
| 113 |
+
# clear_btn = gr.ClearButton([input_image, input_text])
|
| 114 |
+
# with gr.Column():
|
| 115 |
+
# submit_btn = gr.Button("Submit", variant="primary")
|
| 116 |
+
|
| 117 |
+
# with gr.Column():
|
| 118 |
+
# output_text = gr.Markdown(
|
| 119 |
+
# label="Generated Response",
|
| 120 |
+
# max_height="80vh",
|
| 121 |
+
# min_height="50vh",
|
| 122 |
+
# container=True,
|
| 123 |
+
# latex_delimiters=[{
|
| 124 |
+
# "left": "\\(",
|
| 125 |
+
# "right": "\\)",
|
| 126 |
+
# "display": True
|
| 127 |
+
# }, {
|
| 128 |
+
# "left": "\\begin\{equation\}",
|
| 129 |
+
# "right": "\\end\{equation\}",
|
| 130 |
+
# "display": True
|
| 131 |
+
# }, {
|
| 132 |
+
# "left": "\\begin\{align\}",
|
| 133 |
+
# "right": "\\end\{align\}",
|
| 134 |
+
# "display": True
|
| 135 |
+
# }, {
|
| 136 |
+
# "left": "\\begin\{alignat\}",
|
| 137 |
+
# "right": "\\end\{alignat\}",
|
| 138 |
+
# "display": True
|
| 139 |
+
# }, {
|
| 140 |
+
# "left": "\\begin\{gather\}",
|
| 141 |
+
# "right": "\\end\{gather\}",
|
| 142 |
+
# "display": True
|
| 143 |
+
# }, {
|
| 144 |
+
# "left": "\\begin\{CD\}",
|
| 145 |
+
# "right": "\\end\{CD\}",
|
| 146 |
+
# "display": True
|
| 147 |
+
# }, {
|
| 148 |
+
# "left": "\\[",
|
| 149 |
+
# "right": "\\]",
|
| 150 |
+
# "display": True
|
| 151 |
+
# }],
|
| 152 |
+
# elem_id="qwen-md")
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
+
# submit_btn.click(
|
| 157 |
+
# fn=generate_output,
|
| 158 |
+
# inputs=[input_image, input_text],
|
| 159 |
+
# outputs=output_text,
|
| 160 |
+
# queue=True
|
| 161 |
+
# )
|
| 162 |
+
# demo.launch(share=True)
|