mediapipe icon indicating copy to clipboard operation
mediapipe copied to clipboard

Output shape of the Hair segmentation model

Open charlottejuston opened this issue 3 years ago • 3 comments

Hello,

How many channels has the output of the Hair segmentation model ?

In the TfLiteTensorsToSegmentationCalculator from the graph, there is
tensor_channels: 2 does that mean the output have 2 channels ?

In the model paper (https://arxiv.org/pdf/1907.06740.pdf), the output of the model only has one channel.

I want to use this graph with my own segmentation model, but its output has 1 channel. Also, my model does not use the output of the previous frame, can I still use this graph for my own segmentation model ?

charlottejuston avatar Sep 13 '22 14:09 charlottejuston

Hi @charlottejuston, Could you please point out the output channel you are referring in the both of cases. Thank you!

kuaashish avatar Sep 14 '22 09:09 kuaashish

Hello, thank you for your reply!

From what I understood of the paper, the hair segmentation model takes as input a tensor of shape (4x512x512) and has as output a tensor of shape (1x512x512) so with only one channel.

Now, I wanted to know what does the tensor_channels: 2 refer to in this part of the graph ?

node {
  calculator: "TfLiteTensorsToSegmentationCalculator"
  input_stream: "TENSORS:segmentation_tensor"
  input_stream: "PREV_MASK:previous_hair_mask"
  output_stream: "MASK:hair_mask"
  node_options: {
    [type.googleapis.com/mediapipe.TfLiteTensorsToSegmentationCalculatorOptions] {
      tensor_width: 512
      tensor_height: 512
      tensor_channels: 2
      combine_with_previous_ratio: 0.9
      output_layer_index: 0
    }
  }
}

I want to use this graph for my own model, which takes as input a tensor of shape (3x512x512) and has as output a tensor of shape (1x512x512). Is it possible to use the graph of the Hair Segmentation with my own model ?

charlottejuston avatar Sep 14 '22 10:09 charlottejuston

TfLiteTensorsToSegmentationCalculator only processes output tensor of dim 1x512x512x2, so you may need to customize a new calculator for your model. moreover, the hair segmentation model actually takes input tensor of dim 512x512x4. https://github.com/google/mediapipe/blob/6cdc6443b6a7ed662744e2a2ce2d58d9c83e6d6f/mediapipe/calculators/tflite/tflite_tensors_to_segmentation_calculator.cc#L530

andrechen avatar Sep 15 '22 07:09 andrechen

Hello @charlottejuston Did the insights provided above helped you in resolving the issue? Are you still looking for a resolution?

ayushgdev avatar May 03 '23 08:05 ayushgdev

This issue has been marked stale because it has no recent activity since 7 days. It will be closed if no further activity occurs. Thank you.

github-actions[bot] avatar May 12 '23 01:05 github-actions[bot]

This issue was closed due to lack of activity after being marked stale for past 7 days.

github-actions[bot] avatar May 19 '23 01:05 github-actions[bot]

Are you satisfied with the resolution of your issue? Yes No

google-ml-butler[bot] avatar May 19 '23 01:05 google-ml-butler[bot]