Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
REVISION = "
|
| 2 |
|
| 3 |
try:
|
| 4 |
import spaces
|
|
@@ -145,17 +145,20 @@ def caption(img, mode):
|
|
| 145 |
yield buffer.strip()
|
| 146 |
|
| 147 |
@spaces.GPU(duration=10)
|
| 148 |
-
def detect(img, object):
|
| 149 |
if img is None:
|
| 150 |
yield "", gr.update(visible=False, value=None)
|
| 151 |
return
|
| 152 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 153 |
w, h = img.size
|
| 154 |
if w > 768 or h > 768:
|
| 155 |
img = Resize(768)(img)
|
| 156 |
w, h = img.size
|
| 157 |
|
| 158 |
-
objs = moondream.detect(img, object)["objects"]
|
| 159 |
draw_image = ImageDraw.Draw(img)
|
| 160 |
for o in objs:
|
| 161 |
draw_image.rectangle(
|
|
@@ -295,9 +298,10 @@ with gr.Blocks(title="moondream vl (new)", css=css, js=js) as demo:
|
|
| 295 |
)
|
| 296 |
submit = gr.Button("Submit")
|
| 297 |
img = gr.Image(type="pil", label="Upload an Image")
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
|
|
|
| 301 |
elif mode == "Point":
|
| 302 |
with gr.Group():
|
| 303 |
with gr.Row():
|
|
|
|
| 1 |
+
REVISION = "e260c8a27acb2bb5fcc64537bb1b52b588dd575a"
|
| 2 |
|
| 3 |
try:
|
| 4 |
import spaces
|
|
|
|
| 145 |
yield buffer.strip()
|
| 146 |
|
| 147 |
@spaces.GPU(duration=10)
|
| 148 |
+
def detect(img, object, eos_bias):
|
| 149 |
if img is None:
|
| 150 |
yield "", gr.update(visible=False, value=None)
|
| 151 |
return
|
| 152 |
|
| 153 |
+
eos_bias = float(eos_bias)
|
| 154 |
+
|
| 155 |
+
objs = moondream.detect(img, object, settings={"eos_bias": eos_bias})["objects"]
|
| 156 |
+
|
| 157 |
w, h = img.size
|
| 158 |
if w > 768 or h > 768:
|
| 159 |
img = Resize(768)(img)
|
| 160 |
w, h = img.size
|
| 161 |
|
|
|
|
| 162 |
draw_image = ImageDraw.Draw(img)
|
| 163 |
for o in objs:
|
| 164 |
draw_image.rectangle(
|
|
|
|
| 298 |
)
|
| 299 |
submit = gr.Button("Submit")
|
| 300 |
img = gr.Image(type="pil", label="Upload an Image")
|
| 301 |
+
eos_bias = gr.Textbox(label="EOS Bias", value="0")
|
| 302 |
+
submit.click(detect, [img, prompt, eos_bias], [thought, ann])
|
| 303 |
+
prompt.submit(detect, [img, prompt, eos_bias], [thought, ann])
|
| 304 |
+
img.change(detect, [img, prompt, eos_bias], [thought, ann])
|
| 305 |
elif mode == "Point":
|
| 306 |
with gr.Group():
|
| 307 |
with gr.Row():
|