-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #171 from oarriaga/pix2pose_refactor
PIX2POSE refactor
- Loading branch information
Showing
26 changed files
with
3,323 additions
and
496 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
from paz.abstract import SequentialProcessor, Processor | ||
from paz import processors as pr | ||
import numpy as np | ||
# import pytest | ||
|
||
|
||
class PipelineWithTwoChannels(SequentialProcessor): | ||
def __init__(self): | ||
super(PipelineWithTwoChannels, self).__init__() | ||
self.add(lambda x: x) | ||
self.add(pr.ControlMap(pr.Copy(), [0], [1], keep={0: 0})) | ||
|
||
|
||
class PipelineWithThreeChannels(SequentialProcessor): | ||
def __init__(self): | ||
super(PipelineWithThreeChannels, self).__init__() | ||
self.add(lambda a, b: (a, b)) | ||
self.add(pr.ControlMap(pr.Copy(), [0], [2], keep={0: 0})) | ||
|
||
|
||
class PipelineWithThreeChannelsPlus(SequentialProcessor): | ||
def __init__(self): | ||
super(PipelineWithThreeChannelsPlus, self).__init__() | ||
self.add(lambda a, b: (a, b)) | ||
self.add(pr.ControlMap(pr.Copy(), [0], [2], keep={0: 0})) | ||
self.add(pr.ControlMap(SumTwoValues(), [0, 1], [0])) | ||
|
||
|
||
class SumTwoValues(Processor): | ||
def __init__(self): | ||
super(SumTwoValues, self).__init__() | ||
|
||
def call(self, A, B): | ||
return A + B | ||
|
||
|
||
def test_copy_with_controlmap_using_2_channels(): | ||
pipeline = PipelineWithTwoChannels() | ||
random_values = np.random.random((128, 128)) | ||
values = pipeline(random_values) | ||
assert len(values) == 2 | ||
assert np.allclose(values[0], random_values) | ||
assert np.allclose(values[1], random_values) | ||
|
||
|
||
def test_copy_with_controlmap_using_3_channels(): | ||
pipeline = PipelineWithThreeChannels() | ||
A_random_values = np.random.random((128, 128)) | ||
B_random_values = np.random.random((128, 128)) | ||
values = pipeline(A_random_values, B_random_values) | ||
assert len(values) == 3 | ||
assert np.allclose(values[0], A_random_values) | ||
assert np.allclose(values[1], B_random_values) | ||
assert np.allclose(values[2], A_random_values) | ||
|
||
|
||
def test_copy_with_controlmap_using_3_channels_plus(): | ||
pipeline = PipelineWithThreeChannelsPlus() | ||
A_random_values = np.random.random((128, 128)) | ||
B_random_values = np.random.random((128, 128)) | ||
values = pipeline(A_random_values, B_random_values) | ||
assert len(values) == 2 | ||
assert np.allclose(values[0], A_random_values + B_random_values) | ||
assert np.allclose(values[1], A_random_values) |
Oops, something went wrong.