Sha256: 282307826bbd254cee4ac8fa0cb17e46dc81ba8ab5ec63ca9e89137493a684d0

Contents?: true

Size: 663 Bytes

Versions: 16

Compression:

Stored size: 663 Bytes

Contents

require "dnn"
require "dnn/image"
require "dnn/datasets/cifar10"
require "numo/linalg/autoloader"
require_relative "dcgan"

def load_dataset
  x, y = DNN::CIFAR10.load_test
  x_out = Numo::SFloat.cast(x)
  x_in = x_out.mean(axis: 3, keepdims: true)
  x_in = (x_in / 127.5) - 1
  x_out = (x_out / 127.5) - 1
  [x_in, x_out]
end

batch_size = 100

dcgan = DCGAN.load("trained/dcgan_model_epoch20.marshal")
gen = dcgan.gen

x_in, x_out = load_dataset
images = gen.predict(x_in[0...batch_size, false])

batch_size.times do |i|
  img = Numo::UInt8.cast(((images[i, false] + 1) * 127.5).round)
  DNN::Image.write("img/img_#{i}.jpg", img)
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
ruby-dnn-1.3.0 examples/pix2pix/imgen.rb
ruby-dnn-1.2.3 examples/pix2pix/imgen.rb
ruby-dnn-1.2.2 examples/pix2pix/imgen.rb
ruby-dnn-1.2.1 examples/pix2pix/imgen.rb
ruby-dnn-1.2.0 examples/pix2pix/imgen.rb
ruby-dnn-1.1.6 examples/pix2pix/imgen.rb
ruby-dnn-1.1.5 examples/pix2pix/imgen.rb
ruby-dnn-1.1.4 examples/pix2pix/imgen.rb
ruby-dnn-1.1.3 examples/pix2pix/imgen.rb
ruby-dnn-1.1.2 examples/pix2pix/imgen.rb
ruby-dnn-1.1.1 examples/pix2pix/imgen.rb
ruby-dnn-1.1.0 examples/pix2pix/imgen.rb
ruby-dnn-1.0.0 examples/pix2pix/imgen.rb
ruby-dnn-0.16.2 examples/pix2pix/imgen.rb
ruby-dnn-0.16.1 examples/pix2pix/imgen.rb
ruby-dnn-0.16.0 examples/pix2pix/imgen.rb