Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/TensorFlowNET.Core/Sessions/BaseSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,12 @@ private unsafe NDArray fetchValue(IntPtr output)
var str = UTF8Encoding.Default.GetString(bytes, 9, bytes[8]);
nd = np.array(str).reshape();
break;
case TF_DataType.TF_UINT8:
var _bytes = new byte[tensor.size];
for (ulong i = 0; i < tensor.size; i++)
_bytes[i] = *(byte*)(offset + (int)(tensor.itemsize * i));
nd = np.array(_bytes).reshape(ndims);
break;
case TF_DataType.TF_INT16:
var shorts = new short[tensor.size];
for (ulong i = 0; i < tensor.size; i++)
Expand Down
3 changes: 2 additions & 1 deletion src/TensorFlowNET.Core/Tensors/Tensor.Creation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ private IntPtr Allocate(NDArray nd)
case "Double":
Marshal.Copy(nd1.Data<double>(), 0, dotHandle, nd.size);
break;
//case "Byte":
case "Byte":
Marshal.Copy(nd1.Data<byte>(), 0, dotHandle, nd.size);
/*var bb = nd.Data<byte>();
var bytes = Marshal.AllocHGlobal(bb.Length);
Marshal.Copy(bb, 0, bytes, bb.Length);
Expand Down
1 change: 1 addition & 0 deletions src/TensorFlowNET.Core/Tensors/Tensor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ public TF_DataType ToTFDataType(Type type)
case "Double":
return TF_DataType.TF_DOUBLE;
case "Byte":
return TF_DataType.TF_UINT8;
case "String":
return TF_DataType.TF_STRING;
default:
Expand Down
5 changes: 2 additions & 3 deletions test/TensorFlowNET.Examples/ObjectDetection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class ObjectDetection : Python, IExample

public bool Run()
{
//buildOutputImage(null);
PrepareData();

// read in the input image
var imgArr = ReadTensorFromImageFile(Path.Join(imageDir, "input.jpg"));
Expand Down Expand Up @@ -91,7 +91,7 @@ public void PrepareData()
// download the pbtxt file
if (!File.Exists(Path.Join(modelDir, "mscoco_label_map.pbtxt")))
{
string url = $"https://github.com/tensorflow/models/blob/master/research/object_detection/data/mscoco_label_map.pbtxt";
string url = $"https://raw.githubusercontent.com/tensorflow/models/master/research/object_detection/data/mscoco_label_map.pbtxt";
Utility.Web.Download(url, modelDir, "mscoco_label_map.pbtxt");
}
}
Expand Down Expand Up @@ -123,7 +123,6 @@ private void buildOutputImage(NDArray[] resultArr)
float score = scores[i];
if (score > MIN_SCORE)
{
//var boxes = resultArr[1].Data<float[,,]>();
float[] boxes = resultArr[1].Data<float>();
float top = boxes[i * 4] * bitmap.Height;
float left = boxes[i * 4 + 1] * bitmap.Width;
Expand Down