TensorFlowSharp
TensorFlowSharp copied to clipboard
python results different from tensorflowsharp
I use tensorflowsharp to locate items on a conveyor belt - it works :) but the results i see on a python (anaconda) are much better than the tensorflowharp
python image is

when i run tensorflowsharp with my inference graph i get

To get here i changed the tnsorflosharp object detection sample like this
_catalogPath = "C:/Users/user 67/Downloads/TensorFlowSharp-master/Examples/ExampleObjectDetection/bin/Debug/demo/inferencegraph/labelmap.pbtxt";
if (_catalogPath == null) {
_catalogPath = DownloadDefaultTexts (_currentDir);
}
_modelPath = "C:/Users/user 67/Downloads/TensorFlowSharp-master/Examples/ExampleObjectDetection/bin/Debug/demo/inferencegraph/frozen_inference_graph.pb";
if (_modelPath == null) {
_modelPath = DownloadDefaultModel (_currentDir);
}
the .pb file is too large to be here i will try to upload it later
all of this in a slightly nicer form in a link link
in the tensorflosharp console differ in that in the original i get some lines of warnings (5-6) while if i try to load my file i get this tensorflosharp results.txt tensorflowsharp does not say if it is an error or just reading of .pb file contents
windows 10 .net 4.7.1
Unrelated question, but could you tell me how did you load Python created savemodel to tensorflowsharp. I have been struggling with this for days without success...
Getting various errors such as: Unhandled Exception: TensorFlow.TFException: Invalid GraphDef
@ibrcic I used - thank you EdjeElectronics - to get a frozen inference graph. then copied the frozen .pb file to the tensorflowsharp project and set _modelPath to direct to it as the code fragment shows.
the problem I get is that it does not get the same results. but loading a .pb file is straight forward
And what does DownloadDefaultModel function does?
as its name suggests DownloadDefaultModel downloads a model from the net and sets it as the working model if you did not specify a model of your choice.
I am also facing this issue in tf C Sharp . Using same model detection is less in C sharp version than python version
Same problem here. With the same model it seems that the model detection is reduced in TensorFlowSharp
Before the execution the image is resized based in the model training, you need to change it based in your model before execute take a look when converting an image to tensor see my code const int W = 300; const int H = 300; const float Mean = 0; const float Scale = 1;
graph = new TFGraph();
input = graph.Placeholder(TFDataType.String);
if (resizeTensor)
{
output = graph.Cast(graph.Div(
x: graph.Sub(
x: graph.ResizeBilinear(
images: graph.ExpandDims(
input: graph.Cast(
graph.DecodeJpeg(contents: input, channels: 3), DstT: TFDataType.Float),
dim: graph.Const(0, "make_batch")),
size: graph.Const(new int[] { W, H }, "size")),
y: graph.Const(Mean, "mean")),
y: graph.Const(Scale, "scale")), destinationDataType);
}
else
{
output = graph.Cast(
graph.ExpandDims(
input: graph.Cast(
graph.DecodeJpeg(contents: input, channels: 3), DstT: TFDataType.Float),
dim: graph.Const(0, "make_batch")), destinationDataType);
}
Thank you for your answer. I arrive to the same solution redoing the code following the python version:
private static TFGraph ConstructGraphToNormalizeImage( out TFOutput input, out TFOutput output, TFDataType destinationDataType = TFDataType.Float) { var graph = new TFGraph();
input = graph.Placeholder(TFDataType.String);
output = graph.Cast(
graph.ExpandDims(
input: graph.Cast(graph.DecodeJpeg(contents: input, channels: 3), DstT: TFDataType.Float),
dim: graph.Const(0, "make_batch")
)
, destinationDataType
);
return graph;
}
The output from the Object Detection demo it's the same that in the Python version.
both answers of @SignalRT and @erlonted work (not the same results but good enough). does anybody know where can one find the image size and mean parameters for the model? if the model depends on other constant parameters is there a list?
The image size of some models that I use is in the TensorFlow/Hub
For example:
https://github.com/tensorflow/hub/blob/master/docs/modules/image.md
You have some general information and links to the doc, for example:
https://www.tensorflow.org/hub/modules/google/imagenet/mobilenet_v1_100_224/classification/1
Hello, I want to run this sample as well. Can anyone guide me to the steps required to run sample object detection?
@oferbentovim, can you please share your object detection in unity project?
sorry, I do not use unity I used python to get this project. I am in the stage where I transformed this into .pb file but I cant yet run it in c# balloon.zip hope the file above helps - it is my version of the baloon project from thank you EdjeElectronic to run training use something like from baloon directory python balloon.py train --dataset=C:\code\Mask_RCNN-master\datasets\balloon --weights=coco