How to remove the watermark from GradImages using Machine Learning

Borgmon
Borgmon
Jun 17, 2019 · 5 min read

Hey, follow grads, have you received those emails from GradImages that ask you nearly $75 for your graduation photos? You will be provided with watermarked version and take it or leave it… You could use Photoshop to remove those annoying watermark but hey! Wait a second! You are saying you are CS major? Well we are going to have a whole load of fun!

Prices on GradImages. Single image cost you $35! There are 5 of them!

Step 1: Get image from we GradImages website

Once you enter their website (using Ubuntu preferable) you found they disabled your right click feature… Well we can get image easily by using Developer Tools (if you are using Chrome, it’s in menu ->more tools -> Developer Tools)

Using Inspector you can find the img url by click on those pictures.

You can get urls from Developer Tool

Once you find the links, you can right click and open in a new tab.

“But hey!” you may say, “those images are tiny!”

Don’t worry, we can change the query from preset=t to preset=p. Boom! You got a better quality version.

The image from website

Just right click and save it to your computer.

Step 2: Set up an Ubuntu machine

Setup an Ubuntu on a computer (or a server). Not recommend other flavor other than Ubuntu official distro (NVIDIA docker is more tricky).

You need to have git and curl installed

sudo apt-get install git curl

And you need to install the NVIDIA driver. The easiest way is using the Ubuntu build in driver manager.

Driver manager for Xubuntu. You can see NVDIA driver is enabled

After the driver installed you want to restart the computer/server.

Then the real stuff. We are using Deep image prior to do the dirty work.

But first there are some per-requirements need to be installed.

Get docker CE using official convenience script

curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh

Get nvdia-docker

# Add the package repositories
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | \
sudo apt-key add -
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | \
sudo tee /etc/apt/sources.list.d/nvidia-docker.list
sudo apt-get update

# Install nvidia-docker2 and reload the Docker daemon configuration
sudo apt-get install -y nvidia-docker2
sudo pkill -SIGHUP dockerd

Get project repo

git clone https://dmitryulyanov.github.io/deep_image_prior
cd deep-image-prior/

Fix a bug

You may find that you can’t start the docker image and get an error message Name or service not known or Name or service not known or ValueError: ‘’ does not appear to be an IPv4 or IPv6 address.

In this issue tuliopic found a fix: in the repo folder, edit your dockerfile and change the line (maybe the last line)

CMD jupyter notebook --ip="*" --no-browser --allow-root

to

CMD jupyter notebook --ip="0.0.0.0" --no-browser --allow-root

Build docker image

sudo nvidia-docker build -t deep-image-prior .

Then start it!

sudo nvidia-docker run --rm -it --ipc=host -p 8888:8888 deep-image-prior

Step 3: Upload some pictures

So once we start the docker image successfully, we can see green stuff

Green stuff, which is good!

Go to your browser and enter

http://localhost:8888

It will ask your token which is the token print in your console. (for my case it’s 3c8cc***)

Go to directory /data/inpainting, and upload your pic in it.

Because how Deep image prior works, you will need a mask to remove the the watermark. So you will need to download this mask that I created, and upload to your jupyter notebook.

The mask that we needed later

So after you upload both files:

Step 4: Change some code

Go to your jupyter notebook root and open inpainting.ipynb

In the Choose figure code block, you need to change those lines:

img_path  = 'data/inpainting/{YOUR IMAGE NAME}.png'
mask_path = 'data/inpainting/{THE MASK NAME}.png'

Then in the largest code block of Setup section, replace this with everything:

(Why? The original code is hard coded for 3 examples, but we need to do something else! Also original iteration is unnecessary, so I tested the minimum one we need)

INPUT = 'noise'
input_depth = 32
LR = 0.01
num_iter = 2251
param_noise = False
show_every = 50
figsize = 5
reg_noise_std = 0.03

Step 5: Let the fun begin!

Hit the s̶u̶b̶s̶c̶r̶i̶b̶e̶ play button (it looks like a fast forward button), and let the GPU burn!

After the code run through, you should be able to get the result!

Result-ish
Compare

Yay! The result is pretty good! Now you can get as many photo as you want without watermark by repeat last step and replace file name for your photo.

Or use Photoshop.

Borgmon

Written by

Borgmon

Future(Left(isRight), Right(isWrong)) https://www.borgmon.me/

More From Medium

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade