Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tools and examples organization #19

Merged
merged 44 commits into from
Aug 13, 2020
Merged

Tools and examples organization #19

merged 44 commits into from
Aug 13, 2020

Conversation

pehf
Copy link
Member

@pehf pehf commented Dec 13, 2019

Here we start organizing tools and tutorials. There is more to do.

- fftshift works beyond 2d, renamed everywhere
- kurtosis and skew in new stats file
- rename visualization to display
- TODO organize metamer utils
- typo in basic stimuli
- Added simple model: Steerable followed by gain control (can be real or 
complex)
because we very well might have more than 10 of them
plenoptic/tools/stats.py Outdated Show resolved Hide resolved
Copy link
Member

@billbrod billbrod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made several comments that I think need to be addressed, but they're minor:

  • add docstrings. couple functions that are new, some that we just haven't gotten around to writing them for yet

  • there are several TODOs scattered throughout this that you added. Are they things we want done before merging this PR or that we can wait on? If the latter, let's open issues for them so we don't forget

  • do we need to add an implementation for AlexNet? Rather than just using the pytorch one

and I added some comments either answering or asking for clarification

should have a max of one empty line within functions (two is used to
separate functions or classes)
@billbrod billbrod added this to Review in progress in Roadmap Feb 7, 2020
@pehf
Copy link
Member Author

pehf commented Apr 14, 2020

  • docstrings fixed
  • I'm going to open a new branch to work on all the perceptual distances (SSIM, MSSSIM, NLPD, NSPD, etc.)
  • there are some TODOs left that relate to finalizing the texture statistics model

Furhter nice to have features:

  • edit the reconstruction code to handle the not downsampled version
  • polish front end model
  • document and generalize the conv functions

Copy link
Member

@billbrod billbrod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some more requested changes, most of them small or just asking for clarifications

@@ -6,10 +6,10 @@

class Steerable_GainControl(nn.Module):
"""steerable pyramid followed by local gain control"""
def __init__(self, shape, cmplx=False):
def __init__(self, shape, is_complex=False):
super().__init__()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why order and height shouldn't also be args for this class?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, some of these changes have been made, and I propose to move this to a model_zoo branch

plenoptic/simulate/models/steerable_gaincontrol.py Outdated Show resolved Hide resolved
@@ -32,7 +32,7 @@ def torch_complex_to_numpy(x):

def make_basic_stimuli(size=256, requires_grad=True):

# TODO assert size is a power of 2
assert size in [32, 64, 128, 256, 512], 'size not supported'
impulse = np.zeros((size, size))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are all powers of 2 supported, or just these?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now, this is what we support, making it fully general is not a priority to me.
My use case for this function is to get a set of simple stimuli to develop and debug models with

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, can we get a small docstring that includes that info?

@@ -61,7 +61,7 @@ def make_basic_stimuli(size=256, requires_grad=True):
checkerboard = plt.imread(op.join(DATA_PATH, 'checkerboard.pgm')).astype(float)
# adjusting form 256 to desired size
l = int(np.log2(256 // size))
# TODO for larger size use upConv
# for larger size use upConv
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this comment (because I don't see upConv anywhere). What's it mean?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is if we wanted to work with large images, we could start with a 256x256 and upsample_convolve it.
this last function lives in tools/conv.py, which is meant to be a torch port and generalization of pyrtools equivalents.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay. Can we remove this line and, if you think it's important, open an issue?

plenoptic/tools/display.py Show resolved Hide resolved
plenoptic/tools/signal.py Show resolved Hide resolved
Copy link
Collaborator

@nikparth nikparth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll do this since I wrote that function- I think I forgot to do that in my previous PR

Copy link
Collaborator

@nikparth nikparth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll be tackling the cleaning up and formalizing the steering code and the reconstruction from the not downsampled pyramid.

f2 = gaussian(kernel_size, covariance=1) - f1
self.conv1.weight.data[0,0] = nn.Parameter(torch.tensor(f1, dtype=torch.float32))
self.conv1.weight.data[1,0] = nn.Parameter(torch.tensor(f2, dtype=torch.float32))
self.conv1.weight.data[2,0] = nn.Parameter(torch.tensor(-f2, dtype=torch.float32))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity: couldn't this Linear-Nonlinear model have our Linear model as its linear component? Or is it attempting to model something different.

Eventually I think this (and Linear) should have docstrings that explain what they are and everything, but doesn't need to be part of this PR

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a toy model, not seriously aiming to do anything else but be a base case that is easy to understand and can be useful for development / debugging. If we decide to vamp it up, I propose we do so in a dedicated model_zoo branch

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds good to me.

billbrod and others added 3 commits August 11, 2020 21:36
we're about to delete existing texture stats implementation, and this
test was failing

fraction_removed is tested elsewhere
Copy link
Member

@lyndond lyndond left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just minor docstring comments in steerable_pyramid_freq.py

Putting section headers in examples/03 and examples/04 would be appreciated. They look like works in progress so not high priority. We can polish all tutorials next sprint.

billbrod and others added 7 commits August 12, 2020 14:26
renames VentralModel to PooledVentralStream, RetinalGanglionCells to
PooledRGC, and PrimaryVisualCortex to PooledV1, to clarify what they do

Also updates the first line of each docstring
@nikparth
Copy link
Collaborator

Major changes to structure of the repository and how tools and utility functions are handled. Major changes to steerable pyramid code to include not downsampled versions, fixes for reconstruction and tight frame constraints, steering function, preliminary tutorial. Also heavy documentation updates.

@nikparth nikparth merged commit 6de88e6 into master Aug 13, 2020
Roadmap automation moved this from Review in progress to Done Aug 13, 2020
@billbrod billbrod deleted the tools_organization branch August 13, 2020 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Roadmap
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

5 participants