Skip to content
Open

log #262

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions moondream/torch/moondream.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ def _generate_points(
next_token.item() != self.config.tokenizer.eos_id
and len(out) < max_points
):

x_logits = decode_coordinate(hidden, self.region)
x_center = torch.argmax(x_logits, dim=-1) / x_logits.size(-1)
next_emb = encode_coordinate(
Expand All @@ -390,9 +391,17 @@ def _generate_points(
mask[:, :, pos], pos_ids[0] = 1, pos
logits, hidden = self._decode_one_tok(next_emb, mask, pos_ids)
pos += 1

size_logits = decode_size(hidden, self.region)
w = torch.argmax(size_logits[0], dim=-1) / size_logits.size(-1)
h = torch.argmax(size_logits[1], dim=-1) / size_logits.size(-1)

w_bin = torch.argmax(size_logits[0], dim=-1).float()
w_log2 = w_bin / 1023.0 * 10.0 - 10.0
w = 2.0**w_log2

h_bin = torch.argmax(size_logits[1], dim=-1).float()
h_log2 = h_bin / 1023.0 * 10.0 - 10.0
h = 2.0**h_log2

next_emb = encode_size(
torch.tensor(
[w, h], device=self.device, dtype=size_logits.dtype
Expand Down