GithubHelp home page GithubHelp logo

red-net's People

Contributors

ved27 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

red-net's Issues

help

could you please provide the trainning code ?

Here is small python inference code for denoise

Here I wrote python inference code for denoise, so one can use it as guideline:

import caffe

from PIL import Image
import numpy as np
import cv2



# load model

caffe.set_mode_cpu() # the model is very greedy for GPU ram, it does not want to work on my 4G GPU

net = caffe.Net('model/REDNet_ch1.prototxt','model/denoising/30.caffemodel', caffe.TEST)

img = np.array(Image.open('256x256.png').convert('YCbCr'))

y =img[...,0]
res8cb =img[...,1]
res8cr = img[...,2]


img = y/255.0

net.blobs['data'].reshape(*(1,1, img.shape[0], img.shape[1]))



img_out = np.zeros(shape=(img.shape[0], img.shape[1],8), dtype=np.float32);

for i in range(1, 5):
    i1 = np.rot90(img, i-1)[np.newaxis, np.newaxis,...]
    net.blobs['data'].data[...] = i1
    net.forward()
    res = net.blobs['d15'].data[...]

    img_out[:,:,i-1] = np.rot90(res[0,0,:,:], 5-i) + img;

    print('-')
for i in range(5, 8):
    i1 = np.rot90(np.fliplr(img), i-5)[np.newaxis, np.newaxis,...]
    net.blobs['data'].data[...] = i1
    net.forward()
    res = net.blobs['d15'].data[...]

    img_out[:,:,i-1] = np.rot90(res[0,0,:,:], 9-i) + img;
    print('-')



img_out = np.mean(img_out,axis=-1);


res8y = (img_out*255.0).astype(np.uint8)






# Optional: color histogram becomes dark, need to fix it.
# But this may highlight remaining noise


clahe = cv2.createCLAHE(clipLimit=2.0, tileGridSize=(8,8))
res8y = clahe.apply(res8y)




res_out = np.concatenate([res8y[...,np.newaxis], res8cb[...,np.newaxis], res8cr[...,np.newaxis]], axis=-1)

Image.fromarray(res_out, mode='YCbCr').convert('RGB').save('out.png')

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.