Comments (2)
Any update on releasing keras version? Thanks!
from subpixel.
If youre using keras with tensorflow backend, you can use the given code to create a lambda layer doing the PS operation
check out lambda layers :
https://keras.io/layers/core/#lambda
And the code, i just changed the reshape and split lines to fit latest tensorflow version
def _phase_shift(I, r):
input_shape = tf.shape(I)
bsize = input_shape[0]
a = input_shape[1]
b = input_shape[2]
c = input_shape[3]
shape = tf.stack([bsize,a,b,r,r])
input_shape_as_numbers = I.get_shape()
X = tf.reshape(tensor=I, shape=shape)
X = tf.transpose(X, (0, 1, 2, 4, 3)) # bsize, a, b, 1, 1
X = tf.split(X, input_shape_as_numbers[1], axis=1) # a, [bsize, b, r, r]
X = tf.concat([tf.squeeze(x) for x in X], axis=2) # bsize, b, a*r, r
X = tf.split(X,input_shape_as_numbers[2], axis=1) # b, [bsize, a*r, r]
X = tf.concat([tf.squeeze(x) for x in X], axis=2) # bsize, a*r, b*r
return tf.reshape(X, (bsize, a*r, b*r, 1))
def PS(input_shape, r, color=False):
def subpixel_shape(input_shape):
dims = [input_shape[0],
input_shape[1] * r,
input_shape[2] * r,
int(input_shape[3] / (r ** 2))]
output_shape = tuple(dims)
return output_shape
def subpixel(x):
if color:
Xc = tf.split(3, 3, X)
X = tf.concat(3, [_phase_shift(x, r) for x in Xc])
else:
x_upsampled = _phase_shift(x, r)
return x_upsampled
return Lambda(subpixel, output_shape=subpixel_shape, name='subpixel')
Then you would add this layer in a model this way :
upSampled = PS(x_LR.shape, 3, color=False)(x_LR)
from subpixel.
Related Issues (20)
- Implementation for keras HOT 1
- Dynamic image size [batch, None, None, 3] error. HOT 11
- Testing our dataset HOT 1
- Magic number
- Not work on tensorflow 1.3 HOT 2
- TypeError: Input 'split_dim' of 'Split' Op has type float32 that does not match expected type of int32. HOT 3
- problem when run main.py with mnist, Is there anyone have the same problem?or you know how this happen?please give me some advice!Thanks
- Query trained model
- Testing the model
- Please confirm PS(I,r) HOT 1
- How subpixel handle odd image size?
- What to do in grayscale images?
- ###########
- Keras SubPixel 3D
- Pre -Trained model HOT 1
- Evaluation HOT 1
- ValueError: Shape (32, 64, 32, 4, 4) must have rank 0
- the project requestments.txt is needed.
- Is this the same as tf depth_to_space?
- the first paper proposed subpixel convolution?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from subpixel.