Some checks failed
deploy / build-n-publish (push) Has been cancelled
lint / lint (push) Has been cancelled
build / build_cpu (3.7, 1.5.1, torch1.5, 0.6.1) (push) Has been cancelled
build / build_cpu (3.7, 1.6.0, torch1.6, 0.7.0) (push) Has been cancelled
build / build_cpu (3.7, 1.7.0, torch1.7, 0.8.1) (push) Has been cancelled
build / build_cpu (3.7, 1.8.0, torch1.8, 0.9.0) (push) Has been cancelled
build / build_cpu (3.7, 1.9.0, torch1.9, 0.10.0) (push) Has been cancelled
build / build_cuda101 (3.7, 1.5.1+cu101, torch1.5, 0.6.1+cu101) (push) Has been cancelled
build / build_cuda101 (3.7, 1.6.0+cu101, torch1.6, 0.7.0+cu101) (push) Has been cancelled
build / build_cuda101 (3.7, 1.7.0+cu101, torch1.7, 0.8.1+cu101) (push) Has been cancelled
build / build_cuda101 (3.7, 1.8.0+cu101, torch1.8, 0.9.0+cu101) (push) Has been cancelled
build / build_cuda102 (3.6, 1.9.0+cu102, torch1.9, 0.10.0+cu102) (push) Has been cancelled
build / build_cuda102 (3.7, 1.9.0+cu102, torch1.9, 0.10.0+cu102) (push) Has been cancelled
build / build_cuda102 (3.8, 1.9.0+cu102, torch1.9, 0.10.0+cu102) (push) Has been cancelled
build / build_cuda102 (3.9, 1.9.0+cu102, torch1.9, 0.10.0+cu102) (push) Has been cancelled
build / test_windows (windows-2022, cpu, 3.8) (push) Has been cancelled
build / test_windows (windows-2022, cu111, 3.8) (push) Has been cancelled
- Add golf1/2/4/7/8 dataset classes for semantic segmentation - Add kneron-specific configs (meconfig series, kn_stdc1_golf4class) - Organize scripts into tools/check/ and tools/kneron/ - Add kneron_preprocessing module - Update README with quick-start guide - Update .gitignore to exclude data dirs, onnx, nef outputs Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
46 lines
1.4 KiB
Python
46 lines
1.4 KiB
Python
import numpy as np
|
|
from .utils import str2bool, str2int
|
|
|
|
class runner(object):
|
|
def __init__(self, *args, **kwargs):
|
|
self.set = {
|
|
'operator': '',
|
|
"rotate_direction": 0,
|
|
|
|
}
|
|
self.update(*args, **kwargs)
|
|
|
|
def update(self, *args, **kwargs):
|
|
self.set.update(kwargs)
|
|
self.rotate_direction = str2int(self.set['rotate_direction'])
|
|
|
|
# print info
|
|
if str2bool(self.set['b_print']):
|
|
self.print_info()
|
|
|
|
def print_info(self):
|
|
print("<rotate>",
|
|
'rotate_direction', self.rotate_direction,)
|
|
|
|
|
|
def run(self, image_data):
|
|
image_data = self._rotate(image_data)
|
|
return image_data
|
|
|
|
def _rotate(self,img):
|
|
if self.rotate_direction == 1 or self.rotate_direction == 2:
|
|
col, row, unit = img.shape
|
|
pInBuf = img.reshape((-1,1))
|
|
pOutBufTemp = np.zeros((col* row* unit))
|
|
for r in range(row):
|
|
for c in range(col):
|
|
for u in range(unit):
|
|
if self.rotate_direction == 1:
|
|
pOutBufTemp[unit * (c * row + (row - r - 1))+u] = pInBuf[unit * (r * col + c)+u]
|
|
elif self.rotate_direction == 2:
|
|
pOutBufTemp[unit * (row * (col - c - 1) + r)+u] = pInBuf[unit * (r * col + c)+u]
|
|
|
|
img = pOutBufTemp.reshape((col,row,unit))
|
|
|
|
return img
|