Justin-Tan / generative-compression

TensorFlow Implementation of Generative Adversarial Networks for Extreme Learned Image Compression
MIT License
511 stars 108 forks source link

compress single image with error #16

Open zhiqiang-zhu opened 6 years ago

zhiqiang-zhu commented 6 years ago

Traceback (most recent call last): File "compress.py", line 80, in main() File "compress.py", line 77, in main single_compress(config_test, args) File "compress.py", line 60, in single_compress Utils.single_plot(0, 0, sess, gan, handle, save_path, config, single_compress=True) File "/home/zqzhu/EX/GAN_CC/generative-compression-master/utils.py", line 107, in single_plot r, g = sess.run([real, gen], feed_dict={model.training_phase:True, model.handle: handle}) File "/home/zqzhu/tensorflow3/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 900, in run run_metadata_ptr) File "/home/zqzhu/tensorflow3/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1135, in _run feed_dict_tensor, options, run_metadata) File "/home/zqzhu/tensorflow3/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1316, in _do_run run_metadata) File "/home/zqzhu/tensorflow3/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1335, in _do_call raise type(e)(node_def, op, message) tensorflow.python.framework.errors_impl.InvalidArgumentError: Expected image (JPEG, PNG, or GIF), got unknown format starting with 'BM\212\000\014\000\000\000\000\000\212\000\000\000|\000' [[Node: DecodePng = DecodePngchannels=3, dtype=DT_UINT8]] [[Node: IteratorGetNext = IteratorGetNextoutput_shapes=[[?,?,?,3]], output_types=[DT_FLOAT], _device="/job:localhost/replica:0/task:0/device:CPU:0"]] [[Node: generator/decoder/conv2d_transpose_3/conv2d_transpose-0-VecPermuteNHWCToNCHW-LayoutOptimizer/_395 = _HostRecv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device_incarnation=1, tensor_name="edge1470...tOptimizer", tensor_type=DT_INT32, _device="/job:localhost/replica:0/task:0/device:GPU:0"]()]]

The compressed image format is bmp, and then occurre an error.

Justin-Tan commented 6 years ago

You should have the input image as a JPEG or PNG instead of BMP or GIF.

zhiqiang-zhu commented 6 years ago

thank you for your reply, but there is an error when I train the model on ADE20k dataset: Traceback (most recent call last): File "train.py", line 128, in main() File "train.py", line 125, in main train(config_train, args) File "train.py", line 35, in train gan = Model(config, paths, name=args.name, dataset=args.dataset) File "/home/zqzhu/EX/GAN_CC/generative-compression-master/model.py", line 78, in init self.z = tf.concat([self.w_hat, Gv], axis=-1, name="ZZQ") File "/home/zqzhu/tensorflow3/lib/python3.5/site-packages/tensorflow/python/ops/array_ops.py", line 1189, in concat return gen_array_ops.concat_v2(values=values, axis=axis, name=name) File "/home/zqzhu/tensorflow3/lib/python3.5/site-packages/tensorflow/python/ops/gen_array_ops.py", line 953, in concat_v2 "ConcatV2", values=values, axis=axis, name=name) File "/home/zqzhu/tensorflow3/lib/python3.5/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper op_def=op_def) File "/home/zqzhu/tensorflow3/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 3392, in create_op op_def=op_def) File "/home/zqzhu/tensorflow3/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 1734, in init control_input_ops) File "/home/zqzhu/tensorflow3/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 1570, in _create_c_op raise ValueError(str(e)) ValueError: Dimension 2 in both shapes must be equal, but are 32 and 64. Shapes are [?,?,32] and [?,32,64]. for 'generator/ZZQ' (op: 'ConcatV2') with input shapes: [?,?,32,8], [?,32,64,8], [] and with computed input tensors: input[2] = <-1>.

I have change the input image's width to 512px, I checked the code, the shape of w_hat and Gv is not same when sampling noise in model.py, can you give me some advices? Thanks!

lzhzju commented 1 year ago

thank you for your reply, but there is an error when I train the model on ADE20k dataset: Traceback (most recent call last): File "train.py", line 128, in main() File "train.py", line 125, in main train(config_train, args) File "train.py", line 35, in train gan = Model(config, paths, name=args.name, dataset=args.dataset) File "/home/zqzhu/EX/GAN_CC/generative-compression-master/model.py", line 78, in init self.z = tf.concat([self.w_hat, Gv], axis=-1, name="ZZQ") File "/home/zqzhu/tensorflow3/lib/python3.5/site-packages/tensorflow/python/ops/array_ops.py", line 1189, in concat return gen_array_ops.concat_v2(values=values, axis=axis, name=name) File "/home/zqzhu/tensorflow3/lib/python3.5/site-packages/tensorflow/python/ops/gen_array_ops.py", line 953, in concat_v2 "ConcatV2", values=values, axis=axis, name=name) File "/home/zqzhu/tensorflow3/lib/python3.5/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper op_def=op_def) File "/home/zqzhu/tensorflow3/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 3392, in create_op op_def=op_def) File "/home/zqzhu/tensorflow3/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 1734, in init control_input_ops) File "/home/zqzhu/tensorflow3/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 1570, in _create_c_op raise ValueError(str(e)) ValueError: Dimension 2 in both shapes must be equal, but are 32 and 64. Shapes are [?,?,32] and [?,32,64]. for 'generator/ZZQ' (op: 'ConcatV2') with input shapes: [?,?,32,8], [?,32,64,8], [] and with computed input tensors: input[2] = <-1>.

I have change the input image's width to 512px, I checked the code, the shape of w_hat and Gv is not same when sampling noise in model.py, can you give me some advices? Thanks!

I have the same problem, have you solved it?