Closed namas191297 closed 1 month ago
[!WARNING] The feature of split inference by multiple frames is still an experimental implementation.
[!WARNING] Segmentation has a known issue with misaligned results. This is still an open issue yet.
A simple example is here. Please specify how many layers to process per frame using model.SetLayersPerFrame()
.
private void Start()
{
// Create Segmentation Model
model = new HoloLab.DNN.Segmentation.SegmentationModel(weights);
model.SetInputMean(mean);
model.SetInputStd(std);
model.SetLayersPerFrame(layers_per_frame); // specify process number of layers to process per frame (e.g. 50)
/* Other Initializations */
}
private void Update()
{
/* Get Texture2D from WebCamera */
// Segment Area and Draw
StartCoroutine(Segment(input_texture));
}
private IEnumerator Segment(Texture2D input_texture)
{
// Segment Area
Texture2D indices_texture = null;
yield return StartCoroutine(model.Segment(input_texture, (output) => indices_texture = output));
//var indices_texture = model.Segment(input_texture);
// Draw Area on Unity UI
var colorized_texture = HoloLab.DNN.Segmentation.Visualizer.ColorizeArea(indices_texture, colors);
if (output_image.texture == null)
{
output_image.color = Color.white;
output_image.texture = new Texture2D(indices_texture.width, indices_texture.height, TextureFormat.RGBA32, false);
}
Graphics.CopyTexture(colorized_texture, output_image.texture);
// Destroy Texture
Destroy(colorized_texture);
Destroy(indices_texture);
}
Hi there,
Thank you for the amazing repository, you're really doing some great work here.
I was going through the repository and have been playing around with the Segmentation task. I am particularly curious about the Segment method in SegmentationModel.cs file:
Would it possible for you to provide an example of how to call this function during Update() when running an application that uses Webcam frames for Inference?
Cheers, Namas