fcn_resnet101

FP32 LiteRT/TFLite conversion of the pretrained TorchVision fcn_resnet101 model, using FCN_ResNet101_Weights.COCO_WITH_VOC_LABELS_V1.

Files and tensor interface

  • Model: fcn_resnet101.tflite
  • Input: RGB, float32, NCHW [1, 3, 520, 520].
  • Output: float32 logits [1, 21, 520, 520], corresponding to the source model's out tensor.
  • Classes: the 20 Pascal VOC categories plus background. Auxiliary outputs are omitted.

Use

Install ai-edge-litert, huggingface-hub, torch, torchvision, numpy, and pillow, then replace image.jpg below with your image. The example applies the checkpoint's resize and normalization, followed by bilinear resizing to the fixed export dimensions when needed. Apply the same preprocessing for any PyTorch comparison.

import numpy as np
import torch.nn.functional as F
from PIL import Image
from huggingface_hub import hf_hub_download
from ai_edge_litert.interpreter import Interpreter
from torchvision.models.segmentation import FCN_ResNet101_Weights

weights = FCN_ResNet101_Weights.COCO_WITH_VOC_LABELS_V1
image = Image.open("image.jpg").convert("RGB")
x = weights.transforms()(image).unsqueeze(0)
if tuple(x.shape[-2:]) != (520, 520):
    x = F.interpolate(x, size=(520, 520), mode="bilinear", align_corners=False)
x = np.ascontiguousarray(x.numpy(), dtype=np.float32)

path = hf_hub_download("litert-community/fcn_resnet101", "fcn_resnet101.tflite")
model = Interpreter(model_path=path, num_threads=4)
model.allocate_tensors()
model.set_tensor(model.get_input_details()[0]["index"], x)
model.invoke()
logits = model.get_tensor(model.get_output_details()[0]["index"])
mask = logits.argmax(axis=1)[0]  # [520, 520] class IDs
class_names = weights.meta["categories"]
print(mask.shape)

The resulting mask uses the model's 520 ร— 520 coordinate system; resize class IDs with nearest-neighbor interpolation when mapping it to the original image.

Validation

Validated against PyTorch on two seeded random inputs and one photograph on builtin LiteRT CPU and XNNPACK. All six comparisons passed allclose(atol=1e-4, rtol=1e-3); the largest absolute logit difference was 2.3841858e-05.

Validation used PyTorch 2.14.1+cu130, TorchVision 0.29.1+cu130, and ai-edge-litert 2.3.0. These are numerical parity checks, not dataset accuracy measurements. GPU and NPU execution have not been validated for this export.

Downloads last month
7
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support