CoolFace
Apppublic

karolmajek/maxdeeplab

sourceHugging Faceupdated 5y agoView on Hugging Face
0likes
merge_semantic_and_instance_maps_op_kernel.h54 linesDownload Raw Back to kernels
1// Copyright 2021 The Deeplab2 Authors.2//3// Licensed under the Apache License, Version 2.0 (the "License");4// you may not use this file except in compliance with the License.5// You may obtain a copy of the License at6//7//     http://www.apache.org/licenses/LICENSE-2.08//9// Unless required by applicable law or agreed to in writing, software10// distributed under the License is distributed on an "AS IS" BASIS,11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12// See the License for the specific language governing permissions and13// limitations under the License.14 15#ifndef DEEPLAB2_MERGE_SEMANTIC_AND_INSTANCE_MAPS_OP_KERNEL_H_16#define DEEPLAB2_MERGE_SEMANTIC_AND_INSTANCE_MAPS_OP_KERNEL_H_17#include <stdint.h>18 19#include <unordered_set>20 21#include /*third_party*/"tensorflow/core/framework/numeric_types.h"22#include /*third_party*/"tensorflow/core/framework/op_kernel.h"23#include /*third_party*/"tensorflow/core/framework/tensor.h"24#include /*third_party*/"tensorflow/core/framework/tensor_types.h"25 26namespace tensorflow_models {27namespace deeplab {28namespace deeplab2 {29namespace functor {30 31template <typename Device>32struct MergeSemanticAndInstanceMaps {33  // Functor that merges semantic and instance maps.34  void operator()(35      const Device& d,36      typename tensorflow::TTypes<int32_t, 3>::ConstTensor semantic_maps,37      typename tensorflow::TTypes<int32_t, 3>::ConstTensor instance_maps,38      const std::unordered_set<int32_t>& thing_ids_set, int label_divisor,39      int stuff_area_limit, int void_label,40      typename tensorflow::TTypes<int32_t, 3>::Tensor parsing_maps);41};42 43// Helper method to convert a list of thing IDs into hashset.44template <typename Device>45std::unordered_set<int32_t> Convert1DInt32TensorToSet(46    const Device& d, const tensorflow::Tensor& tensor);47 48}  // namespace functor49}  // namespace deeplab250}  // namespace deeplab51}  // namespace tensorflow_models52 53#endif  // DEEPLAB2_MERGE_SEMANTIC_AND_INSTANCE_MAPS_OP_KERNEL_H_54