Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -71,103 +71,24 @@ def process_answer(img, answer):
|
|
71 |
|
72 |
return gr.update(visible=False, value=None)
|
73 |
|
74 |
-
|
75 |
-
.
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
.
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
.
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
margin-top: 10px;
|
94 |
-
}
|
95 |
-
|
96 |
-
.github-link:hover {
|
97 |
-
background-color: #2f363d;
|
98 |
-
}
|
99 |
-
|
100 |
-
.input-section {
|
101 |
-
margin: 20px 0;
|
102 |
-
}
|
103 |
-
|
104 |
-
.response-section {
|
105 |
-
margin-top: 20px;
|
106 |
-
padding: 20px;
|
107 |
-
border-radius: 8px;
|
108 |
-
background-color: #f8f9fa;
|
109 |
-
}
|
110 |
-
"""
|
111 |
-
|
112 |
-
with gr.Blocks(css=custom_css) as demo:
|
113 |
-
with gr.Column(elem_classes="container"):
|
114 |
-
gr.Markdown(
|
115 |
-
"""
|
116 |
-
<div class="header">
|
117 |
-
# 🌔 Moondream VL
|
118 |
-
### A Tiny Vision Language Model
|
119 |
-
<a href="https://github.com/vikhyat/moondream" class="github-link" target="_blank">
|
120 |
-
📦 GitHub Repository
|
121 |
-
</a>
|
122 |
-
</div>
|
123 |
-
""",
|
124 |
-
elem_classes="header"
|
125 |
-
)
|
126 |
-
|
127 |
-
with gr.Column(elem_classes="input-section"):
|
128 |
-
img = gr.Image(
|
129 |
-
type="pil",
|
130 |
-
label="Upload an Image",
|
131 |
-
elem_id="image-upload",
|
132 |
-
height=400
|
133 |
-
)
|
134 |
-
|
135 |
-
with gr.Row():
|
136 |
-
prompt = gr.Textbox(
|
137 |
-
label="Your Question",
|
138 |
-
placeholder="Ask something about the image...",
|
139 |
-
value="Describe this image.",
|
140 |
-
scale=4
|
141 |
-
)
|
142 |
-
submit = gr.Button(
|
143 |
-
"✨ Analyze",
|
144 |
-
variant="primary",
|
145 |
-
scale=1
|
146 |
-
)
|
147 |
-
|
148 |
-
with gr.Column(elem_classes="response-section"):
|
149 |
-
output = gr.Markdown(label="AI Response")
|
150 |
-
ann = gr.Image(
|
151 |
-
visible=False,
|
152 |
-
label="Annotated Image"
|
153 |
-
)
|
154 |
-
|
155 |
-
# Event handlers
|
156 |
-
submit.click(
|
157 |
-
answer_question,
|
158 |
-
inputs=[img, prompt],
|
159 |
-
outputs=output
|
160 |
-
)
|
161 |
-
prompt.submit(
|
162 |
-
answer_question,
|
163 |
-
inputs=[img, prompt],
|
164 |
-
outputs=output
|
165 |
-
)
|
166 |
-
output.change(
|
167 |
-
process_answer,
|
168 |
-
inputs=[img, output],
|
169 |
-
outputs=ann,
|
170 |
-
show_progress=False
|
171 |
-
)
|
172 |
|
173 |
demo.queue().launch()
|
|
|
71 |
|
72 |
return gr.update(visible=False, value=None)
|
73 |
|
74 |
+
with gr.Blocks() as demo:
|
75 |
+
gr.Markdown(
|
76 |
+
"""
|
77 |
+
# 🌔 moondream vl (new)
|
78 |
+
A tiny vision language model. [GitHub](https://github.com/vikhyat/moondream)
|
79 |
+
"""
|
80 |
+
)
|
81 |
+
with gr.Row():
|
82 |
+
prompt = gr.Textbox(label="Input", value="Describe this image.", scale=4)
|
83 |
+
submit = gr.Button("Submit")
|
84 |
+
with gr.Row():
|
85 |
+
img = gr.Image(type="pil", label="Upload an Image")
|
86 |
+
with gr.Column():
|
87 |
+
output = gr.Markdown(label="Response")
|
88 |
+
ann = gr.Image(visible=False, label="Annotated Image")
|
89 |
+
|
90 |
+
submit.click(answer_question, [img, prompt], output)
|
91 |
+
prompt.submit(answer_question, [img, prompt], output)
|
92 |
+
output.change(process_answer, [img, output], ann, show_progress=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
|
94 |
demo.queue().launch()
|