init
This commit is contained in:
14
lib/utils/fb_transform.py
Normal file
14
lib/utils/fb_transform.py
Normal 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
|
Reference in New Issue
Block a user