CoolFace
Apppublic

karolmajek/Axial-DeepLab-SWideRNet

sourceHugging Faceupdated 5y agoView on Hugging Face
0likes
common.py153 linesDownload Raw Back to root
1# coding=utf-82# Copyright 2021 The Deeplab2 Authors.3#4# Licensed under the Apache License, Version 2.0 (the "License");5# you may not use this file except in compliance with the License.6# You may obtain a copy of the License at7#8#     http://www.apache.org/licenses/LICENSE-2.09#10# Unless required by applicable law or agreed to in writing, software11# distributed under the License is distributed on an "AS IS" BASIS,12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13# See the License for the specific language governing permissions and14# limitations under the License.15 16"""This file contains common methods and constants used across this framework."""17 18# Prediction keys used by the model output dictionary.19PRED_PANOPTIC_KEY = 'panoptic_pred'20PRED_SEMANTIC_KEY = 'semantic_pred'21PRED_INSTANCE_KEY = 'instance_pred'22PRED_INSTANCE_CENTER_KEY = 'instance_center_pred'23 24 25PRED_SEMANTIC_LOGITS_KEY = 'semantic_logits'26PRED_SEMANTIC_PROBS_KEY = 'semantic_probs'27PRED_INSTANCE_SCORES_KEY = 'instance_scores'28PRED_CENTER_HEATMAP_KEY = 'center_heatmap'29PRED_OFFSET_MAP_KEY = 'offset_map'30PRED_FRAME_OFFSET_MAP_KEY = 'frame_offset_map'31PRED_NEXT_OFFSET_MAP_KEY = 'next_offset_map'32PRED_NEXT_PANOPTIC_KEY = 'next_panoptic_pred'33PRED_CONCAT_NEXT_PANOPTIC_KEY = 'concat_next_panoptic_pred'34 35PRED_PIXEL_SPACE_NORMALIZED_FEATURE_KEY = 'pixel_space_normalized_feature'36PRED_PIXEL_SPACE_MASK_LOGITS_KEY = 'pixel_space_mask_logits'37PRED_TRANSFORMER_CLASS_LOGITS_KEY = 'transformer_class_logits'38 39# Ground-truth keys used by the model.40GT_PANOPTIC_KEY = 'panoptic_gt'41GT_SEMANTIC_KEY = 'semantic_gt'42GT_INSTANCE_CENTER_KEY = 'instance_center_gt'43GT_INSTANCE_REGRESSION_KEY = 'instance_regression_gt'44GT_FRAME_OFFSET_KEY = 'frame_offset_gt'45GT_IS_CROWD = 'is_crowd_gt'46GT_THING_ID_MASK_KEY = 'thing_id_mask_gt'47GT_THING_ID_CLASS_KEY = 'thing_id_class_gt'48GT_NEXT_INSTANCE_REGRESSION_KEY = 'next_instance_regression_gt'49 50# Raw labels.51GT_PANOPTIC_RAW = 'panoptic_raw'52GT_SEMANTIC_RAW = 'semantic_raw'53GT_IS_CROWD_RAW = 'is_crowd_raw'54GT_SIZE_RAW = 'size_raw'55GT_NEXT_PANOPTIC_RAW = 'next_panoptic_raw'56 57# Loss keys.58SEMANTIC_LOSS = 'semantic_loss'59CENTER_LOSS = 'center_loss'60REGRESSION_LOSS = 'regression_loss'61MOTION_LOSS = 'motion_loss'62NEXT_REGRESSION_LOSS = 'next_regression_loss'63PQ_STYLE_LOSS = 'pq_style_loss'64# The PQ-style loss consists of a class term and a mask dice term.65PQ_STYLE_LOSS_CLASS_TERM = 'pq_style_loss_class_term'66PQ_STYLE_LOSS_MASK_DICE_TERM = 'pq_style_loss_mask_dice_term'67MASK_ID_CROSS_ENTROPY_LOSS = 'mask_id_cross_entropy_loss'68INSTANCE_DISCRIMINATION_LOSS = 'instance_discrimination_loss'69TOTAL_LOSS = 'total_loss'70 71# Weight keys used by the model.72SEMANTIC_LOSS_WEIGHT_KEY = 'semantic_loss_weight'73CENTER_LOSS_WEIGHT_KEY = 'center_loss_weight'74REGRESSION_LOSS_WEIGHT_KEY = 'regression_loss_weight'75FRAME_REGRESSION_LOSS_WEIGHT_KEY = 'frame_regression_loss_weight'76NEXT_REGRESSION_LOSS_WEIGHT_KEY = 'next_regression_loss_weight'77 78# Misc.79RESIZED_IMAGE = 'resized_image'80IMAGE = 'image'81IMAGE_NAME = 'image_name'82SEQUENCE_ID = 'sequence_id'83NEXT_IMAGE = 'next_image'84 85# TfExample keys.86KEY_ENCODED_IMAGE = 'image/encoded'87KEY_ENCODED_PREV_IMAGE = 'prev_image/encoded'88KEY_ENCODED_NEXT_IMAGE = 'next_image/encoded'89KEY_IMAGE_FILENAME = 'image/filename'90KEY_IMAGE_FORMAT = 'image/format'91KEY_IMAGE_HEIGHT = 'image/height'92KEY_IMAGE_WIDTH = 'image/width'93KEY_IMAGE_CHANNELS = 'image/channels'94KEY_ENCODED_LABEL = 'image/segmentation/class/encoded'95KEY_ENCODED_PREV_LABEL = 'prev_image/segmentation/class/encoded'96KEY_ENCODED_NEXT_LABEL = 'next_image/segmentation/class/encoded'97KEY_LABEL_FORMAT = 'image/segmentation/class/format'98KEY_SEQUENCE_ID = 'video/sequence_id'99KEY_FRAME_ID = 'video/frame_id'100KEY_ENCODED_DEPTH = 'image/depth/encoded'101KEY_DEPTH_FORMAT = 'image/depth/format'102 103# Checkpoint Items104# All models105CKPT_SEMANTIC_LAST_LAYER = 'semantic_last_layer'106 107# DeepLabV3108CKPT_DEEPLABV3_ASPP = 'deeplab_v3_aspp'109CKPT_DEEPLABV3_CLASSIFIER_CONV_BN_ACT = 'classifier_conv_bn_act'110 111# DeepLabV3+112CKPT_DEEPLABV3PLUS_ASPP = 'deeplab_v3plus_aspp'113CKPT_DEEPLABV3PLUS_PROJECT_CONV_BN_ACT = 'deeplab_v3plus_project_conv_bn_act'114CKPT_DEEPLABV3PLUS_FUSE = 'deeplab_v3plus_fuse'115 116# Panoptic-DeepLab117CKPT_SEMANTIC_DECODER = 'semantic_decoder'118CKPT_SEMANTIC_HEAD_WITHOUT_LAST_LAYER = 'semantic_head_without_last_layer'119 120CKPT_INSTANCE_DECODER = 'instance_decoder'121CKPT_INSTANCE_CENTER_HEAD_WITHOUT_LAST_LAYER = ('instance_center_head'122                                                '_without_last_layer')123CKPT_INSTANCE_CENTER_HEAD_LAST_LAYER = 'instance_center_head_last_layer'124CKPT_INSTANCE_REGRESSION_HEAD_WITHOUT_LAST_LAYER = ('instance_regression_head'125                                                    '_without_last_layer')126CKPT_INSTANCE_REGRESSION_HEAD_LAST_LAYER = 'instance_regression_head_last_layer'127 128# Motion-DeepLab129CKPT_MOTION_REGRESSION_HEAD_WITHOUT_LAST_LAYER = ('motion_regression_head'130                                                  '_without_last_layer')131CKPT_MOTION_REGRESSION_HEAD_LAST_LAYER = 'motion_regression_head_last_layer'132 133# ViP-DeepLab134CKPT_NEXT_INSTANCE_DECODER = 'next_instance_decoder'135CKPT_NEXT_INSTANCE_REGRESSION_HEAD_WITHOUT_LAST_LAYER = (136    'next_instance_regression_head_without_last_layer')137CKPT_NEXT_INSTANCE_REGRESSION_HEAD_LAST_LAYER = (138    'next_instance_regression_head_last_layer')139 140# MaX-DeepLab141CKPT_PIXEL_SPACE_HEAD = 'pixel_space_head'142CKPT_TRANSFORMER_MASK_HEAD = 'transformer_mask_head'143CKPT_TRANSFORMER_CLASS_HEAD = 'transformer_class_head'144CKPT_PIXEL_SPACE_FEATURE_BATCH_NORM = 'pixel_space_feature_batch_norm'145CKPT_PIXEL_SPACE_MASK_BATCH_NORM = 'pixel_space_mask_batch_norm'146 147# Supported Tasks148TASK_PANOPTIC_SEGMENTATION = 'panoptic_segmentation'149TASK_INSTANCE_SEGMENTATION = 'instance_segmentation'150TASK_VIDEO_PANOPTIC_SEGMENTATION = 'video_panoptic_segmentation'151TASK_DEPTH_AWARE_VIDEO_PANOPTIC_SEGMENTATION = (152    'depth_aware_video_panoptic_segmentation')153