I'm currently building vehicle identification software using machine learning.
- Some of our open source projects are on Parkpow.
- If you are interested in working with us, contact us.
Fully convolutional deep neural network to remove transparent overlays from images
I'm currently building vehicle identification software using machine learning.
what does the output.png look like when run python watermarks.py --image assets/output.png --selection assets/cat-selection.png
? my output.png still has the watermark and it looks like a part of source image.
I trained on dataset of 192 images. Train size = 192*0.8/2 = 153 and training on 39 images. I started training on google cloud with 24 GB Ram . 100 epoch completed with in 15 min but while evaluating after 100 epoch .. It is taking a lot of time. Its been 9 hours since evaluation part started after 100 epoch and its still not completed.
What can be done to speed it up? Thanks.
i am not familiar tensorflow-python, but i'd love to try running this interesting project.
will anyone post steps to run it ( video tutorial would be extremely helpful )
Hello!
Can I get a full instruction on how to train pictures of this type. And how then does it all work to remove the watermark?
I added my 25 images with watermark custom images in data/VOCdevkit/VOC2012/JPEGImages as described and trained using given command.
In the last line return (next_element,
[iterator.make_initializer(x) for x in [train, val]]) this portion of the code gives above error.
def dataset_split(dataset_fn, split):
# import pdb; pdb.set_trace();
records = get_records()
split = int(len(records) * split)
train, val = dataset_fn(records[:split]), dataset_fn(records[split:])
iterator = tf.contrib.data.Iterator.from_structure(
train.output_types, train.output_shapes)
# import ipdb; ipdb.set_trace();
next_element = iterator.get_next()
return (next_element,
[iterator.make_initializer(x) for x in [train, val]])
What could be the issue? Thanks.
how to run this project please help me, i am new in this field so i do not know that much.
Thank you for your time.
Hi,
sess.run(iterator_inits[1]) # switch to validation dataset
while True:
import pdb; pdb.set_trace();
try:
_, summaries_ = sess.run([loss, summaries],
feed_dict={training: False})
# print(summaries_)
val_writer.add_summary(summaries_, global_step_)
except tf.errors.OutOfRangeError:
break
Above code for validation steps never finishes. I trained on 192 images and validation steps never finishes even after 10 hours.
Is the because of that infinite loop and never reaching to break statement?
1 watermarks.py line 12 should be tf.flags.DEFINE_string('logdir', '/log', 'Log directory')
2 you should build an directory named 'data' and put the traindata in that
3 training cost lots of time
Could you please add model.ckpt that you have trained to avoid personal full dataset training as well?
I assume using this model with transfer learning way: get a pre-trained model, set up training on my own dataset to reach the best result
Describe the bug
test.py return "W tensorflow/core/framework/op_kernel.cc:1192] Not found: Unsuccessful TensorSliceReader constructor: ".
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Test pass.
I just found your repo and tried to use the CNN on a dataset of images, but I ran into a problem.
As described in the README I installed the dependencies with pip, downloaded the training material into the data/ folder and trained the CNN with the given command.
The part I don't understand right now is how I can use the trained CNN for my images.
Hopefully you can help me with that.
I'm not exactly sure where to place training data, if it should be in a specific format or not.
Error message: Source images are missing!
Please document these into the README.md
file. Its quite stressful to try and find.
I'm training 17000 pictures on GCP compute engine.
Computer engine infomation:
CPU & Memory: n1-highmem-8 (8 vCPU๏ผ52 GB memory)
GPU: 8 x NVIDIA Tesla K80
Disk: 100G SSD
I've already executed the python3 watermarks.py --logdir=save/ until now.
but it has not completed yet. Is there any way to get faster?
Trained successfully for 1000 epoch but result is worst than the given watermarked image. Seems like watermark getting override on top of watermark image itself instead of removing it which makes watermark now more thicker. Doing opposite job.
Please let me know if I did something wrong?
Can you please tell me which part might have cause issue of not generalising well. Like which part should I focus on more to improve your code?
When I run
G:\Users\user\Desktop\cnn>C:\Users\user\AppData\Local\Programs\Python\Python36\python.exe watermarks.py --logdir=save/
The trainer crashes after exactly 17000 TFRecords with the following message
Traceback (most recent call last):
File "watermarks.py", line 295, in <module>
tf.app.run()
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\platform\app.py", line 48, in run
_sys.exit(main(_sys.argv[:1] + flags_passthrough))
File "watermarks.py", line 290, in main
train(sess, globals()[FLAGS.dataset])
File "watermarks.py", line 188, in train
min_opacity, max_opacity)
File "G:\Users\user\Desktop\cnn\dataset.py", line 16, in batch_masks
for _ in range(FLAGS.batch_size)], 0)
File "G:\Users\user\Desktop\cnn\dataset.py", line 16, in <listcomp>
for _ in range(FLAGS.batch_size)], 0)
File "G:\Users\user\Desktop\cnn\dataset.py", line 39, in create_mask
mask, tf.random_uniform([], -max_angle, max_angle, tf.float32)) # Costly
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\contrib\image\python\ops\image_ops.py", line 75, in rotate
interpolation=interpolation)
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\contrib\image\python\ops\image_ops.py", line 170, in transform
images, transforms, interpolation=interpolation.upper())
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\contrib\image\ops\gen_image_ops.py", line 94, in image_projective_transform
interpolation=interpolation, name=name)
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 767, in apply_op
op_def=op_def)
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\ops.py", line 2632, in create_op
set_shapes_for_outputs(ret)
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\ops.py", line 1911, in set_shapes_for_outputs
shapes = shape_func(op)
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\common_shapes.py", line 595, in call_cpp_shape_fn
require_shape_fn)
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\common_shapes.py", line 654, in _call_cpp_shape_fn_impl
input_tensors_as_shapes, status)
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\contextlib.py", line 88, in __exit__
next(self.gen)
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\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.NotFoundError: Op type not registered 'ImageProjectiveTransform' in binary running on USER-PC. Make sure the Op and Kernel are registered in the binary running in this process.
Am I doing something wrong?
When I ran this with GPU, its always report following error, any insight?
2018-01-19 11:48:00.339295: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\36\tensorflow\core\common_runtime\placer.cc:874] global_step/initial_value: (Const)/job:localhost/replica:0/task:0/device:CPU:0
2018-01-19 11:48:01.722868: E C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\36\tensorflow\stream_executor\cuda\cuda_event.cc:49] Error polling for event status: failed to query event: CUDA_ERROR_LAUNCH_FAILED
2018-01-19 11:48:01.723068: F C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\36\tensorflow\core\common_runtime\gpu\gpu_event_mgr.cc:203] Unexpected Event status: 1
Describe the bug
A clear and concise description of what the bug is.
Last time I tried installing all the prereqs, at the very end it didn't work (windows 10 with python and all the requirements)
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
I cannot install either with pip, pip2, or pip3
Step i did in the terminal is (after i clone the git)
All the pip command i run is failed
All my python versions:
Python 2 is 2.7.18
Python 3 is 3.8.3 is more than 3.6 requirement (Read from Pipfile)
pip and pip2 command result:
ERROR: Could not find a version that satisfies the requirement matplotlib==3.1.1 (from -r requirements.txt (line 1)) (from versions: 0.86, 0.86.1, 0.86.2, 0.91.0, 0.91.1, 1.0.1, 1.1.0, 1.1.1, 1.2.0, 1.2.1, 1.3.0, 1.3.1, 1.4.0, 1.4.1rc1, 1.4.1, 1.4.2, 1.4.3, 1.5.0, 1.5.1, 1.5.2, 1.5.3, 2.0.0b1, 2.0.0b2, 2.0.0b3, 2.0.0b4, 2.0.0rc1, 2.0.0rc2, 2.0.0, 2.0.1, 2.0.2, 2.1.0rc1, 2.1.0, 2.1.1, 2.1.2, 2.2.0rc1, 2.2.0, 2.2.2, 2.2.3, 2.2.4, 2.2.5)
ERROR: No matching distribution found for matplotlib==3.1.1 (from -r requirements.txt (line 1))
pip3 command result:
ERROR: Could not find a version that satisfies the requirement tensorflow==1.14.0 (from -r requirements.txt (line 4)) (from versions: 2.2.0rc1, 2.2.0rc2, 2.2.0rc3, 2.2.0rc4, 2.2.0, 2.3.0rc0)
ERROR: No matching distribution found for tensorflow==1.14.0 (from -r requirements.txt (line 4))
If the problem is the python version. I sure that not the problem
All 'my sudo apt-get install' results
Python 3:
Command: sudo apt-get install python3
Result:
Reading package lists... Done
Building dependency tree
Reading state information... Done
python3 is already the newest version (3.8.2-3).
Python 2:
Command: sudo apt-get install python2
Result:
Reading package lists... Done
Building dependency tree
Reading state information... Done
python2 is already the newest version (2.7.17-2). for some reason python2 output 2.7.18 not 2.7.17
python2 set to manually installed.
How do i train it on our own dataset? Can you please specify guidelines and can tell how to use mask also?
Hello, I just run the inference using your pretained model. Though hello world
words in the watermark temple assets/cat-selection.png
is very different from the watermark word in the assets/cat.png
, it works well.
But when try my own watermark photo(it is same with watermark on the common photo, but having a very small size) and common photo, it does not work. Small watermark temple mask does not work? Can you give some advises?
Hi Marc,
First of all, thanks for sharing the experiment it's pretty interesting for learning.
I had few questions tho, the selection file must be with the same width/height than the input image ? the Training tooks hours and reach 40000 epoch but with this result :
Her is also my model :
data.zip
Thank you.
======================================================================`
ERROR: test_inference_voc (__main__.WatermarkTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/ubuntu/anaconda3/envs/watermark/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1323, in _do_call
return fn(*args)
File "/home/ubuntu/anaconda3/envs/watermark/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1302, in _run_fn
status, run_metadata)
File "/home/ubuntu/anaconda3/envs/watermark/lib/python3.6/site-packages/tensorflow/python/framework/errors_impl.py", line 473, in __exit__
c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.NotFoundError: Key conv2d_9/kernel not found in checkpoint
[[Node: save_1/RestoreV2_117 = RestoreV2[dtypes=[DT_FLOAT], _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_save_1/Const_0_0, save_1/RestoreV2_117/tensor_names, `save_1/RestoreV2_117/shape_and_slices)]]
How to solve this error? Why is it happening? Thanks
I mkdir 'cifar-10-batches-py' and copy the data "data_batch_*".
after that, I run the script "python watermarks.py --logdir=./save "
but I got this error:
''
Traceback (most recent call last):
File "watermarks.py", line 311, in
tf.app.run()
File "lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 40, in run
_run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
File "lib/python3.6/site-packages/absl/app.py", line 303, in run
_run_main(main, args)
File "lib/python3.6/site-packages/absl/app.py", line 251, in _run_main
sys.exit(main(argv))
File "watermarks.py", line 306, in main
train(sess, globals()[FLAGS.dataset])
File "watermarks.py", line 189, in train
next_image, iterator_inits = dataset_split(dataset, .8)
File "cnn-watermark-removal/dataset.py", line 70, in dataset_split
records = get_records()
File "cnn-watermark-removal/dataset.py", line 64, in get_records
convert_to_record()
File "cnn-watermark-removal/dataset.py", line 181, in convert_to_record
writer.close()
AttributeError: 'NoneType' object has no attribute 'close'
''
thx a lot!
So I tried removing the watermark on the cat picture with your code and the selection mask provided in the assets
directory, but not getting the same result as is shown in your README
file. It looks like something whitish is just simply added onto the cat picture instead of reducing the watermark effect. How come this happen? Any suggestions on improving this result?
How can your code be used to detect watermarks?Just want to detect if there's a watermark in the image or not by using your code?
Describe the bug
Seems stuck after executing python3 watermarks.py --logdir=save/
Been more than 12 hours.
I have a Macbook Pro i7 with 16GB RAM.
This is the output after which it got stuck:
2019-06-29 22:47:21.727178: 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.
2019-06-29 22:47:21.727206: 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.
2019-06-29 22:47:21.727248: 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.
2019-06-29 22:47:21.727257: 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.
Ironically the CPU & RAM are running full throttle.
Expected behavior
A clear and concise description of what you expected to happen.
Is Google CVPR 2017 on roadmap ?
I want to train on custom dataset. How to generate training mask for this?
Hi there. I cannot find a download for the pascal dataset.
Could you please link to it or better yet include it in the repo?
Thanks.
I want to understand that how you were able to generate that image cat-selection.png for predicting output.
Any help will be appreciated.
Please add docker for use in container
!python watermarks.py --image assets/cat.png --selection assets/cat-selection.png --dataset=dataset_cifar --batch_size 32
WARNING:tensorflow:From watermarks.py:298: The name tf.app.run is deprecated. Please use tf.compat.v1.app.run instead.
WARNING:tensorflow:From watermarks.py:282: The name tf.Session is deprecated. Please use tf.compat.v1.Session instead.
W1109 16:02:22.012408 140498710181760 deprecation_wrapper.py:119] From watermarks.py:282: The name tf.Session is deprecated. Please use tf.compat.v1.Session instead.
2020-11-09 16:02:22.025011: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2020-11-09 16:02:22.028714: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 2249995000 Hz
2020-11-09 16:02:22.028934: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x32032c0 executing computations on platform Host. Devices:
2020-11-09 16:02:22.028963: I tensorflow/compiler/xla/service/service.cc:175] StreamExecutor device (0): <undefined>, <undefined>
Traceback (most recent call last):
File "watermarks.py", line 298, in <module>
tf.app.run()
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/platform/app.py", line 40, in run
_run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
File "/usr/local/lib/python3.6/dist-packages/absl/app.py", line 300, in run
_run_main(main, args)
File "/usr/local/lib/python3.6/dist-packages/absl/app.py", line 251, in _run_main
sys.exit(main(argv))
File "watermarks.py", line 289, in main
lambda: dataset_paths([FLAGS.selection]))
File "watermarks.py", line 117, in inference
next_image, iterator_init = dataset()
File "watermarks.py", line 286, in <lambda>
lambda: dataset_paths([FLAGS.image]),
File "/content/cnn-watermark-removal/dataset.py", line 50, in dataset_paths
dataset = tf.Dataset.from_tensor_slices(tf.constant(paths))
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/util/deprecation_wrapper.py", line 106, in __getattr__
attr = getattr(self._dw_wrapped_module, name)
AttributeError: module 'tensorflow' has no attribute 'Dataset'
Hello,thanks for your share
But I want to use it to train my own dataset, and I dont know how to deal with it.
Could you give me some suggestion?
Shayna&Jared@laptopv1 MINGW64 ~/Desktop/g
$ git clone https://github.com/marcbelmont/cnn-watermark-removal.git
fatal: bad config line 1 in file C:/Users/Shayna&Jared/.gitconfig
Shayna&Jared@laptopv1 MINGW64 ~/Desktop/g
$ man git config
bash: man: command not found
Shayna&Jared@laptopv1 MINGW64 ~/Desktop/g
$ git -h
fatal: bad config line 1 in file C:/Users/Shayna&Jared/.gitconfig
Shayna&Jared@laptopv1 MINGW64 ~/Desktop/g
$ git clone https://github.com/marcbelmont/cnn-watermark-removal.git
Cloning into 'cnn-watermark-removal'...
remote: Enumerating objects: 95, done.
remote: Counting objects: 100% (7/7), done.
remote: Compressing objects: 100% (7/7), done.
Receiving objects: 100% (95/95), 1.49 MiB | 352.00 KiB/s, done.eceiving objects: 90% (86/95), 1.37 MiB | 330.00 KiB/s
Resolving deltas: 100% (41/41), done.
Shayna&Jared@laptopv1 MINGW64 ~/Desktop/g
$ pip install -r requirements.txt
ERROR: Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt'
Shayna&Jared@laptopv1 MINGW64 ~/Desktop/g
$ ls
cnn-watermark-removal/
Shayna&Jared@laptopv1 MINGW64 ~/Desktop/g
$ cd cnn-watermark-removal/
Shayna&Jared@laptopv1 MINGW64 ~/Desktop/g/cnn-watermark-removal
$ ls
assets/ dataset.py Pipfile Pipfile.lock README.md requirements.txt tests.py watermarks.py
Shayna&Jared@laptopv1 MINGW64 ~/Desktop/g/cnn-watermark-removal
$ pip install -r requirements.txt
Collecting matplotlib==3.1.1
Downloading matplotlib-3.1.1.tar.gz (37.8 MB)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ 37.8/37.8 MB 1.4 MB/s eta 0:00:00
Preparing metadata (setup.py) ... done
Collecting numpy==1.16.0
Downloading numpy-1.16.0.zip (5.1 MB)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ 5.1/5.1 MB 800.7 kB/s eta 0:00:00
Preparing metadata (setup.py) ... done
Collecting Pillow==4.1.0
Downloading Pillow-4.1.0.tar.gz (11.3 MB)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ 11.3/11.3 MB 688.8 kB/s eta 0:00:00
Preparing metadata (setup.py) ... done
ERROR: Could not find a version that satisfies the requirement tensorflow==1.14.0 (from versions: 2.8.0rc1, 2.8.0, 2.8.1,
2.8.2, 2.8.3, 2.9.0rc0, 2.9.0rc1, 2.9.0rc2, 2.9.0, 2.9.1, 2.9.2, 2.10.0rc0, 2.10.0rc1, 2.10.0rc2, 2.10.0rc3, 2.10.0)
ERROR: No matching distribution found for tensorflow==1.14.0
Shayna&Jared@laptopv1 MINGW64 ~/Desktop/g/cnn-watermark-removal
$
Limitations: this architectures does not generalize to watermarks that are too different from the one generated with create_mask and it produces decent results only when the overlay is applied in an additive fashion.
Could you please elaborate on mostly on create_mask() function and overlay is applied in an additive fashion?
Hi, I ran a problem when trying to test your pre-trained model on my own image, and I'm a little confused by the cat-selection.png. I know that the model can work well when corresponding selection.png is provided. But I noticed that cat.png and cat-selection.png have completely different sizes. How does the model know the corresponding relationship between two images. I tried to change the size of cat-selection.png and the outcome did become worse, so I'm pretty sure that there's something I didn't notice. Can anyone answer my question?
My output.png looks like a part of source image. The source image has a size of 1200530, and the output image only has a size of 300300. I find the size of empty.png is also 300*300. So I wonder what the function of empty.png is.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.