CLIPSeg RD64 Refined MNN WQ8
WQ8 MNN conversion of CIDAS/clipseg-rd64-refined for text-guided image segmentation. An image and a short text prompt produce a mask for the described region.
Runtime: MNN (GitHub).
Models
| File | Purpose | Size |
|---|---|---|
model_fp32_wq8_block128.mnn |
Complete RD64 Refined model | 210.73 MiB |
split_wq8/clipseg_text_projection_fp32_wq8_block128.mnn |
Text encoder and projection | 135.97 MiB |
split_wq8/clipseg_vision_encoder_fp32_wq8_block128.mnn |
Vision encoder | 73.68 MiB |
split_wq8/clipseg_decoder_head_fp32_wq8_block128.mnn |
RD64 refined decoder and mask head | 1.44 MiB |
All models use decoder reduction dimension 64 with the refined convolutional mask head. Eligible weights use 8-bit quantization with block size 128. The complete model was converted from Xenova/clipseg-rd64-refined.
The split files were extracted directly from the existing quantized complete model; their weights were not requantized. They are RD64 Refined modules, distinct from the RD16 split modules in the separate RD16 repository.
Inputs and output
- Image: RGB, bilinear resize to 352 x 352, scale to [0, 1], then normalize with mean
[0.485, 0.456, 0.406]and standard deviation[0.229, 0.224, 0.225]. Feedpixel_valuesas float32 NCHW[1, 3, 352, 352]. - Text: tokenize with the included CLIP BPE files, pad / truncate to 77 tokens, and feed
input_idsandattention_maskas int32[1, 77]. - Output: float32
logits, normally[1, 352, 352]. Apply sigmoid for mask probabilities and resize to the image dimensions.
Use an MNN runtime with batch size 1 as the documented input convention. Image inputs and exported logits use float32; fp32 in the filename identifies the source conversion variant.
Tokenizer files, preprocessor_config.json, and the upstream architecture config.json are included. manifest.json records payload sizes and SHA-256 hashes; SHA256SUMS covers all other files in this repository.
Split pipeline and feature caching
Use the MNN Module/Express API with shape-mutable inputs. The graph contains control flow; the older Session API is not the interface validated here.
- Text inputs are
input_idsandattention_mask, int32[1, 77]. Cache the output/text_projection/MatMul_output_0, float32[1, 512], for repeated text. - The image input is
pixel_values, float32 NCHW[1, 3, 352, 352]. Cache these float32 outputs for the same preprocessed image:/vision_model/encoder/layers.3/Add_1_output_0/vision_model/encoder/layers.6/Add_1_output_0/vision_model/encoder/layers.9/Add_1_output_0Each has shape[1, 485, 768]at the documented image size.
- Feed the text and three image features to the decoder using those exact names. The result is
logitswith shape[1, 352, 352]; apply sigmoid for probabilities.
Scope feature caches to the model/configuration and exact preprocessed input. Text and image features from a different checkpoint must not be mixed.
Validation and reproduction
split_validation.json records source hashes and the numerical check. On CPU4 with MNN Python 3.6.0 Module/Express, six combinations (gradient, seeded random input, and an app test photo, each with table / cup) produced exactly equal logits between the complete and split pipelines: maximum absolute difference 0. The real-photo cup mask had 32,562 positive pixels in both pipelines.
The retained serialized operator payloads were also checked byte-for-byte against the source graph. This is a small desktop numerical-consistency test, not a segmentation-quality benchmark, Android performance result, or guarantee for other backends.
tools/split_quantized_mnn.cpp reproduces the dependency-graph extraction using MNN public generated schema headers. Compile with C++17 and the matching schema/current / FlatBuffers include paths, then run split_quantized_mnn model_fp32_wq8_block128.mnn output_directory.
Attribution and license
CLIPSeg was introduced by Timo Lueddecke and Alexander Ecker in Image Segmentation Using Text and Image Prompts. The upstream CIDAS checkpoint is listed under Apache-2.0. See LICENSE and NOTICE.