Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

' System.DllNotFoundException has been thrown ."tensorflow" at graph = new Graph().as_default(); #87

Open
skywalker78 opened this issue Apr 25, 2019 · 0 comments

Comments

@skywalker78
Copy link

Hello ,
Im simply trying to test code for image recognition and my code keeps throwing exception at "var graph = new Graph().as_default();' .The error is ' System.DllNotFoundException has been thrown ."tensorflow". I have added Tensorflow.Net from NuGet and there are no compilation errors and all the references are available . Im using Xamarin ,Net Console project .

using NumSharp;
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Net;
using System.Text;
using Tensorflow;
using Tensorflow.Contrib;
using Tensorflow.Framework;
using Tensorflow.Operations;

public static void AnalyzeImage()

   {

        string pb_path ="/Users/jacksparow/Desktop/images2/frozen_inference_graph.pb";
       
       string image_path = "/Users/jacksparow/Desktop/images1/a1.jpg";

           var tensor = ReadTensorFromImageFile(image_path);
           graph = new Graph().as_default();
            //import GraphDef from pb file
            graph.Import(pb_path);

            var input_name = "input";
            var output_name = "output";

            var input_operation = graph.OperationByName(input_name);
            var output_operation = graph.OperationByName(output_name);

            var idx = 0;
            float propability = 0;
            with(tf.Session(graph), sess =>
            {
                var results = sess.run(output_operation.outputs[0], new FeedItem(input_operation.outputs[0], tensor));
                var probabilities = results.Data<float>();
                for (int i = 0; i < probabilities.Length; i++)
                {
                    if (probabilities[i] > propability)
                    {
                        idx = i;
                        propability = probabilities[i];
                    }
                }
            });
       
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant