Comments (4)
plus you have to edit each train.py as below
from
info = {
'loss': loss,
'sr_loss': sr_loss,
'dm_loss': dm_loss,
'psnr': cur_psnr
}
to
info = {
'loss': loss.item(),
'sr_loss': sr_loss.item(),
'dm_loss': dm_loss.item(),
'psnr': cur_psnr
}
from tenet.
However, I found that tensorflow requires a lot of memory just to log the losses.
So, I changed the code with tensorboard for pytorch.
# import tensorflow as tf
from torch.utils.tensorboard import SummaryWriter
import numpy as np
try:
from StringIO import StringIO # Python 2.7
except ImportError:
from io import BytesIO # Python 3.x
class Tf_Logger(object):
def __init__(self, log_dir):
"""Create a summary writer logging to log_dir."""
self.writer = SummaryWriter(log_dir)
def scalar_summary(self, tag, value, step):
"""Log a scalar variable."""
self.writer.add_scalar(tag, value, step)
def image_summary(self, tag, images, step):
"""Log a list of images."""
for i, img in enumerate(images):
if len(img.shape) == 2:
img = img[np.newaxis,:,:,np.newaxis]
elif len(img.shape) == 3:
img = img[np.newaxis,:,:,:]
self.writer.add_image('%s/%d' % (tag, i), img, step)
def histo_summary(self, tag, values, step, bins=1000):
"""Log a histogram of the tensor of values."""
# Create a histogram using numpy
counts, bin_edges = np.histogram(values, bins=bins)
# Fill the fields of the histogram proto
hist = tf.HistogramProto()
hist.min = float(np.min(values))
hist.max = float(np.max(values))
hist.num = int(np.prod(values.shape))
hist.sum = float(np.sum(values))
hist.sum_squares = float(np.sum(values**2))
# Drop the start of the first bin
bin_edges = bin_edges[1:]
# Add bin edges and counts
for edge in bin_edges:
hist.bucket_limit.append(edge)
for c in counts:
hist.bucket.append(c)
# Create and write Summary
self.writer.add_histogram(tag, hist, step)
from tenet.
In this case, you don't need to transpose RGB images at valid() function.
img = img[0:1, 0:4]
img = torch.clamp(img.cpu()[0, 0], 0, 1).detach().numpy()
gt = torch.clamp(gt.cpu()[0], 0, 1).detach().numpy()
# gt = np.transpose(gt, [1, 2, 0]) # permute
output = torch.clamp(output.cpu()[0], 0, 1).detach().numpy()
# output = np.transpose(output, [1, 2, 0])
from tenet.
@jungwon-choi thank you for your updates! Really helpful.
from tenet.
Related Issues (20)
- .ARW images as input HOT 1
- RAW , linRGB, SRGB
- TypeError: Cannot set tensorflow.Summary.Value.simple_value to tensor(0.0915, device='cuda:0', grad_fn=<ThAddBackward>): tensor(0.0915, device='cuda:0', gred_fn=<ThAddBackward>) has type <calss 'torch.Tensor'>, but expected one of: numbers.Real for field Value.simple_value HOT 1
- PreTrained Weights
- where is the metadata of Pixelshift dataset ? HOT 2
- is the raw data 14 bit ? HOT 4
- Question about PixelShift200 data preparation HOT 1
- It seems the dataset link sucked. HOT 2
- how to download 200 pixel shift dataset ? HOT 2
- thank you to give me pixelshift200 link to download ,but i find 。。。。。
- some problem about pixelshift image HOT 2
- How to extract the image data bayer data in the ARW file instead of exif and meta information
- requirement
- test bug?
- how to convert rgb image to Bayer raw images (bayer pattern is rggb) HOT 8
- Can you release the RGB data of Pixelshift200 datasets? HOT 6
- tenet2-dn-ps200.path HOT 4
- how to set noise_level(or sigma) if I want use it to process other RAW image? HOT 1
- test using provided model HOT 4
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 tenet.