Skip to content

Commit ad65d5c

Browse files
author
Abdul Dakkak
committed
1 parent 2bb839f commit ad65d5c

14 files changed

+78
-0
lines changed

config.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,25 @@ type dldatasetConfig struct {
1111
done chan struct{} `json:"-" config:"-"`
1212
}
1313

14+
// Config ...
1415
var (
1516
// Config holds the data read by rai-project/config
1617
Config = &dldatasetConfig{
1718
done: make(chan struct{}),
1819
}
1920
)
2021

22+
// ConfigName ...
2123
func (dldatasetConfig) ConfigName() string {
2224
return "DLDataset"
2325
}
2426

27+
// SetDefaults ...
2528
func (c *dldatasetConfig) SetDefaults() {
2629
vipertags.SetDefaults(c)
2730
}
2831

32+
// Read ...
2933
func (c *dldatasetConfig) Read() {
3034
defer close(c.done)
3135
config.App.Wait()
@@ -35,14 +39,17 @@ func (c *dldatasetConfig) Read() {
3539
}
3640
}
3741

42+
// Wait ...
3843
func (c dldatasetConfig) Wait() {
3944
<-c.done
4045
}
4146

47+
// String ...
4248
func (c dldatasetConfig) String() string {
4349
return pp.Sprintln(c)
4450
}
4551

52+
// Debug ...
4653
func (c dldatasetConfig) Debug() {
4754
log.Debug("DLDataset Config = ", c)
4855
}

dldataset.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ import (
66
context "golang.org/x/net/context"
77
)
88

9+
// LabeledData ...
910
type LabeledData interface {
1011
Label() string
1112
Data() (interface{}, error)
1213
}
1314

15+
// Dataset ...
1416
type Dataset interface {
1517
New(ctx context.Context) (Dataset, error)
1618
Category() string

register.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010

1111
var datasets syncmap.Map
1212

13+
// Get ...
1314
func Get(category, name string) (Dataset, error) {
1415
category = strings.ToLower(category)
1516
name = strings.ToLower(name)
@@ -31,10 +32,12 @@ func Get(category, name string) (Dataset, error) {
3132
return dataset, nil
3233
}
3334

35+
// Register ...
3436
func Register(d Dataset) {
3537
datasets.Store(d.CanonicalName(), d)
3638
}
3739

40+
// Datasets ...
3841
func Datasets() []string {
3942
names := []string{}
4043
datasets.Range(func(key, _ interface{}) bool {

vision/base.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ type base struct {
99
baseWorkingDir string
1010
}
1111

12+
// Category ...
1213
func (base) Category() string {
1314
return "vision"
1415
}

vision/cifar10.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323

2424
var cifar10 *CIFAR10
2525

26+
// CIFAR10 ...
2627
type CIFAR10 struct {
2728
base
2829
url string
@@ -40,34 +41,41 @@ type CIFAR10 struct {
4041
isDownloaded bool
4142
}
4243

44+
// CIFAR10LabeledImage ...
4345
type CIFAR10LabeledImage struct {
4446
label string
4547
data *types.RGBImage
4648
}
4749

50+
// Label ...
4851
func (l CIFAR10LabeledImage) Label() string {
4952
return l.label
5053
}
5154

55+
// Data ...
5256
func (l CIFAR10LabeledImage) Data() (interface{}, error) {
5357
return l.data, nil
5458
}
5559

60+
// Name ...
5661
func (*CIFAR10) Name() string {
5762
return "CIFAR10"
5863
}
5964

65+
// CanonicalName ...
6066
func (d *CIFAR10) CanonicalName() string {
6167
category := strings.ToLower(d.Category())
6268
name := strings.ToLower(d.Name())
6369
key := path.Join(category, name)
6470
return key
6571
}
6672

73+
// New ...
6774
func (d *CIFAR10) New(ctx context.Context) (dldataset.Dataset, error) {
6875
return cifar10, nil
6976
}
7077

78+
// Download ...
7179
func (d *CIFAR10) Download(ctx context.Context) error {
7280
if d.isDownloaded {
7381
return nil
@@ -135,6 +143,7 @@ func (d *CIFAR10) move(ctx context.Context) error {
135143
return nil
136144
}
137145

146+
// List ...
138147
func (d *CIFAR10) List(ctx context.Context) ([]string, error) {
139148
if err := d.read(ctx); err != nil {
140149
return nil, err
@@ -146,6 +155,7 @@ func (d *CIFAR10) List(ctx context.Context) ([]string, error) {
146155
return keys, nil
147156
}
148157

158+
// Get ...
149159
func (d *CIFAR10) Get(ctx context.Context, name string) (dldataset.LabeledData, error) {
150160
if err := d.read(ctx); err != nil {
151161
return nil, err
@@ -279,6 +289,7 @@ func (d *CIFAR10) readLabels(ctx context.Context) error {
279289
return nil
280290
}
281291

292+
// Close ...
282293
func (d *CIFAR10) Close() error {
283294
return nil
284295
}

vision/cifar100.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323

2424
var cifar100 *CIFAR100
2525

26+
// CIFAR100 ...
2627
type CIFAR100 struct {
2728
base
2829
url string
@@ -43,43 +44,52 @@ type CIFAR100 struct {
4344
isDownloaded bool
4445
}
4546

47+
// CIFAR100LabeledImage ...
4648
type CIFAR100LabeledImage struct {
4749
coarseLabel string
4850
fineLabel string
4951
data *types.RGBImage
5052
}
5153

54+
// CoarseLabel ...
5255
func (l CIFAR100LabeledImage) CoarseLabel() string {
5356
return l.coarseLabel
5457
}
5558

59+
// FineLabel ...
5660
func (l CIFAR100LabeledImage) FineLabel() string {
5761
return l.fineLabel
5862
}
5963

64+
// Label ...
6065
func (l CIFAR100LabeledImage) Label() string {
6166
return l.FineLabel()
6267
}
6368

69+
// Data ...
6470
func (l CIFAR100LabeledImage) Data() (interface{}, error) {
6571
return l.data, nil
6672
}
6773

74+
// Name ...
6875
func (*CIFAR100) Name() string {
6976
return "CIFAR100"
7077
}
7178

79+
// CanonicalName ...
7280
func (d *CIFAR100) CanonicalName() string {
7381
category := strings.ToLower(d.Category())
7482
name := strings.ToLower(d.Name())
7583
key := path.Join(category, name)
7684
return key
7785
}
7886

87+
// New ...
7988
func (d *CIFAR100) New(ctx context.Context) (dldataset.Dataset, error) {
8089
return cifar100, nil
8190
}
8291

92+
// Download ...
8393
func (d *CIFAR100) Download(ctx context.Context) error {
8494
if d.isDownloaded {
8595
return nil
@@ -157,6 +167,7 @@ func (d *CIFAR100) move(ctx context.Context) error {
157167
return nil
158168
}
159169

170+
// List ...
160171
func (d *CIFAR100) List(ctx context.Context) ([]string, error) {
161172
if err := d.read(ctx); err != nil {
162173
return nil, err
@@ -168,6 +179,7 @@ func (d *CIFAR100) List(ctx context.Context) ([]string, error) {
168179
return keys, nil
169180
}
170181

182+
// Get ...
171183
func (d *CIFAR100) Get(ctx context.Context, name string) (dldataset.LabeledData, error) {
172184
if err := d.read(ctx); err != nil {
173185
return nil, err
@@ -332,6 +344,7 @@ func (d *CIFAR100) readLabels(ctx context.Context) error {
332344
return nil
333345
}
334346

347+
// Close ...
335348
func (d *CIFAR100) Close() error {
336349
return nil
337350
}

vision/cifar100_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/stretchr/testify/assert"
1010
)
1111

12+
// TestDownloadCIFAR100 ...
1213
func TestDownloadCIFAR100(t *testing.T) {
1314
ctx := context.Background()
1415

vision/cifar10_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/stretchr/testify/assert"
1010
)
1111

12+
// TestDownloadCIFAR10 ...
1213
func TestDownloadCIFAR10(t *testing.T) {
1314
ctx := context.Background()
1415

vision/ilsvrc2012_validation.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818

1919
var iLSVRC2012Validation *ILSVRC2012Validation
2020

21+
// ILSVRC2012Validation ...
2122
type ILSVRC2012Validation struct {
2223
base
2324
baseURL string
@@ -26,19 +27,23 @@ type ILSVRC2012Validation struct {
2627
data map[string]ILSVRC2012ValidationLabeledImage
2728
}
2829

30+
// ILSVRC2012ValidationLabeledImage ...
2931
type ILSVRC2012ValidationLabeledImage struct {
3032
label string
3133
data *types.RGBImage
3234
}
3335

36+
// Label ...
3437
func (l ILSVRC2012ValidationLabeledImage) Label() string {
3538
return l.label
3639
}
3740

41+
// Data ...
3842
func (l ILSVRC2012ValidationLabeledImage) Data() (interface{}, error) {
3943
return l.data, nil
4044
}
4145

46+
// New ...
4247
func (d *ILSVRC2012Validation) New(ctx context.Context) (dldataset.Dataset, error) {
4348
return iLSVRC2012Validation, nil
4449
}
@@ -49,25 +54,30 @@ func (d *ILSVRC2012Validation) workingDir() string {
4954
return filepath.Join(d.baseWorkingDir, category, name)
5055
}
5156

57+
// Name ...
5258
func (d *ILSVRC2012Validation) Name() string {
5359
return "ilsvrc2012_validation"
5460
}
5561

62+
// CanonicalName ...
5663
func (d *ILSVRC2012Validation) CanonicalName() string {
5764
category := strings.ToLower(d.Category())
5865
name := strings.ToLower(d.Name())
5966
key := path.Join(category, name)
6067
return key
6168
}
6269

70+
// Download ...
6371
func (d *ILSVRC2012Validation) Download(ctx context.Context) error {
6472
return nil
6573
}
6674

75+
// List ...
6776
func (d *ILSVRC2012Validation) List(ctx context.Context) ([]string, error) {
6877
return d.filePaths, nil
6978
}
7079

80+
// GetWithoutDownloadManager ...
7181
func (d *ILSVRC2012Validation) GetWithoutDownloadManager(ctx context.Context, name string) (dldataset.LabeledData, error) {
7282
fileURL, ok := d.fileURLs[name]
7383
if !ok {
@@ -96,6 +106,7 @@ func (d *ILSVRC2012Validation) GetWithoutDownloadManager(ctx context.Context, na
96106
}, nil
97107
}
98108

109+
// Get ...
99110
func (d *ILSVRC2012Validation) Get(ctx context.Context, name string) (dldataset.LabeledData, error) {
100111
fileURL, ok := d.fileURLs[name]
101112
if !ok {
@@ -133,6 +144,7 @@ func (d *ILSVRC2012Validation) Get(ctx context.Context, name string) (dldataset.
133144
}, nil
134145
}
135146

147+
// Close ...
136148
func (d *ILSVRC2012Validation) Close() error {
137149
return nil
138150
}

vision/ilsvrc2012_validation_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
context "golang.org/x/net/context"
1010
)
1111

12+
// TestILSVRC2012Validation ...
1213
func TestILSVRC2012Validation(t *testing.T) {
1314

1415
ctx := context.Background()

0 commit comments

Comments
 (0)