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
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.

Using a tensorflow model

Discussion in 'AI & Navigation Previews' started by DanAmador, Dec 20, 2017.

  1. DanAmador


    Jun 28, 2015
    Good Day.

    I have a scene where I'm able to draw using a Line tracer and using the camera I'm able to take a screenshot of said drawn scene.

    I'm trying to connect a simple model of a trained CNN on the MNIST dataset the thing is I'm trying to use TensorflowSharp as it's detailed in this README.

    But I'm having problems just trying to process the information

    graph = new TFGraph();
    session = new TFSession(graph);
    var runner = session.GetRunner();

    runner.AddInput(graph["input"][0], image);

    But it says that graph is not an instance of an object.

    How can I access the model ?
    Last edited: Dec 21, 2017
  2. jameskanestl


    Nov 3, 2017
    I'm about to tackle a really similar problem - did you ever get this figured out? Any good resources to point to?
  3. kim_me_ma_ro


    Oct 8, 2015
    Follow this code may be help...

    private TextAsset graphModel;
    graphModel = Resources.Load(graph_path) as TextAsset;

    I think you may forgot the code to import the actual model in it.

    PS graph path rooted in Resources Folder so make sure that the graphmodel is in Resources folder in my case graph path is (public string graph_path= "TFModels/graph";) like this.
  4. q8sr


    Nov 21, 2014
    In case you'd like a working example project to start from, you can check this one out. It's a very simple example project that includes a TensorFlow model, trained graph, and working classifier.