File: gfs_IN1k.py

package info (click to toggle)
pytorch 1.13.1%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 139,252 kB
  • sloc: cpp: 1,100,274; python: 706,454; ansic: 83,052; asm: 7,618; java: 3,273; sh: 2,841; javascript: 612; makefile: 323; xml: 269; ruby: 185; yacc: 144; objc: 68; lex: 44
file content (54 lines) | stat: -rw-r--r-- 1,406 bytes parent folder | download | duplicates (2)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54





# # example1 using gfs as input source.

def gen_input_builder_fun(self, model, dataset, is_train):
    if is_train:
        input_path = self.opts['input']['train_input_path']
    else:
        input_path = self.opts['input']['test_input_path']

    reader = model.CreateDB("reader",
                            db=input_path,
                            db_type='lmdb',
                            shard_id=self.shard_id,
                            num_shards=self.opts['distributed']['num_shards'],)

    def AddImageInput(model, reader, batch_size, img_size):
        '''
        Image input operator that loads data from reader and
        applies certain transformations to the images.
        '''
        data, label = model.ImageInput(
            reader,
            ["data", "label"],
            batch_size=batch_size,
            use_caffe_datum=True,
            mean=128.,
            std=128.,
            scale=256,
            crop=img_size,
            mirror=1,
            is_test=True
        )
        data = model.StopGradient(data, data)

    def add_image_input(model):
        AddImageInput(
            model,
            reader,
            batch_size=self.opts['epoch_iter']['batch_per_device'],
            img_size=self.opts['input']['imsize'],
        )
    return add_image_input


def get_input_dataset(opts):
    return []


def get_model_input_fun(self):
    pass