Sha256: 023d64930e3c26cfabdbedc1556351846fc5063bcedc84ff2e6c2edbab88046e

Contents?: true

Size: 474 Bytes

Versions: 5

Compression:

Stored size: 474 Bytes

Contents

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

Image = DNN::Image

batch_size = 100

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

Numo::SFloat.srand(rand(1 << 31))
noise = Numo::SFloat.new(batch_size, 20).rand(-1, 1)
images = gen.predict(noise)

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ruby-dnn-0.13.4 examples/dcgan/imgen.rb
ruby-dnn-0.13.3 examples/dcgan/imgen.rb
ruby-dnn-0.13.2 examples/dcgan/imgen.rb
ruby-dnn-0.13.1 examples/dcgan/imgen.rb
ruby-dnn-0.13.0 examples/dcgan/imgen.rb