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.

data_utils.cs 1.1 kB

12345678910111213141516171819202122232425262728293031323334353637
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. using System.IO;
  5. using System.Text;
  6. namespace Tensorflow.Keras.Utils
  7. {
  8. public class data_utils
  9. {
  10. public static string get_file(string fname, string origin,
  11. bool untar = false,
  12. string md5_hash = null,
  13. string file_hash = null,
  14. string cache_subdir = "datasets",
  15. string hash_algorithm = "auto",
  16. bool extract = false,
  17. string archive_format = "auto",
  18. string cache_dir = null)
  19. {
  20. var datadir_base = cache_dir;
  21. Directory.CreateDirectory(datadir_base);
  22. var datadir = Path.Combine(datadir_base, cache_subdir);
  23. Directory.CreateDirectory(datadir);
  24. Web.Download(origin, datadir, fname);
  25. if (untar)
  26. Compress.ExtractTGZ(Path.Combine(datadir_base, fname), datadir_base);
  27. else if (extract)
  28. Compress.ExtractGZip(Path.Combine(datadir_base, fname), datadir_base);
  29. return datadir;
  30. }
  31. }
  32. }