Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. The 2022.2 beta is now available for testing. To find out what's new, have a look at our 2022.2 feature highlights.
    Dismiss Notice
  3. We are updating our Terms of Service for all Unity subscription plans, effective October 13, 2022, to create a more streamlined, user-friendly set of terms. Please review them here:
    Dismiss Notice
  4. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice
  5. Join us on Thursday, September 29, for a day with Unity's SRP teams here on the forum or on Reddit, and discuss topics around URP, HDRP, and the Scriptable Render Pipeline in general.
    Dismiss Notice
Dismiss Notice
Submit bug reports tagged with #Beta2022Win_Unity when you encounter unknown issues while testing the 2022.2 betas for a chance to win a year of Unity Pro. For more information, have a look at our Beta Sweepstakes Announcement.

Errors with Tensorflowsharp output = runner.Run() on Android

Discussion in 'AI & Navigation Previews' started by lindyrock, Apr 16, 2019.

  1. lindyrock


    Apr 12, 2019
    I've written a YOLO object detection model that tests out properly when inferenced in Python or with TFSharp in Visual Studio only. It's a Yolo v3, so i've added nodes to the graph to convert the anchor box output into boxes, scores, and classes, and these use some of the less basic operations like TFGraph.Tile, TFGraph.NonMaxSuppressionV2, TFGraph.Squeeze. All of these seem to be supported by libtensorflow and the TensorFlowSharp.dll.

    But when I run via an Android full build or in ARCore Instant Preview, I'm not getting usable results at all. I have errors and I have unexpected behavior.

    The errors are:

    and the unexpected behavior is that, in Debug mode if I set a breakpoint after the runner.Run() command below, I cannot even access the GetValue() method. I receive "Cannot find a match for GetValue" in the interactive console.

    Code (CSharp):
    1. public TFTensor[] Detect(TFTensor imageTensor, TFTensor shape)
    2.         {
    3.             var runner = this.sess.GetRunner();
    4.             runner.AddInput(this.graph["input_1"][0], imageTensor).
    5.                 AddInput(this.graph["image_shape"][0], shape).Fetch(
    6.                 this.graph["boxes"][0],  //(bottom left (y, x), top right (y, x))
    7.                 this.graph["scores"][0],
    8.                 this.graph["classes"][0]);
    9.             TFTensor[] output = runner.Run();
    10.             var boxes = (float[,])output[0].GetValue(jagged: false);
    11.             var scores = (float[])output[1].GetValue(jagged: false);
    12.             var classes = (float[])output[2].GetValue(jagged: false);
    13.             Debug.Log(classes);
    15.             return output;
    16.         }
    My path forward right now will be to just switch to Barracuda. But for time efficiency, it would be a big step forward if there's a simple fix to get this Tensorflowsharp version running on Android.

    * [Edit] the boxes, scores, and classes variables are just there in the code so I can inspect them. They actually don't successfully initialize past 'null'.