GithubHelp home page GithubHelp logo

Help with pycaffe about dbpn-caffe HOT 5 CLOSED

alterzero avatar alterzero commented on August 16, 2024
Help with pycaffe

from dbpn-caffe.

Comments (5)

alterzero avatar alterzero commented on August 16, 2024

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.

cmcuza avatar cmcuza commented on August 16, 2024

Hi,

Thank you for your reply, it works perfect now !!!!!

from dbpn-caffe.

alexnie1997 avatar alexnie1997 commented on August 16, 2024

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.

cmcuza avatar cmcuza commented on August 16, 2024

Hi, you are right I had to change dimension in the prototxt, change 57 and 86 to 64.

from dbpn-caffe.

alexnie1997 avatar alexnie1997 commented on August 16, 2024

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.

dbpn_caffe_x4 _result
dbpn_pytorch_x4_result

from dbpn-caffe.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.