forked from SciSharp/TensorFlow.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata_utils.cs
More file actions
37 lines (32 loc) · 1.07 KB
/
data_utils.cs
File metadata and controls
37 lines (32 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace Tensorflow.Keras.Utils
{
public class data_utils
{
public static string get_file(string fname, string origin,
bool untar = false,
string md5_hash = null,
string file_hash = null,
string cache_subdir = "datasets",
string hash_algorithm = "auto",
bool extract = false,
string archive_format = "auto",
string cache_dir = null)
{
var datadir_base = cache_dir;
Directory.CreateDirectory(datadir_base);
var datadir = Path.Combine(datadir_base, cache_subdir);
Directory.CreateDirectory(datadir);
Web.Download(origin, datadir, fname);
if (untar)
Compress.ExtractTGZ(Path.Combine(datadir_base, fname), datadir_base);
else if (extract)
Compress.ExtractGZip(Path.Combine(datadir_base, fname), datadir_base);
return datadir;
}
}
}