Florence-2 grounding base

Click a block to read its description, or select it with Tab and Enter.

Florence-2 grounding baseImage inference at 768 × 768. DaViT vision encoder, BART encoder-decoder and LibreYOLO output adapter.LibreYOLOFlorence-2 grounding baseImage inference at 768 × 768. DaViT vision encoder, BART encoder-decoder and LibreYOLO output adapter.DaViT stage sequenceProcessor image tensor1 × 3 × 768 × 768Conv2d then LayerNorm3 to 128; k=7, s=4, p=3Spatial block then channel blockn=1; 128 × 192 × 192LayerNorm then Conv2d128 to 256; k=3, s=2, p=1Spatial block then channel blockn=1; 256 × 96 × 96LayerNorm then Conv2d256 to 512; k=3, s=2, p=1Spatial block then channel blockn=9; 512 × 48 × 48LayerNorm then Conv2d512 to 1024; k=3, s=2, p=1Spatial block then channel blockn=1; 1024 × 24 × 24Stage heads / channel groups: 4, 8, 16, 32Both blocks are expanded below; channel width C follows the stage.Vision projector and source sequenceFinal feature map1 × 1024 × 24 × 24Add learned 2D positionsRow and column embedding concatenationFlatten spatial dimensions1 × 576 × 1024Add cosine/sine temporal positionsOne image frame; temporal index 0Mean over 576 positions1 × 1 × 1024Mean over one frame1 × 576 × 1024Concat token axis577 × 1024Linear, no bias1024 to 768LayerNorm577 × 768Replace image placeholdersPrompt tokens use vocabulary embeddingsAdd learned source positionsLayerNorm; sequence length L, width 768BART encoder and decoderImage and prompt sequenceL × 768; vocabulary51328Encoder layersn=6; 12 heads; FFN=3072Encoder memoryL × 768; supplies cross-attention K/VGenerated prefix embeddingVocabulary51328; width 768Add learned target positionsLayerNorm before decoder stackDecoder layersn=6; 12 heads; FFN=3072Vocabulary Linear768 to 51328; shared embedding weightsBeam search3 beams; autoregressive token selectionGenerated token IDsDecode with processorDropout is disabled in inference. Cached decoding reuses K/V.LibreYOLO adapterTask token and queryPhrase groundingProcessor post-processDecode tags and pixel-coordinate boxesExtract bboxes and labelsOriginal image size supplies geometryRemove whole-image boxesMatch normalized query textChoose tightest matching boxFallback to tightest remaining candidateBox center pointx=(x1+x2)/2; y=(y1+y2)/2Results.pointsOne pixel point; synthetic score1Task: <CAPTION_TO_PHRASE_GROUNDING>No pretrained inference was run for this diagram.DaViT spatial / channel blockUse spatial attention first, then channel attention; same skeleton.InputDepthwise Conv2dC channels; kernel3, stride1, padding1+InputLayerNorm + selected attentionSee separate spatial and channel insets+InputDepthwise Conv2dC channels; kernel3, stride1, padding1+InputLayerNorm + MLPLinear C to 4C; GELU; Linear 4C to C+LayerNorm acts on channels; reshape between grids and tokens.C by stage: 128, 256, 512, 1024. FFN widths: 512, 1024, 2048, 4096.Spatial attention primitivesLayerNormC channelsPad and partition windows12 × 12 positions per windowQ/K/V LinearC to 3C; split 3, heads, 32Q × transpose(K)144 × 144 per head; scale1/sqrt(32)Softmax over keys144 spatial positionsAttention weights × V144 × 32 per headConcat headsWidth COutput LinearC to CMerge windows and crop paddingRestore original H × W × CChannel attention primitivesLayerNormC channelsQ/K/V LinearC to 3C; split into G groupsTranspose each grouped tensor32 channels × S spatial positionsQ × transpose(K)32 × 32 per group; scale1/sqrt(S)Softmax over channel keys32 channels per groupAttention weights × V32 channels × S positionsRestore token and channel orderS × C; S = H × WOutput LinearC to CBART decoder layerInputCausal self-attentionQ/K/V from target prefix; 12 heads+LayerNorm768 channelsInputCross-attentionQ from target; K/V from encoder memory+LayerNorm768 channelsInputMLPLinear 768 to 3072; GELU; Linear 3072 to 768+LayerNorm768 channelsEach sublayer uses residual addition followed by LayerNorm.BART encoder layerInputBidirectional self-attentionQ/K/V from source; 12 heads+LayerNorm768 channelsInputMLPLinear 768 to 3072; GELU; Linear 3072 to 768+LayerNorm768 channelsBART attention primitivesQ from sublayer inputLinear 768 to 768; reshape 12 headsK from input or memoryLinear 768 to 768; reshape 12 headsV from input or memoryLinear 768 to 768; reshape 12 headsQ × transpose(K)Head width 64; inverse sqrt scalingAdd mask; softmax over keysCausal for decoder self-attention onlyAttention weights × VEncoder memory used only in cross-attentionConcat heads; output Linear768 to 768No rotary positions. Learned positions enter embeddings before the encoder and decoder.MLP primitivesLayerNorm (DaViT only)BART normalizes after the residual sumLinearDaViT C to 4C; BART 768 to 3072GELUElementwise activationLinearDaViT 4C to C; BART 3072 to 768Checked: pinned config and native meta module geometry. Runtime token counts depend on the processor; no weight-based execution.Source: libreyolo/models/ground/florence.py; Transformers 5.16.1. Revision a4d0ecc9e17f.libreyolo.com