Comments (5)
Hi,
Sorry for my very late reply. Can you try this code?
##################
import numpy as np
from PIL import Image
import caffe
import sys
import scipy.io
import scipy.misc
import timeit
caffe.set_device(0)
caffe.set_mode_gpu()
inputsize=64
upscale=4
net = caffe.Net("model/DBPN_mat_4x.prototxt", "model/DBPN_4x.caffemodel",caffe.TEST)
transformer = caffe.io.Transformer({'data': net.blobs['data'].data.shape})
transformer.set_transpose('data', (2,0,1))
net.blobs['data'].reshape(1,3,inputsize,inputsize)
im = caffe.io.load_image('baby_GT_input.png', color=True)
net.blobs['data'].data[...] = transformer.preprocess('data', im)
start = timeit.default_timer()
out = net.forward()
stop = timeit.default_timer()
print stop - start
result=net.blobs['conv_final'].data
max_val, min_val = np.max(result[0]), np.min(result[0])
flatten_img = ((result.transpose((0,2,3,1)))[:] - min_val) / (max_val-min_val)
scipy.misc.imsave('result.png', flatten_img.reshape(1,1,inputsizeupscale,inputsizeupscale,3).swapaxes(1,2).reshape(inputsizeupscale,inputsizeupscale, 3))
from dbpn-caffe.
Hi,
Thank you for your reply, it works perfect now !!!!!
from dbpn-caffe.
Hi,
I just copied the scripts you provided and did not change anything of them.
But I got an error as follows:
File "firsttrial.py", line 17, in
net.blobs['data'].data[...] = transformer.preprocess('data', im)
ValueError: could not broadcast input array from shape (3,57,86) into shape (1,3,64,64)
I don't know why you can run it without problem. Did you change some thing in the scripts?
Many thanks
from dbpn-caffe.
Hi, you are right I had to change dimension in the prototxt, change 57 and 86 to 64.
from dbpn-caffe.
Thanks for your message.
After I changed these two parameters, I can run the code without errors.
Did you get the same output as that of pytorch version?
I found that the result of pycaffe is worse than that of pytorch.
from dbpn-caffe.
Related Issues (6)
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 dbpn-caffe.