You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

ImageRecognition.cs 843 B

6 years ago
123456789101112131415161718192021222324252627282930
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.IO.Compression;
  5. using System.Linq;
  6. using System.Net;
  7. using System.Text;
  8. using Tensorflow;
  9. namespace TensorFlowNET.Examples
  10. {
  11. public class ImageRecognition : Python, IExample
  12. {
  13. public void Run()
  14. {
  15. var graph = new Graph();
  16. //import GraphDef from pb file
  17. graph.Import("tmp/tensorflow_inception_graph.pb");
  18. with<Session>(tf.Session(graph), sess =>
  19. {
  20. var labels = File.ReadAllLines("tmp/imagenet_comp_graph_label_strings.txt");
  21. var files = Directory.GetFiles("img");
  22. foreach(var file in files)
  23. {
  24. var tensor = new Tensor(File.ReadAllBytes(file));
  25. }
  26. });
  27. }
  28. }
  29. }

tensorflow框架的.NET版本,提供了丰富的特性和API,可以借此很方便地在.NET平台下搭建深度学习训练与推理流程。