Skip to content

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

@skywalker78

Description

@skywalker78

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];
                    }
                }
            });
       
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions