Coder Social home page Coder Social logo

fast-neural-style-tensorflow's People

Contributors

hzy46 avatar lanko-x avatar

Stargazers

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

Watchers

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

fast-neural-style-tensorflow's Issues

hello,is there any bias_value in Conv Layer? I just see the "weight" value

def conv2d(x, input_filters, output_filters, kernel, strides, mode='REFLECT'):
with tf.variable_scope('conv',reuse=False):

    shape = [kernel, kernel, input_filters, output_filters]
    weight = tf.get_variable(name = 'weight',shape=shape,dtype = tf.float32, 
                             initializer=tf.truncated_normal_initializer(stddev=0.1),trainable=True)
    x_padded = tf.pad(x, [[0, 0], [kernel / 2, kernel / 2], [kernel / 2, kernel / 2], [0, 0]], mode=mode)
    return tf.nn.conv2d(x_padded, weight, strides=[1, strides, strides, 1], padding='VALID', name='conv')

ERROR:The tensor returned for EncodeJpeg:0 was not valid.

Traceback (most recent call last):
File "eval.py", line 76, in
tf.app.run()
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/app.py", line 48, in run
_sys.exit(main(_sys.argv[:1] + flags_passthrough))
File "eval.py", line 67, in main
img.write(sess.run(tf.image.encode_jpeg(generated)))
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 778, in run
run_metadata_ptr)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 982, in _run
feed_dict_string, options, run_metadata)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 1032, in _do_run
target_list, options, run_metadata)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 1052, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: The tensor returned for EncodeJpeg:0 was not valid.

train.py的训练结果无法直接应用到eval.py中

谢谢分享的项目!
使用train.py训练后能在对应路径下看到检查点及最终的训练数据如附图。
训练方法按照说明中一样进行 vgg16已放入对应文件夹 train2014在同一主目录下 基于wave.yml修改名称和对应图片路径得到新的配置文件
但是其中的fast-style-model.ckpt-done.data-00000-of-00001无法被eval.py读取。
报错如下:
--------------------------------
DataLossError (see above for traceback): Unable to open table file /home/tensorflow/neural_style/fast-neural-style-tensorflow-master/trained_model/sketch.ckpt-done: Data loss: not an sstable (bad magic number): perhaps your file is in a different file format and you need to use a different restore operator?
--------------------------------
看了看代码似乎新的模型导入只要使用默认结构就不用特别声明吧?还是train.py的输出还需处理才能直接使用?又或者是我训练步骤有问题?
train_result

Why do we need the COCO dataset?

I'm new to VGG, so I'm a little confused about this:

To train a model from scratch, you should first download VGG16 model from Tensorflow Slim. Extract the file vgg_16.ckpt.
Then download the COCO dataset. Please unzip it, and you will have a folder named "train2014" with many raw images in it. Then create a symbol link to it:
Train the model of "wave"

While you've downloaded the vgg_16.ckpt, so u can use it to gennerate the style gram with the style_picture???So why do we need the COCO dataset and what is vgg doing here _, endpoints_dict = network_fn(tf.concat([processed_generated, processed_images], 0), spatial_squeeze=False)

Thx

运行报错误

File "eval.py", line 76, in
tf.app.run()
File "/Library/Python/2.7/site-packages/tensorflow/python/platform/app.py", line 48, in run
_sys.exit(main(_sys.argv[:1] + flags_passthrough))
File "eval.py", line 24, in main
with open(FLAGS.image_file, 'rb') as img:
IOError: [Errno 2] No such file or directory: 'a.jpg'
第一次运行报这个错误,我添加了一张图片,但是又报

DataLossError (see above for traceback): Unable to open table file /Users/taowei/Documents/python_wrokspace/fast-neural-style-tensorflow-master1/img/wave.jpg: Data loss: not an sstable (bad magic number): perhaps your file is in a different file format and you need to use a different restore operator?
[[Node: save/RestoreV2_4 = RestoreV2[dtypes=[DT_FLOAT], _device="/job:localhost/replica:0/task:0/cpu:0"](_arg_save/Const_0_0, save/RestoreV2_4/tensor_names, save/RestoreV2_4/shape_and_slices)]]
这个错误
请问是什么原因?
有联系方式吗? 我想问你一些关于tensorflow 的内容。 [email protected]

IndexError: list index out of range

Traceback (most recent call last):
File "train.py", line 146, in
main(FLAGS)
File "train.py", line 44, in main
'train2014/', image_preprocessing_fn, epochs=FLAGS.epoch)
File "/root/fast-neural-style-tensorflow/reader.py", line 18, in image
png = filenames[0].lower().endswith('png') # If first file is a png, assume they all are
IndexError: list index out of range

Thanks!

是否开启了gpu功能和多cpu功能

你好,不知道你这个项目有没有开启多cpu多线程以及gpu功能?如果有,默认的数值分别是多少?还有要如何进行自定义设置?非常感谢。

Error after model quantisation

Describe the problem
I am using the pre-trained style transfer models from Baidu Drive. I have converted them to .pb format using the export() function. When I inference a single image through these fp32 models then I can see the styled image at the output of the network and everything works fine. Later on I optimize the model for inference using transform_graph tool with these parameters :

--transforms='
  add_default_attributes
  strip_unused_nodes(type=float)
  remove_nodes(op=CheckNumerics)
  fold_constants(ignore_errors=true)
  fold_batch_norms
  fold_old_batch_norms
  quantize_weights
  quantize_nodes
  strip_unused_nodes
  sort_by_execution_order'

the quantised models (.pb) generated successfully but now I have problem with inference when I execute sess.run().

Error Output :

Traceback (most recent call last):
  File "Inf_Image_pb.py", line 89, in <module>
    Session_out = sess.run(l_output, feed_dict={l_input: image})            
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 889, in run
    run_metadata_ptr)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 1120, in _run
    feed_dict_tensor, options, run_metadata)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 1317, in _do_run
    options, run_metadata)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 1336, in _do_call
    raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Shapes of all inputs must match: values[0].shape = [474,712,3] != values[2].shape = []
	 [[Node: Reshape/shape = Pack[N=3, T=DT_INT32, axis=0, _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_input_image_0_0, _arg_input_image_0_0, Reshape/shape/2)]]

Caused by op u'Reshape/shape', defined at:
  File "Inf_Image_pb.py", line 74, in <module>
    producer_op_list=None
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/importer.py", line 313, in import_graph_def
    op_def=op_def)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 2956, in create_op
    op_def=op_def)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 1470, in __init__
    self._traceback = self._graph._extract_stack()  # pylint: disable=protected-access

InvalidArgumentError (see above for traceback): Shapes of all inputs must match: values[0].shape = [474,712,3] != values[2].shape = []
	 [[Node: Reshape/shape = Pack[N=3, T=DT_INT32, axis=0, _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_input_image_0_0, _arg_input_image_0_0, Reshape/shape/2)]]

Is this a model problem or a transform graph problem ?? What is this error refers to ? I can't find any useful information online ..

一个网络复用的问题

我想要在这个代码里实现preserving style的论文。
问下我如果需要share vgg网络的话,需要怎么做呢。我尝试果使用scope.reuse方式,但是似乎有问题。我在loss.py里修改get_style_features_flow函数如下,并在vgg.py中添加了reuse选项:

def get_style_features_flow(sess, FLAGS, images_placeholder, network_fn):
    network_fn = nets_factory.get_network_fn(
        FLAGS.loss_model,
        num_classes=1,
        is_training=False)
    sizex = conf.height
    sizey = conf.width
    img_bytes = tf.read_file(FLAGS.style_image)
    if FLAGS.style_image.lower().endswith('png'):
        c_style_image = tf.image.decode_png(img_bytes)
    else:
        c_style_image = tf.image.decode_jpeg(img_bytes)
        # image = _aspect_preserving_resize(image, size)
    prev_image = images_placeholder[0, :,:,:]
    curr_image = images_placeholder[1, :,:,:]
    style_image = tf.image.rgb_to_hsv(tf.to_float(c_style_image))

    image_preprocessing_fn, image_unprocessing_fn = preprocessing_factory.get_preprocessing(
        FLAGS.loss_model,
        is_training=False)
    def getFeatures(image):
        image1 = tf.image.rgb_to_hsv(tf.to_float(image))
        image2 = tf.stack([image1[:,:,0], image1[:,:,1], style_image[:, :, 2]], axis=-1)
        s_image = tf.image.hsv_to_rgb(image2)
        images = tf.stack([image_preprocessing_fn(s_image, sizex, sizey)])
        # scope.reuse_variables()
        _, endpoints_dict = network_fn(images, spatial_squeeze=False, REUSE=True)
        features = []
        for layer in FLAGS.style_layers:
            print("layer:", layer)
            feature = endpoints_dict[layer]
            tf.logging.info(tf.shape(feature))
            feature = tf.squeeze(gram(feature), [0])  # remove the batch dimension
            # feature = gram(feature)
            features.append(feature)
        return features
    return getFeatures(prev_image), getFeatures(curr_image)

tensorflow运行时报错:

  File "hsv_train.py", line 252, in <module>
    train(FLAGS)
  File "hsv_train.py", line 230, in train
    _, loss_t, step = sess.run([train_op, loss, global_step], feed_dict=feed_dict)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 789, in run
    run_metadata_ptr)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 997, in _run
    feed_dict_string, options, run_metadata)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 1132, in _do_run
    target_list, options, run_metadata)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 1152, in _do_call
    raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Tried to explicitly squeeze dimension 0 but dimension was not 1: 4
	 [[Node: Squeeze_11 = Squeeze[T=DT_FLOAT, squeeze_dims=[0], _device="/job:localhost/replica:0/task:0/cpu:0"](div_5)]]

Caused by op u'Squeeze_11', defined at:
  File "hsv_train.py", line 252, in <module>
    train(FLAGS)
  File "hsv_train.py", line 126, in train
    style_features_prev, style_features_curr = losses.get_style_features_flow(sess, FLAGS, images_placeholder, network_fn)
  File "/home/zhangyule/fast-neural-style-flow-tensorflow/fast-neural-style-tensorflow/hsv_losses.py", line 131, in get_style_features_flow
    return getFeatures(prev_image), getFeatures(curr_image)
  File "/home/zhangyule/fast-neural-style-flow-tensorflow/fast-neural-style-tensorflow/hsv_losses.py", line 127, in getFeatures
    feature = tf.squeeze(gram(feature), [0])  # remove the batch dimension
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/array_ops.py", line 2281, in squeeze
    return gen_array_ops._squeeze(input, axis, name)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gen_array_ops.py", line 3329, in _squeeze
    squeeze_dims=squeeze_dims, name=name)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/op_def_library.py", line 767, in apply_op
    op_def=op_def)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 2506, in create_op
    original_op=self._default_original_op, op_def=op_def)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 1269, in __init__
    self._traceback = _extract_stack()

InvalidArgumentError (see above for traceback): Tried to explicitly squeeze dimension 0 but dimension was not 1: 4
	 [[Node: Squeeze_11 = Squeeze[T=DT_FLOAT, squeeze_dims=[0], _device="/job:localhost/replica:0/task:0/cpu:0"](div_5)]]

possible to train own images?

hi,I want to train my own datas, not coco images ,I have got only one image set,their style are all the same,
Assume the style is A. Is it possible to put one content image to transfer it to A style

利用已训练好的模型生成图片出错

执行代码后如下所示
lstreasure@lstreasure-OptiPlex-7040:~/下载/hzy46/fast-neural-style-tensorflow-master$ python eval.py --model_file models/wave.ckpt-done --image_file img/test.jpg
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE3 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
INFO:tensorflow:Image size: 712x474
Traceback (most recent call last):
File "eval.py", line 62, in
tf.app.run()
File "/home/lstreasure/.local/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 44, in run
_sys.exit(main(_sys.argv[:1] + flags_passthrough))
File "eval.py", line 38, in main
image = reader.get_image(FLAGS.image_file, height, width, image_preprocessing_fn)
File "/home/lstreasure/下载/hzy46/fast-neural-style-tensorflow-master/reader.py", line 10, in get_image
return preprocess_fn(image, height, width)
File "/home/lstreasure/下载/hzy46/fast-neural-style-tensorflow-master/preprocessing/preprocessing_factory.py", line 70, in preprocessing_fn
image, output_height, output_width, is_training=is_training, **kwargs)
File "/home/lstreasure/下载/hzy46/fast-neural-style-tensorflow-master/preprocessing/vgg_preprocessing.py", line 388, in preprocess_image
resize_side_min)
File "/home/lstreasure/下载/hzy46/fast-neural-style-tensorflow-master/preprocessing/vgg_preprocessing.py", line 353, in preprocess_for_eval
image = _central_crop([image], output_height, output_width)[0]
File "/home/lstreasure/下载/hzy46/fast-neural-style-tensorflow-master/preprocessing/vgg_preprocessing.py", line 200, in _central_crop
crop_height, crop_width))
File "/home/lstreasure/下载/hzy46/fast-neural-style-tensorflow-master/preprocessing/vgg_preprocessing.py", line 76, in _crop
tf.pack([crop_height, crop_width, original_shape[2]]))
AttributeError: 'module' object has no attribute 'pack'
请问什么原因,怎么解决,万分感谢帮忙的伙伴!

运行train.py报错ResourceExhaustedError

cmd里训练命令为
python train.py -c conf\scream.yml
提示

Traceback (most recent call last):
File "train.py", line 146, in
main(FLAGS)
File "train.py", line 118, in main
_, loss_t, step = sess.run([train_op, loss, global_step])
File "D:\Anaconda\lib\site-packages\tensorflow\python\client\session.py", line 905, in run
run_metadata_ptr)
File "D:\Anaconda\lib\site-packages\tensorflow\python\client\session.py", line 1140, in _run
feed_dict_tensor, options, run_metadata)
File "D:\Anaconda\lib\site-packages\tensorflow\python\client\session.py", line 1321, in _do_run
run_metadata)
File "D:\Anaconda\lib\site-packages\tensorflow\python\client\session.py", line 1340, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.ResourceExhaustedError: OOM when allocating tensor with shape[4,128,278,278] and type float on /job:localhost/replica:0/task:0/device:GPU:0 by allocator GPU_0_bfc
[[Node: deconv1/conv_transpose/conv/conv-0-TransposeNHWCToNCHW-LayoutOptimizer = Transpose[T=DT_FLOAT, Tperm=DT_INT32, _device="/job:localhost/replica:0/task:0/device:GPU:0"](deconv1/conv_transpose/conv/MirrorPad, PermConstNHWCToNCHW-LayoutOptimizer)]]
Hint: If you want to see a list of allocated tensors when OOM happens, add report_tensor_allocations_upon_oom to RunOptions for current allocation info.

使用的是tensorflow-gpu.显卡是GTX-960M.我觉得没有理由跑不起来...(batch size已经4了)
请问是什么原因导致这种情况发生,我能如何修改让它运行?

ResourceExhaustedError

百度图片上随便下载一个图片,进行测试,报错如下
ResourceExhaustedError (see above for traceback): OOM when allocating tensor with shape[1,64,1578,2090]
[[Node: deconv2/conv_transpose/conv/conv = Conv2D[T=DT_FLOAT, data_format="NHWC", padding="VALID", strides=[1, 2, 2, 1], use_cudnn_on_gpu=true, _device="/job:localhost/replica:0/task:0/gpu:0"](deconv2/conv_transpose/conv/MirrorPad, deconv2/conv_transpose/conv/weight/read)]]

python3.6下train模型出现错误

python3.6,tensorflow1.3环境下运行出现
INFO:tensorflow:Scale of 0 disables regularizer.
2017-11-02 17:15:01.143690: W C:\tf_jenkins\home\workspace\rel-win\M\windows\PY\36\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
INFO:tensorflow:Use pretrained model pretrained/vgg_16.ckpt
INFO:tensorflow:Restoring parameters from pretrained/vgg_16.ckpt
INFO:tensorflow:Target style pattern is saved to: generated/target_style_mosaic.jpg.
INFO:tensorflow:Scale of 0 disables regularizer.
Traceback (most recent call last):
File "E:/web/image_style/fast-neural-style-tensorflow-master/train.py", line 146, in
main(FLAGS)
File "E:/web/image_style/fast-neural-style-tensorflow-master/train.py", line 45, in main
generated = model.net(processed_images, training=True)
File "E:\web\image_style\fast-neural-style-tensorflow-master\model.py", line 104, in net
conv1 = tf.nn.relu(instance_norm(conv2d(image, 3, 32, 9, 1)))
File "E:\web\image_style\fast-neural-style-tensorflow-master\model.py", line 9, in conv2d
x_padded = tf.pad(x, [[0, 0], [kernel / 2, kernel / 2], [kernel / 2, kernel / 2], [0, 0]], mode=mode)
File "D:\Anaconda3\lib\site-packages\tensorflow\python\ops\array_ops.py", line 1684, in pad
name=name)
File "D:\Anaconda3\lib\site-packages\tensorflow\python\ops\gen_array_ops.py", line 1738, in _mirror_pad
mode=mode, name=name)
File "D:\Anaconda3\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 589, in apply_op
param_name=input_name)
File "D:\Anaconda3\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 60, in _SatisfiesTypeConstraint
", ".join(dtypes.as_dtype(x).name for x in allowed_list)))
TypeError: Value passed to parameter 'paddings' has DataType float32 not in list of allowed values: int32, int64
这个错误提示?是因为不支持python3的原因吗?

为什么要使用COCO数据集呢?

不是太懂得为什么要使用COCO数据集。学习风格不是只需要一张图片么?为什么要用到COCO中种类繁多的图片?
萌新的问题,请多担待

tensorflow貌似在python 2.7环境下无法下载

用virtualenv装了python 2.7之后tensorflow就没法下了
我用的是
pip install tensorflow

Could not find a version that satisfies the requirement tensorflow (from versions: )
No matching distribution found for tensorflow

How to set the parameters in *.yml when training a new model

`## Basic configuration
style_image: img/snow.jpg # targeted style image
naming: "snow" # the name of this model. Determine the path to save checkpoint and events file.
model_path: models # root path to save checkpoint and events file. The final path would be <model_path>/

Weight of the loss

content_weight: 1.0 # weight for content features loss
style_weight: 200.0 # weight for style features loss
tv_weight: 0.0 # weight for total variation loss

The size, the iter number to run

image_size: 256
batch_size: 4
epoch: 2`

Hi, this is a yml file I want to set for training, I noticed the parameter of style_weight is different in those .yml file you proposed while others are the same. Any suggestions for parameter setting? Thanks a lot

使用训练好的模型出错

我使用的版本是 Python3.5 (Python2.7 似乎并不能支持 Tensorflow1.0啊) Tensorflow 1.0 ,在运行时报错
TypeError: Value passed to parameter 'paddings' has DataType float32 not in list of allowed values: int32, int64 。不知道有没有遇到同样问题的朋友,谢谢啦~

tensorflow 1.0版本无法运行

应该是API变动的原因吧,导致无法运行
尝试调整,但是一直无法成功
我是初学者,想将这个项目作为入门学习的项目,实在是不会修改
作者可否帮忙将代码更新成支持1.0版本

new model dont work

I can not train the model, the pictures are processed normally, but I'm trying to train a new model. Creates a folder in the wave folder in the models folder, and the file itself is not scrpt-done.

3.5 gigabytes of azure vps cpu

COCO dataset 的作用

你好,我刚接触这个方面,看了这篇论文,大概清楚流程,还是有一些地方不太清楚。
已经有了pretrained vgg16的网络参数,想请问一下COCO dataset 在training 时的作用是什么? 训练的是哪些参数?
感觉想法还是在 那篇 原始的风格迁移。
可以麻烦你简单的解答一下么,非常感谢。

请教一下各位大佬穷人用GTX950怎么跑

如题
终端的资讯
INFO:tensorflow:vgg_16/fc8
INFO:tensorflow:Use pretrained model pretrained/vgg_16.ckpt
INFO:tensorflow:Restoring parameters from pretrained/vgg_16.ckpt
2018-06-20 05:08:37.059562: W tensorflow/core/common_runtime/bfc_allocator.cc:219] Allocator (GPU_0_bfc) ran out of memory trying to allocate 2.09GiB. The caller indicates that this is not a failure, but may mean that there could be performance gains if more memory were available.

显存不够用怎么办...萌新表示头痛

Train a new model? checkpoint format depreched

On training a model, there is wvery 1000 steps a
Warning:
"Tensorsflow V1 checkpoint format has been depreched:
Consoder switching to the more efficient V2 format
....
"

Is this ok? Or need I to edit the source code?

训练一个模型需要多少时间呢

代码在我的python3.6上直接就可以运行了
有几个问题想请教一下:
按照原来yml里面的配置,训练一个模型需要迭代多少个批次?
loss大概下降到多少?
style_weight是凭感觉设置的吗?

A problem about testing

你好,作者。我在运行你已经训练好的模型时间遇到了一个问题。
我直接把模型down下来 运行
$ python eval.py --model_file models/wave/fast-style-model.ckpt-done --image_file img/test.jpg
程序提升找不到weight这是为什么?

Missing Model Files

Link for model files won't work. Could share them in a different location ?

I've got an error message "Invalid JPEG data, size 53248".

I don't know how it happened. It goes well in first hundreds of iterations. Maybe there's some problems with my mscoco dataset? And I'm trying to print the name of the image with problem.

Here's the error message.

Traceback (most recent call last):
File "/home/gongxinyu/Deeplearning/CNN/source_code/fast-neural-style-tensorflow_gxy/train.py", line 158, in
main(FLAGS)
File "/home/gongxinyu/Deeplearning/CNN/source_code/fast-neural-style-tensorflow_gxy/train.py", line 151, in main
coord.join(threads)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/coordinator.py", line 389, in join
six.reraise(*self._exc_info_to_raise)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/queue_runner_impl.py", line 238, in _run
enqueue_callable()
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 1175, in _single_operation_run
target_list_as_strings, status, None)
File "/usr/lib/python2.7/contextlib.py", line 24, in exit
self.gen.next()
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/errors_impl.py", line 466, in raise_exception_on_not_ok_status
pywrap_tensorflow.TF_GetCode(status))
tensorflow.python.framework.errors_impl.InvalidArgumentError: Invalid JPEG data, size 53248
[[Node: DecodeJpeg = DecodeJpegacceptable_fraction=1, channels=3, dct_method="", fancy_upscaling=true, ratio=1, try_recover_truncated=false, _device="/job:localhost/replica:0/task:0/cpu:0"]]
[[Node: ResizeBilinear/_91 = _Recvclient_terminated=false, recv_device="/job:localhost/replica:0/task:0/gpu:0", send_device="/job:localhost/replica:0/task:0/cpu:0", send_device_incarnation=1, tensor_name="edge_53_ResizeBilinear", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/gpu:0"]]

tensorflow 1.0RC

使用tensorflow 1.0rc遇到两个问题,经过简单修改已经可以正常运行

eval.py

报错:
File "eval.py", line 29, in main
image = sess.run(tf.image.decode_jpeg(img.read()))
AttributeError: 'weakref' object has no attribute 'run'

修改 : tf.Session().as_default() 改为 tf.Session()

运行python eval.py --model_file model/wave.ckpt-done --image_file img/test.jpg报错!问题如下:

Traceback (most recent call last):
File "/home/thomas/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1039, in _do_call
return fn(*args)
File "/home/thomas/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1021, in _run_fn
status, run_metadata)
File "/home/thomas/anaconda3/lib/python3.6/contextlib.py", line 88, in exit
next(self.gen)
File "/home/thomas/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/errors_impl.py", line 466, in raise_exception_on_not_ok_status
pywrap_tensorflow.TF_GetCode(status))
tensorflow.python.framework.errors_impl.InvalidArgumentError: Unsuccessful TensorSliceReader constructor: Failed to get matching files on /home/thomas/PycharmProjects/fast-neural-style-tensorflow/model/wave.ckpt-done: Not found: /home/thomas/PycharmProjects/fast-neural-style-tensorflow/model
[[Node: save/RestoreV2_5 = RestoreV2[dtypes=[DT_FLOAT], _device="/job:localhost/replica:0/task:0/cpu:0"](_recv_save/Const_0, save/RestoreV2_5/tensor_names, save/RestoreV2_5/shape_and_slices)]]
[[Node: save/RestoreV2_15/_7 = _Recvclient_terminated=false, recv_device="/job:localhost/replica:0/task:0/gpu:0", send_device="/job:localhost/replica:0/task:0/cpu:0", send_device_incarnation=1, tensor_name="edge_56_save/RestoreV2_15", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/gpu:0"]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "eval.py", line 77, in
tf.app.run()
File "/home/thomas/anaconda3/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 48, in run
_sys.exit(main(_sys.argv[:1] + flags_passthrough))
File "eval.py", line 58, in main
saver.restore(sess, FLAGS.model_file)
File "/home/thomas/anaconda3/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 1457, in restore
{self.saver_def.filename_tensor_name: save_path})
File "/home/thomas/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 778, in run
run_metadata_ptr)
File "/home/thomas/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 982, in _run
feed_dict_string, options, run_metadata)
File "/home/thomas/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1032, in _do_run
target_list, options, run_metadata)
File "/home/thomas/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1052, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Unsuccessful TensorSliceReader constructor: Failed to get matching files on /home/thomas/PycharmProjects/fast-neural-style-tensorflow/model/wave.ckpt-done: Not found: /home/thomas/PycharmProjects/fast-neural-style-tensorflow/model
[[Node: save/RestoreV2_5 = RestoreV2[dtypes=[DT_FLOAT], _device="/job:localhost/replica:0/task:0/cpu:0"](_recv_save/Const_0, save/RestoreV2_5/tensor_names, save/RestoreV2_5/shape_and_slices)]]
[[Node: save/RestoreV2_15/_7 = _Recvclient_terminated=false, recv_device="/job:localhost/replica:0/task:0/gpu:0", send_device="/job:localhost/replica:0/task:0/cpu:0", send_device_incarnation=1, tensor_name="edge_56_save/RestoreV2_15", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/gpu:0"]]

Caused by op 'save/RestoreV2_5', defined at:
File "eval.py", line 77, in
tf.app.run()
File "/home/thomas/anaconda3/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 48, in run
_sys.exit(main(_sys.argv[:1] + flags_passthrough))
File "eval.py", line 54, in main
saver = tf.train.Saver(tf.global_variables(), write_version=tf.train.SaverDef.V1)
File "/home/thomas/anaconda3/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 1056, in init
self.build()
File "/home/thomas/anaconda3/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 1086, in build
restore_sequentially=self._restore_sequentially)
File "/home/thomas/anaconda3/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 691, in build
restore_sequentially, reshape)
File "/home/thomas/anaconda3/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 407, in _AddRestoreOps
tensors = self.restore_op(filename_tensor, saveable, preferred_shard)
File "/home/thomas/anaconda3/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 247, in restore_op
[spec.tensor.dtype])[0])
File "/home/thomas/anaconda3/lib/python3.6/site-packages/tensorflow/python/ops/gen_io_ops.py", line 669, in restore_v2
dtypes=dtypes, name=name)
File "/home/thomas/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 768, in apply_op
op_def=op_def)
File "/home/thomas/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 2336, in create_op
original_op=self._default_original_op, op_def=op_def)
File "/home/thomas/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1228, in init
self._traceback = _extract_stack()

InvalidArgumentError (see above for traceback): Unsuccessful TensorSliceReader constructor: Failed to get matching files on /home/thomas/PycharmProjects/fast-neural-style-tensorflow/model/wave.ckpt-done: Not found: /home/thomas/PycharmProjects/fast-neural-style-tensorflow/model
谢谢呀!亲

关于vgg模型的迁移应用

看过论文之后好像是说把训练好的模型拿来用是不是应该要把vgg中的模型里的参数都改为转变为常量呢?我感觉代码中似乎没有这个静态化的过程?不知道是我论文理解错了还是代码没有看懂的,能指导解答一下吗?

执行出错

python eval.py --model_file </Users/DOVAN/Downloads/mosaic.ckpt-done> --image_file /Users/DOVAN/Desktop/photo.jpg

Traceback (most recent call last):
File "eval.py", line 62, in
tf.app.run()
File "/Users/DOVAN/anaconda2/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 44, in run
_sys.exit(main(_sys.argv[:1] + flags_passthrough))
File "eval.py", line 38, in main
image = reader.get_image(FLAGS.image_file, height, width, image_preprocessing_fn)
File "/Users/DOVAN/deeprely/fast-neural-style-tensorflow/reader.py", line 10, in get_image
return preprocess_fn(image, height, width)
File "/Users/DOVAN/deeprely/fast-neural-style-tensorflow/preprocessing/preprocessing_factory.py", line 70, in preprocessing_fn
image, output_height, output_width, is_training=is_training, **kwargs)
File "/Users/DOVAN/deeprely/fast-neural-style-tensorflow/preprocessing/vgg_preprocessing.py", line 388, in preprocess_image
resize_side_min)
File "/Users/DOVAN/deeprely/fast-neural-style-tensorflow/preprocessing/vgg_preprocessing.py", line 353, in preprocess_for_eval
image = _central_crop([image], output_height, output_width)[0]
File "/Users/DOVAN/deeprely/fast-neural-style-tensorflow/preprocessing/vgg_preprocessing.py", line 200, in _central_crop
crop_height, crop_width))
File "/Users/DOVAN/deeprely/fast-neural-style-tensorflow/preprocessing/vgg_preprocessing.py", line 76, in _crop
tf.pack([crop_height, crop_width, original_shape[2]]))
AttributeError: 'module' object has no attribute 'pack'

这个是什么原因?
当我尝试卸载之前版本的tensorflow后,安装TF-slim后,又报错了

DOVANtekiMacBook-Pro:fast-neural-style-tensorflow DOVAN$ sudo pip install --upgrade $TF_BINARY_URL
Password:
The directory '/Users/DOVAN/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/DOVAN/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
tensorflow-0.10.0rc0-cp27-none-linux_x86_64.whl is not a supported wheel on this platform.

请问是什么原因,该怎么解决~

python eval.py --model_file model/wave.ckpt-done --image_file img/4.jpg执行报错

您好!我执行时报如下错误,这是什么原因导致的呢?求教
Traceback (most recent call last):
File "eval.py", line 62, in
tf.app.run()
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/app.py", line 44, in run
_sys.exit(main(_sys.argv[:1] + flags_passthrough))
File "eval.py", line 38, in main
image = reader.get_image(FLAGS.image_file, height, width, image_preprocessing_fn)
File "/home/minist/deep_learning/style transfer code/hzy46 fast-neural-style-tensorflow/fast-neural-style-tensorflow-master/reader.py", line 10, in get_image
return preprocess_fn(image, height, width)
File "/home/minist/deep_learning/style transfer code/hzy46 fast-neural-style-tensorflow/fast-neural-style-tensorflow-master/preprocessing/preprocessing_factory.py", line 70, in preprocessing_fn
image, output_height, output_width, is_training=is_training, **kwargs)
File "/home/minist/deep_learning/style transfer code/hzy46 fast-neural-style-tensorflow/fast-neural-style-tensorflow-master/preprocessing/vgg_preprocessing.py", line 388, in preprocess_image
resize_side_min)
File "/home/minist/deep_learning/style transfer code/hzy46 fast-neural-style-tensorflow/fast-neural-style-tensorflow-master/preprocessing/vgg_preprocessing.py", line 357, in preprocess_for_eval
return _mean_image_subtraction(image, [_R_MEAN, _G_MEAN, _B_MEAN])
File "/home/minist/deep_learning/style transfer code/hzy46 fast-neural-style-tensorflow/fast-neural-style-tensorflow-master/preprocessing/vgg_preprocessing.py", line 231, in _mean_image_subtraction
channels = tf.split(2, num_channels, image)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/array_ops.py", line 1319, in split
split_dim=axis, num_split=num_or_size_splits, value=value, name=name)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gen_array_ops.py", line 3385, in _split
num_split=num_split, name=name)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/op_def_library.py", line 509, in apply_op
(prefix, dtypes.as_dtype(input_arg.type).name))
TypeError: Input 'split_dim' of 'Split' Op has type float32 that does not match expected type of int32.

train a new model

1.直接执行python train.py -c conf/wave.yml就可以了?
我的电脑显示以下信息就没有动过了什么情况?
{
INFO:tensorflow:vgg_16/conv1/conv1_1
………………
INFO:tensorflow:vgg_16/fc7
INFO:tensorflow:vgg_16/fc8
INFO:tensorflow:Use pretrained model pretrained/vgg_16.ckpt
}

2.我们只能训练conf文件夹里面原有的模型?不能全部重新训练?
3.执行train最终会得到什么?

使用网盘训练好的模型验证出错

Use Trained Models:

You can download all the 7 trained models from Baidu Drive.

To generate a sample from the model "wave.ckpt-done", run:

python eval.py --model_file --image_file img/test.jpg
使用网盘下载下来的模型验证,提示
image

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.