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
|
@@ -46,18 +46,6 @@ moondream = AutoModelForCausalLM.from_pretrained(
|
|
46 |
device_map={"": "cuda"},
|
47 |
revision=REVISION
|
48 |
)
|
49 |
-
|
50 |
-
# CKPT_DIRS = ["/tmp/md-ckpt/ckpt/ft/song-moon-4c-s15/s72001/"]
|
51 |
-
# def get_ckpt(filename):
|
52 |
-
# ckpts = [
|
53 |
-
# torch.load(os.path.join(dir, filename), map_location="cpu") for dir in CKPT_DIRS
|
54 |
-
# ]
|
55 |
-
# avg_ckpt = {
|
56 |
-
# key.replace("._orig_mod", ""): sum(ckpt[key] for ckpt in ckpts) / len(ckpts)
|
57 |
-
# for key in ckpts[0]
|
58 |
-
# }
|
59 |
-
# return avg_ckpt
|
60 |
-
# moondream.load_state_dict(get_ckpt("model.pt"))
|
61 |
moondream.eval()
|
62 |
|
63 |
|
@@ -278,7 +266,7 @@ with gr.Blocks(title="moondream vl (new)", css=css, js=js) as demo:
|
|
278 |
scale=4,
|
279 |
)
|
280 |
submit = gr.Button("Submit")
|
281 |
-
|
282 |
img = gr.Image(type="pil", label="Upload an Image")
|
283 |
submit.click(answer_question, [img, prompt, reasoning], [output, thought])
|
284 |
prompt.submit(answer_question, [img, prompt, reasoning], [output, thought])
|
@@ -362,16 +350,15 @@ with gr.Blocks(title="moondream vl (new)", css=css, js=js) as demo:
|
|
362 |
img = Resize(768)(img)
|
363 |
w, h = img.size
|
364 |
|
365 |
-
|
366 |
-
if len(coords) % 2 != 0:
|
367 |
-
raise ValueError("Only points supported right now.")
|
368 |
|
369 |
img_clone = img.copy()
|
370 |
draw = ImageDraw.Draw(img_clone)
|
371 |
|
372 |
for i in range(0, len(coords), 2): # Step by 2 to handle x,y pairs
|
373 |
-
|
374 |
-
|
|
|
375 |
draw.ellipse(
|
376 |
(x - 3, y - 3, x + 3, y + 3),
|
377 |
fill="red",
|
|
|
1 |
+
REVISION = "9fd441468eb4ca6091a6fbee26edc1090b55ded7"
|
2 |
|
3 |
try:
|
4 |
import spaces
|
|
|
46 |
device_map={"": "cuda"},
|
47 |
revision=REVISION
|
48 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
moondream.eval()
|
50 |
|
51 |
|
|
|
266 |
scale=4,
|
267 |
)
|
268 |
submit = gr.Button("Submit")
|
269 |
+
reasoning = gr.Checkbox(label="Enable reasoning")
|
270 |
img = gr.Image(type="pil", label="Upload an Image")
|
271 |
submit.click(answer_question, [img, prompt, reasoning], [output, thought])
|
272 |
prompt.submit(answer_question, [img, prompt, reasoning], [output, thought])
|
|
|
350 |
img = Resize(768)(img)
|
351 |
w, h = img.size
|
352 |
|
353 |
+
points = json.loads(evt.value[1])
|
|
|
|
|
354 |
|
355 |
img_clone = img.copy()
|
356 |
draw = ImageDraw.Draw(img_clone)
|
357 |
|
358 |
for i in range(0, len(coords), 2): # Step by 2 to handle x,y pairs
|
359 |
+
for point in points:
|
360 |
+
x = int(point[0] * w)
|
361 |
+
y = int(point[1] * h)
|
362 |
draw.ellipse(
|
363 |
(x - 3, y - 3, x + 3, y + 3),
|
364 |
fill="red",
|