Jacobellis Dan (dgj335)
commited on
Commit
·
6a8d727
1
Parent(s):
051155c
entropy coding
Browse files- README.ipynb +0 -0
- README.md +26 -26
- README_files/README_5_0.jpg +2 -2
- README_files/README_5_0.png +2 -2
- README_files/README_8_0.png +2 -2
- README_files/README_9_0.jpg +2 -2
- README_files/README_9_0.png +2 -2
- walloc.ipynb +0 -0
README.ipynb
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
README.md
CHANGED
@@ -1,7 +1,3 @@
|
|
1 |
-
---
|
2 |
-
datasets:
|
3 |
-
- danjacobellis/LSDIR_540
|
4 |
-
---
|
5 |
```python
|
6 |
!pip install walloc PyWavelets pytorch-wavelets
|
7 |
```
|
@@ -13,8 +9,10 @@ datasets:
|
|
13 |
|
14 |
|
15 |
```python
|
|
|
16 |
import torch
|
17 |
import matplotlib.pyplot as plt
|
|
|
18 |
from PIL import Image
|
19 |
from IPython.display import display
|
20 |
from torchvision.transforms import ToPILImage, PILToTensor
|
@@ -25,14 +23,14 @@ class Args: pass
|
|
25 |
|
26 |
```python
|
27 |
device = "cpu"
|
28 |
-
checkpoint = torch.load("v0.
|
29 |
args = checkpoint['args']
|
30 |
codec = Walloc(
|
31 |
channels = args.channels,
|
32 |
J = args.J,
|
33 |
N = args.N,
|
34 |
latent_dim = args.latent_dim,
|
35 |
-
latent_bits =
|
36 |
)
|
37 |
codec.load_state_dict(checkpoint['model_state_dict'])
|
38 |
codec = codec.to(device)
|
@@ -84,7 +82,7 @@ with torch.no_grad():
|
|
84 |
print(f"dimensionality reduction: {x.numel()/Y.numel()}x")
|
85 |
```
|
86 |
|
87 |
-
dimensionality reduction:
|
88 |
|
89 |
|
90 |
|
@@ -95,18 +93,15 @@ Y.unique()
|
|
95 |
|
96 |
|
97 |
|
98 |
-
tensor([-
|
99 |
-
|
100 |
-
|
101 |
-
5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., 16.,
|
102 |
-
17., 18., 19., 20., 21., 22., 23., 24., 25., 26., 27., 28.,
|
103 |
-
29., 30., 31.])
|
104 |
|
105 |
|
106 |
|
107 |
|
108 |
```python
|
109 |
-
plt.hist(Y.flatten().numpy(),range=(-
|
110 |
```
|
111 |
|
112 |
|
@@ -117,28 +112,33 @@ plt.hist(Y.flatten().numpy(),range=(-32,32),bins=65);
|
|
117 |
|
118 |
|
119 |
```python
|
120 |
-
|
121 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
```
|
123 |
|
124 |
|
125 |
-
|
126 |
-
![png](README_files/README_9_0.png)
|
127 |
-
|
128 |
-
|
129 |
|
130 |
|
131 |
|
132 |
-
![png](README_files/
|
133 |
|
134 |
|
135 |
|
136 |
|
137 |
-
|
138 |
-
![png](README_files/README_9_2.png)
|
139 |
-
|
140 |
|
|
|
|
|
|
|
|
|
141 |
|
|
|
142 |
|
143 |
-
|
144 |
-
![png](README_files/README_9_3.png)
|
|
|
|
|
|
|
|
|
|
|
1 |
```python
|
2 |
!pip install walloc PyWavelets pytorch-wavelets
|
3 |
```
|
|
|
9 |
|
10 |
|
11 |
```python
|
12 |
+
import os
|
13 |
import torch
|
14 |
import matplotlib.pyplot as plt
|
15 |
+
import numpy as np
|
16 |
from PIL import Image
|
17 |
from IPython.display import display
|
18 |
from torchvision.transforms import ToPILImage, PILToTensor
|
|
|
23 |
|
24 |
```python
|
25 |
device = "cpu"
|
26 |
+
checkpoint = torch.load("v0.6.1.pth",map_location="cpu")
|
27 |
args = checkpoint['args']
|
28 |
codec = Walloc(
|
29 |
channels = args.channels,
|
30 |
J = args.J,
|
31 |
N = args.N,
|
32 |
latent_dim = args.latent_dim,
|
33 |
+
latent_bits = 5
|
34 |
)
|
35 |
codec.load_state_dict(checkpoint['model_state_dict'])
|
36 |
codec = codec.to(device)
|
|
|
82 |
print(f"dimensionality reduction: {x.numel()/Y.numel()}x")
|
83 |
```
|
84 |
|
85 |
+
dimensionality reduction: 12.0x
|
86 |
|
87 |
|
88 |
|
|
|
93 |
|
94 |
|
95 |
|
96 |
+
tensor([-15., -14., -13., -12., -11., -10., -9., -8., -7., -6., -5., -4.,
|
97 |
+
-3., -2., -1., 0., 1., 2., 3., 4., 5., 6., 7., 8.,
|
98 |
+
9., 10., 11., 12., 13., 14., 15.])
|
|
|
|
|
|
|
99 |
|
100 |
|
101 |
|
102 |
|
103 |
```python
|
104 |
+
plt.hist(Y.flatten().numpy(),range=(-17.5,17.5),bins=35);
|
105 |
```
|
106 |
|
107 |
|
|
|
112 |
|
113 |
|
114 |
```python
|
115 |
+
grid_size = 4
|
116 |
+
n_channels, H, W = Y[0].shape
|
117 |
+
combined_image = Image.new('L', (W * grid_size, H * grid_size))
|
118 |
+
size_bytes = 0
|
119 |
+
for i, channel in enumerate(Y[0]):
|
120 |
+
channel = (channel+16).to(torch.uint8)
|
121 |
+
row = i // grid_size
|
122 |
+
col = i % grid_size
|
123 |
+
channel = ToPILImage()(channel)
|
124 |
+
combined_image.paste(channel, (col * W, row * H))
|
125 |
+
combined_image
|
126 |
```
|
127 |
|
128 |
|
|
|
|
|
|
|
|
|
129 |
|
130 |
|
131 |
|
132 |
+
![png](README_files/README_9_0.png)
|
133 |
|
134 |
|
135 |
|
136 |
|
|
|
|
|
|
|
137 |
|
138 |
+
```python
|
139 |
+
combined_image.save('tmp.png')
|
140 |
+
print("compression_ratio: ", x.numel()/os.path.getsize("tmp.png"))
|
141 |
+
```
|
142 |
|
143 |
+
compression_ratio: 20.75383532723434
|
144 |
|
|
|
|
README_files/README_5_0.jpg
CHANGED
Git LFS Details
|
Git LFS Details
|
README_files/README_5_0.png
CHANGED
Git LFS Details
|
Git LFS Details
|
README_files/README_8_0.png
CHANGED
Git LFS Details
|
Git LFS Details
|
README_files/README_9_0.jpg
CHANGED
Git LFS Details
|
Git LFS Details
|
README_files/README_9_0.png
CHANGED
Git LFS Details
|
Git LFS Details
|
walloc.ipynb
DELETED
The diff for this file is too large to render.
See raw diff
|
|