Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Using a tensorflow model

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

  1. DanAmador

    DanAmador

    Joined:
    Jun 28, 2015
    Posts:
    1
    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();
    graph.Import(graphModel.bytes);
    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

    jameskanestl

    Joined:
    Nov 3, 2017
    Posts:
    12
    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

    kim_me_ma_ro

    Joined:
    Oct 8, 2015
    Posts:
    4
    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

    q8sr

    Joined:
    Nov 21, 2014
    Posts:
    4
    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.