Spaces:
Running on Zero
Running on Zero
Upload folder using huggingface_hub
Browse filesFiles changed (11)
- .gitattributes+5
- README.md+44-6
- app.pyAdded+162
- examples/acoustic_guitar.jpgAdded
- examples/cat_tabby.jpgAdded
- examples/living_room_blue_couch.jpgAdded
- examples/motorcycle_street.jpgAdded
- examples/red_fox.jpgAdded
- examples/rubber_ducks.jpgAdded
- fast_read.pyAdded+170
- requirements.txtAdded+6
32 unmodified lines33343532 unmodified lines*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -text32 unmodified lines333435363738394032 unmodified lines*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -textexamples/acoustic_guitar.jpg filter=lfs diff=lfs merge=lfs -textexamples/cat_tabby.jpg filter=lfs diff=lfs merge=lfs -textexamples/living_room_blue_couch.jpg filter=lfs diff=lfs merge=lfs -textexamples/motorcycle_street.jpg filter=lfs diff=lfs merge=lfs -textexamples/red_fox.jpg filter=lfs diff=lfs merge=lfs -text
12345678910111213---title: Readpointemoji: 📉colorFrom: bluecolorTo: greensdk: gradiosdk_version: 6.33.0python_version: '3.12'app_file: app.pypinned: false---Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051---title: ReadPointemoji: 🎯colorFrom: graycolorTo: greensdk: gradiosdk_version: 6.33.0app_file: app.pyshort_description: Fast self-checking pointing decision VLMspython_version: "3.12"startup_duration_timeout: 30m---# ReadPoint — fast self-checking pointing decision modelsPoint a small vision-language model at a target — **one forward pass** reads the probability of *every*point (000–999 per axis), plus an optional bounding box and a self-check confidence. No token-by-tokenwriting, nothing sampled: the exact distributions come out of a single pass over a packed tree of allpossible digit prefixes.Adapters by NAVER Cloud AI, from [Small Vision-Language Models Are Fast Self-Checking PointingDecision Models](https://huggingface.co/papers/2611.38866) ([project page](https://naver-ai.github.io/ReadPoint/)):- [`naver-ai/ReadPoint-0.8B`](https://huggingface.co/naver-ai/ReadPoint-0.8B) — the fast variant- [`naver-ai/ReadPoint-2B`](https://huggingface.co/naver-ai/ReadPoint-2B) — the accurate variant## How it worksA pointing answer is three digits per coordinate, and every digit prefix the model could write isknown in advance. ReadPoint packs the image, the request "Point to \<target\>.", the tail of eachquestion (x, y — and in full mode also the box edges x1/y1/x2/y2 and the self-check) and 10+100digit-prefix nodes per axis into ONE sequence. Full-attention layers use a tree mask so each nodesees only its own path, and the Gated-DeltaNet layers continue every branch from its parent'srecurrent state inside the same layer. Reading the logits at the leaves yields the exactdistribution over 000–999 for each axis — the point is the argmax, the box the argmax of its fouredges, and the self-check is P("Yes") on the check question.The demo draws the point (and box) on the image, renders the joint probability mapP(x)·P(y) on the model's own 1000×1000 grid, and reports the self-check P(yes): the model's ownjudgement of whether it can point precisely at this image resolution.## Notes- Inference follows the authors' minimal reader (`fast_read.py`, shipped in the model repos) 1:1,with a ZeroGPU adaptation: the model loads and merges on CPU at startup, then is moved with`.to("cuda")` so the runtime streams it into VRAM on the first call.- The adapters and `fast_read.py` are released under **CC BY-NC 4.0** (research / non-commercialuse only) — see the [model card](https://huggingface.co/naver-ai/ReadPoint-0.8B).- Example images are from[`linoyts/repo-to-space-example-inputs`](https://huggingface.co/datasets/linoyts/repo-to-space-example-inputs)(CC0 1.0).
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162import spaces # ZeroGPU: must be imported before torchimport time
import numpy as npimport gradio as grfrom PIL import Image, ImageDraw, ImageFont
from fast_read import FastReader
MODEL_CHOICES = ["naver-ai/ReadPoint-0.8B", "naver-ai/ReadPoint-2B"]DEFAULT_MODE = "Point + box + self-check"
# ZeroGPU rule: load every variant eagerly at module scope. A lazily-filled dict would be lost on# every cold worker fork (workers inherit the main process's memory), forcing a full re-download# and re-merge inside the GPU call. Both adapters together are ~5.6 GB of bf16 — well inside a# 48 GB worker — and each is .to("cuda")-packed once so any call streams in quickly.READERS = {name: FastReader(name) for name in MODEL_CHOICES}
def _load_font(size: int): for name in ("DejaVuSans-Bold.ttf", "DejaVuSans.ttf"): try: return ImageFont.truetype(name, size) except OSError: continue return ImageFont.load_default()
def draw_overlay(image: Image.Image, point, box=None, p_yes=None): """Annotate the image with the point marker (and box + self-check if read in full mode).""" W, H = image.size x, y = point px, py = x * W / 1000, y * H / 1000 canvas = image.copy() d = ImageDraw.Draw(canvas, "RGBA") if box is not None: x1, y1, x2, y2 = box d.rectangle( [x1 * W / 1000, y1 * H / 1000, x2 * W / 1000, y2 * H / 1000], outline=(255, 106, 0, 255), width=max(3, W // 240), ) r = max(6, W // 90) d.ellipse([px - r, py - r, px + r, py + r], fill=(255, 106, 0, 110), outline=(255, 106, 0, 255), width=max(2, W // 320)) d.line([px - 2 * r, py, px + 2 * r, py], fill=(255, 106, 0, 255), width=2) d.line([px, py - 2 * r, px, py + 2 * r], fill=(255, 106, 0, 255), width=2) return canvas
def render_heatmap(dist_x: np.ndarray, dist_y: np.ndarray): """Render the joint probability map on the 1000x1000 grid the model reads over.""" grid = np.outer(dist_y, dist_x) # rows = y (000 top .. 999 bottom), cols = x grid = grid / grid.sum() # square-root scaling keeps small secondary modes visible; blur the peak slightly for a smooth map p = np.sqrt(grid) k = np.outer(np.hanning(61), np.hanning(61)); k /= k.sum() p = np.real(np.fft.ifft2(np.fft.fft2(p, s=(1061, 1061))) * np.fft.fft2(k, s=(1061, 1061)))[:1000, :1000] p = np.clip(p, 0, None) p = p / (p.max() + 1e-12) lo = np.array([24, 30, 66], dtype=np.float64) # dark navy hi = np.array([255, 138, 40], dtype=np.float64) # warm orange arr = np.zeros((1000, 1000, 3), dtype=np.uint8) for c in range(3): arr[..., c] = lo[c] + (hi[c] - lo[c]) * p argmy, argmx = np.unravel_index(grid.argmax(), grid.shape) d = ImageDraw.Draw(Image.fromarray(arr)) d.ellipse([argmx - 22, argmy - 22, argmx + 22, argmy + 22], outline=(255, 255, 255), width=4) d.ellipse([argmx - 34, argmy - 34, argmx + 34, argmy + 34], outline=(255, 255, 255, 90), width=2) f = _load_font(26) d.text((12, 8), "x: 000 to 999 (left to right)", fill=(200, 208, 226), font=f) d.text((12, 960), "y: 000 to 999 (top to bottom)", fill=(200, 208, 226), font=f) return Image.fromarray(arr)
@spaces.GPU(duration=120)def read_point(image, target: str = "", model_choice: str = MODEL_CHOICES[0], mode: str = DEFAULT_MODE): """Point at a target in an image and read the probability of every point in one forward pass.
Args: image: input image. target: what to point at, e.g. "the cat's left ear". model_choice: adapter to use, "naver-ai/ReadPoint-0.8B" or "naver-ai/ReadPoint-2B". mode: "Point only" or "Point + box + self-check". """ if image is None: raise gr.Error("Please provide an image.") if not target or not target.strip(): raise gr.Error("Please describe what to point at.") img = image if isinstance(image, Image.Image) else Image.open(image).convert("RGB") reader = READERS[model_choice if model_choice in READERS else MODEL_CHOICES[0]] full = mode == "Point + box + self-check" t0 = time.perf_counter() res = reader.read(img, target, full=full) elapsed = time.perf_counter() - t0 x, y = res["point"] overlay = draw_overlay(img, res["point"], res.get("box"), res.get("p_yes")) heat = render_heatmap(res["dist"]["x"], res["dist"]["y"]) lines = [f"**Point** — x `{x:03d}`, y `{y:03d}` · ({x * img.size[0] / 1000:.0f}, {y * img.size[1] / 1000:.0f}) px in a {img.size[0]}×{img.size[1]} image"] if "box" in res: x1, y1, x2, y2 = res["box"] lines.append(f"**Box** — ({x1:03d}, {y1:03d}) → ({x2:03d}, {y2:03d}) /1000") if "p_yes" in res: verdict = "yes — precise at this resolution" if res["p_yes"] >= 0.5 else "no — not precise at this resolution" lines.append(f"**Self-check P(yes)** — `{res['p_yes']:.2f}` · the model says {verdict}") lines.append(f"**Read time** — {elapsed:.2f} s (single forward pass; exact distributions over 000–999 per axis, nothing sampled)") return overlay, heat, "\n\n".join(lines)
CSS = """#col-container { max-width: 1200px; margin: 0 auto; }.dark .gradio-container { color: var(--body-text-color); }"""
with gr.Blocks(theme=gr.themes.Citrus(), css=CSS) as demo: with gr.Column(elem_id="col-container"): gr.Markdown( """ # ReadPoint — fast self-checking pointing decision models Point a small VLM at a target and **one forward pass** reads the probability of *every* point (000–999 per axis) — no token-by-token writing — plus an optional bounding box and a self-check confidence. Adapters by NAVER Cloud AI ([paper](https://huggingface.co/papers/2611.38866) · [project page](https://naver-ai.github.io/ReadPoint/) · [0.8B](https://huggingface.co/naver-ai/ReadPoint-0.8B) · [2B](https://huggingface.co/naver-ai/ReadPoint-2B)). """ ) with gr.Row(): with gr.Column(): image_in = gr.Image(type="pil", label="Image", height=340) target = gr.Textbox( label="Point to…", placeholder="e.g. the cat's left ear", lines=1, value="" ) with gr.Accordion("Options", open=False): model_choice = gr.Radio( MODEL_CHOICES, value=MODEL_CHOICES[0], label="Adapter", info="0.8B is the fast variant; 2B is the accurate one." ) mode = gr.Radio( ["Point only", "Point + box + self-check"], value="Point + box + self-check", label="What to read", info="Everything is read in the same single forward pass.", ) run = gr.Button("Point", variant="primary") with gr.Column(): overlay_out = gr.Image(type="pil", label="Point (and box) overlay", height=340, show_label=True) heat_out = gr.Image(type="pil", label="Probability of every point (1000 × 1000 grid)", height=340) report = gr.Markdown() gr.Examples( examples=[ ["examples/cat_tabby.jpg", "the cat's left eye"], ["examples/red_fox.jpg", "the fox's face"], ["examples/living_room_blue_couch.jpg", "the wall-mounted TV"], ["examples/motorcycle_street.jpg", "the round headlight"], ["examples/rubber_ducks.jpg", "the smallest rubber duck"], ["examples/acoustic_guitar.jpg", "the sound hole"], ], inputs=[image_in, target], outputs=[overlay_out, heat_out, report], fn=read_point, cache_examples=True, cache_mode="lazy", )
if __name__ == "__main__": demo.launch(mcp_server=True)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170# ReadPoint — vendored from the model repos (naver-ai/ReadPoint-0.8B, naver-ai/ReadPoint-2B)# Copyright (c) 2026-present NAVER Cloud Corp.# Released with the ReadPoint adapters under their license (CC BY-NC 4.0); the code release will carry its own license.# Adapted for ZeroGPU: model loads on CPU and is moved with .to("cuda") (the ZeroGPU# runtime streams it into VRAM on the first @spaces.GPU call); everything else is 1:1# the authors' minimal reader."""Minimal ReadPoint inference for Qwen3.5 adapters: ONE forward pass reads the point (and, optionally, the box and the self-check).
Each coordinate answer is three digits, and every digit prefix the model could write is known in advance: per axis thequestion, 10 one-digit prefixes and 100 two-digit prefixes. They are packed with the image and "Point to <target>." into onesequence and run through the model once. Full-attention layers use a tree mask (each token sees only its own path), and theGated-DeltaNet layers continue every branch from its parent's state inside the same layer. The outputs give the exactdistribution over 000..999 for each axis; nothing is sampled or written."""
import json, osimport numpy as npimport torchimport torch.nn.functional as Ffrom PIL import Image
def _gdn(model): return [m for m in model.modules() if type(m).__name__.endswith("GatedDeltaNet")]
def _run(mod, x, conv, rec, chunk): """Gated-DeltaNet layer on rows x (B, n, d) continuing from conv / recurrent states (the module's own weights and kernels).""" B, n, _ = x.shape mixed = mod.in_proj_qkv(x).transpose(1, 2) z = mod.in_proj_z(x).reshape(B, n, -1, mod.head_v_dim); b, a = mod.in_proj_b(x), mod.in_proj_a(x) K = mod.conv_kernel_size; xe = torch.cat([conv[..., 1:].to(mixed.dtype), mixed], -1); new_conv = xe[..., -K:].contiguous() mixed = F.silu(F.conv1d(xe, mod.conv1d.weight, mod.conv1d.bias, groups=xe.shape[1])).transpose(1, 2) q, k, v = torch.split(mixed, [mod.key_dim, mod.key_dim, mod.value_dim], dim=-1) q, k = q.reshape(B, n, -1, mod.head_k_dim), k.reshape(B, n, -1, mod.head_k_dim); v = v.reshape(B, n, -1, mod.head_v_dim) g = -mod.A_log.float().exp() * F.softplus(a.float() + mod.dt_bias) if mod.num_v_heads > mod.num_k_heads: r = mod.num_v_heads // mod.num_k_heads; q, k = q.repeat_interleave(r, 2), k.repeat_interleave(r, 2) rule = mod.chunk_gated_delta_rule if chunk else mod.recurrent_gated_delta_rule o, last = rule(q, k, v, g=g, beta=b.sigmoid(), initial_state=rec, output_final_state=True, use_qk_l2norm_in_kernel=True) o = mod.norm(o.reshape(-1, mod.head_v_dim), z.reshape(-1, mod.head_v_dim)).reshape(B, n, -1) return mod.out_proj(o), new_conv, last
def _patch(model, plan): """Gated-DeltaNet layers run the packed sequence as a tree: prefix, then each question tail, then the digit nodes.""" for mod in _gdn(model): def fwd(hidden_states, cache_params=None, attention_mask=None, _m=mod, **kw): p = plan; h = hidden_states[0]; out = torch.empty_like(h) conv0 = h.new_zeros(1, _m.conv1d.weight.shape[0], _m.conv_kernel_size) rec0 = h.new_zeros(1, _m.num_v_heads, _m.head_k_dim, _m.head_v_dim, dtype=torch.float32) o, cP, sP = _run(_m, h[None, :p["Lp"]], conv0, rec0, True); out[:p["Lp"]] = o[0] ends_c, ends_s = [None] * len(p["tails"]), [None] * len(p["tails"]) for idx in p["groups"]: # tails of equal length run as one batch s, n = p["tails"][idx[0]]; x = torch.stack([h[p["tails"][i][0]: p["tails"][i][0] + n] for i in idx]) o, c, st = _run(_m, x, cP.expand(len(idx), -1, -1), sP.expand(len(idx), -1, -1, -1), True) for j, i in enumerate(idx): out[p["tails"][i][0]: p["tails"][i][0] + n] = o[j]; ends_c[i], ends_s[i] = c[j], st[j] pc, ps = torch.stack(ends_c), torch.stack(ends_s) for (s, cnt, par) in p["levels"]: # one-token digit nodes, each from its parent's end state o, pc, ps = _run(_m, h[s: s + cnt, None], pc.index_select(0, par), ps.index_select(0, par), False) out[s: s + cnt] = o[:, 0] return out[None] mod.forward = fwd
class FastReader: def __init__(self, adapter="naver-ai/ReadPoint-0.8B", max_pixels=147456, device="cuda", dtype=torch.bfloat16): from transformers import AutoProcessor, AutoModelForImageTextToText from peft import PeftConfig, PeftModel from huggingface_hub import snapshot_download path = adapter if os.path.isdir(adapter) else snapshot_download(adapter) base = PeftConfig.from_pretrained(path).base_model_name_or_path self.dev = device self.proc = AutoProcessor.from_pretrained(base, max_pixels=max_pixels); self.tok = self.proc.tokenizer # ZeroGPU: load + merge on CPU (no accelerator is visible at import time), then .to(device): # the hijack turns this into a registered fake-CUDA tensor whose CPU original the runtime # packs to disk and streams into VRAM on the first @spaces.GPU call. m = AutoModelForImageTextToText.from_pretrained(base, dtype=dtype, attn_implementation="sdpa") m = PeftModel.from_pretrained(m, path).merge_and_unload().eval() self.model = m.to(device) self.plan = {}; _patch(self.model, self.plan) self._moved = False self.lm = self.model.model.language_model; self.lm._update_linear_attn_mask = lambda *a, **k: None # avoids a host sync self.graphs = {} if device == "cuda" else None # one CUDA graph per sequence layout: no per-kernel launch cost cfg = json.load(open(os.path.join(path, "read_config.json"))) self.qtext = {n: cfg[n] for n in ("x", "y", "x1", "y1", "x2", "y2", "check")} self.q = {n: self._ids(t) for n, t in self.qtext.items()} self.yes, self.no = self._ids("Yes")[0], self._ids("No")[0] self.D = [self._ids(str(d))[0] for d in range(10)] vocab = self.tok.get_vocab() # an answer may also end after 1 or 2 digits: count those terminators as the reference reader does ends = {i for s, i in vocab.items() if s[:1] in (",", "}")} NL = chr(10) # newline (kept out of this literal so the line stays a single line) ends |= {self._ids(s)[0] for s in ("<|im_end|>", NL, NL + NL, ".", " .") if len(self._ids(s)) == 1} # kept on CPU here: a bare factory call with device="cuda" is not the .to("cuda") the # ZeroGPU hijack intercepts at import time; read() moves them onto the (real) device. self.dig = torch.tensor(self.D); self.term = torch.tensor(sorted(ends))
def _ids(self, s): return self.tok(s, add_special_tokens=False)["input_ids"]
def prompt(self, target): t = target.strip().rstrip("."); t = t[len("point to "):] if t.lower().startswith("point to ") else t msgs = [{"role": "user", "content": [{"type": "image"}, {"type": "text", "text": f"Point to {t}."}]}] text = self.proc.apply_chat_template(msgs, add_generation_prompt=True, tokenize=False, enable_thinking=False) return text[:text.rfind("<|im_end|>")] # the shared prefix: the questions start where the user turn ends
def _lm(self, emb, pos, mask, key): """The language model on the packed sequence; on CUDA, captured once per layout and replayed (same kernels, same output).""" run = lambda e, p, m: self.lm(inputs_embeds=e, position_ids=p, attention_mask=m, use_cache=False).last_hidden_state if self.graphs is None: return run(emb, pos, mask) if key not in self.graphs: st = [emb.clone(), pos.clone(), mask.clone()]; s = torch.cuda.Stream(); s.wait_stream(torch.cuda.current_stream()) with torch.cuda.stream(s): for _ in range(2): run(*st) torch.cuda.current_stream().wait_stream(s); g = torch.cuda.CUDAGraph() with torch.cuda.graph(g): out = run(*st) self.graphs[key] = (g, st, out, dict(self.plan)) # keeps the captured plan tensors alive g, st, out, _ = self.graphs[key] for a, b in zip(st, (emb, pos, mask)): a.copy_(b) g.replay(); return out
@torch.no_grad() def read(self, image, target, full=False): """One forward (full=True also reads the box edges and the self-check, still in the same forward). Sequence = [prefix | tail of each question | 10 one-digit nodes per axis | 100 two-digit nodes per axis].""" names, check = (("x", "y", "x1", "y1", "x2", "y2"), True) if full else (("x", "y"), False) if not self._moved: # first call runs inside the GPU worker: move the small constants onto the real device self.dig, self.term = self.dig.to(self.dev), self.term.to(self.dev); self._moved = True inp = self.proc(text=[self.prompt(target)], images=[image], return_tensors="pt").to(self.dev) P = inp["input_ids"][0]; Lp = len(P); qs = list(names) + (["check"] if check else []) ids, tails, par = [P], [], [] o = Lp for n in qs: tails.append((o, len(self.q[n]))); ids.append(torch.tensor(self.q[n], device=self.dev)); o += len(self.q[n]) s1 = o; n1 = 10 * len(names); ids.append(self.dig.repeat(len(names))); o += n1 s2 = o; n2 = 100 * len(names); ids.append(self.dig.repeat(10 * len(names))); o += n2 ids = torch.cat(ids)[None]; N = ids.shape[1] # tree mask (True = may attend) and positions M = torch.zeros(N, N, dtype=torch.bool, device=self.dev); M[:Lp, :Lp] = torch.ones(Lp, Lp, device=self.dev).tril().bool() pos3, _ = self.model.model.get_rope_index(inp["input_ids"], inp["mm_token_type_ids"], image_grid_thw=inp["image_grid_thw"]) base = int(pos3.max()) + 1; tp = torch.zeros(N, dtype=torch.long, device=self.dev) for (s, n) in tails: M[s:s + n, :Lp] = True; M[s:s + n, s:s + n] = torch.ones(n, n, device=self.dev).tril().bool(); tp[s:s + n] = base + torch.arange(n, device=self.dev) par1 = torch.arange(len(names), device=self.dev).repeat_interleave(10) # node1 -> its tail last = torch.tensor([s + n - 1 for s, n in tails[:len(names)]], device=self.dev) r1 = s1 + torch.arange(n1, device=self.dev); M[r1] = M[last[par1]]; M[r1, r1] = True; tp[r1] = tp[last[par1]] + 1 par2 = torch.arange(n1, device=self.dev).repeat_interleave(10) # node2 -> its node1 r2 = s2 + torch.arange(n2, device=self.dev); M[r2] = M[r1[par2]]; M[r2, r2] = True; tp[r2] = tp[r1[par2]] + 1 pos = tp[None, None].repeat(3, 1, 1); pos[:, :, :Lp] = pos3 mm = torch.zeros_like(ids); mm[:, :Lp] = inp["mm_token_type_ids"] lens = sorted({n for _, n in tails}); groups = [[i for i, (_, n) in enumerate(tails) if n == L] for L in lens] self.plan.clear(); self.plan.update(Lp=Lp, tails=tails, groups=groups, levels=[(s1, n1, par1), (s2, n2, par2)]) emb = self.model.model.get_input_embeddings()(ids) img = self.model.model.get_image_features(inp["pixel_values"], inp["image_grid_thw"]).pooler_output emb = emb.masked_scatter((ids == self.model.config.image_token_id)[..., None], torch.cat(img).to(emb.dtype)) h = self._lm(emb, pos, M[None, None], (Lp, tuple(tails)))[0] out = {} for i, name in enumerate(names): rows = torch.cat([last[i:i + 1], r1[10 * i: 10 * i + 10], r2[100 * i: 100 * i + 100]]) Pr = torch.softmax(self.model.lm_head(h[rows]).float(), -1) root, Q1, Q2 = Pr[0], Pr[1:11], Pr[11:] # after the question / after the 1st digit / after 2 digits r = root[self.dig] / root[self.dig].sum() def split(p): d, e = p[:, self.dig], p[:, self.term].sum(-1); z = d.sum(-1) + e; return d / z[:, None], e / z g1, t1 = split(Q1); g2, t2 = split(Q2) m = torch.zeros(1000, device=self.dev, dtype=torch.float64); two = (r[:, None] * g1).reshape(-1) m[:10] += (r * t1).double(); m[:100] += (two * t2).double(); m += (two[:, None] * g2).reshape(-1).double() out[name] = (m / m.sum()).cpu().numpy() res = {"dist": out, "point": (int(out["x"].argmax()), int(out["y"].argmax())), "passes": 1} if "x1" in out: res["box"] = tuple(int(out[e].argmax()) for e in ("x1", "y1", "x2", "y2")) if check: pc = torch.softmax(self.model.lm_head(h[tails[-1][0] + tails[-1][1] - 1]).float(), -1) res["p_yes"] = float(pc[self.yes] / (pc[self.yes] + pc[self.no])) return res123456transformers==5.14.1peftflash-linear-attentionacceleratepillownumpy.gitattributes+5
README.md+44-6
app.pyAdded+162
examples/acoustic_guitar.jpgAdded

Large File Pointer Details
- SHA256: c938cf403fd5d512e50e3ab13cd3a63a22f024477342de96411e180cc7de2b2a
- Pointer size: 131 Bytes
- Size of remote file: 150 kB
examples/cat_tabby.jpgAdded

Large File Pointer Details
- SHA256: 7d17010bdc32ffc33df0e3fae71660db6e896ae759edb0202857120afda9f296
- Pointer size: 131 Bytes
- Size of remote file: 232 kB
examples/living_room_blue_couch.jpgAdded

Large File Pointer Details
- SHA256: 31509acfb170d47fc181d7a1ead26c35081b53a7dc7ed14b4aedf02dea866dea
- Pointer size: 131 Bytes
- Size of remote file: 112 kB
examples/motorcycle_street.jpgAdded

Large File Pointer Details
- SHA256: 03233a365e2b92d1c557bfdd5c3e3bb0b578875ba699394895899f291a6a4b13
- Pointer size: 131 Bytes
- Size of remote file: 182 kB
examples/red_fox.jpgAdded

Large File Pointer Details
- SHA256: 286130138fec79ac754b641c2b8b51cc8709c1ce1202dcc33ef0becdc418064d
- Pointer size: 131 Bytes
- Size of remote file: 167 kB
examples/rubber_ducks.jpgAdded

fast_read.pyAdded+170
requirements.txtAdded+6