This commit is contained in:
D-X-Y
2019-02-01 01:27:38 +11:00
commit 13e908f4df
104 changed files with 102494 additions and 0 deletions

14
lib/utils/fb_transform.py Normal file
View File

@@ -0,0 +1,14 @@
import torch
import random
import numpy as np
class ApplyOffset(object):
def __init__(self, offset):
assert isinstance(offset, int), 'The offset is not right : {}'.format(offset)
self.offset = offset
def __call__(self, x):
if isinstance(x, np.ndarray) and x.dtype == 'uint8':
x = x.astype(int)
if isinstance(x, np.ndarray) and x.size == 1:
x = int(x)
return x + self.offset