Caricature generation by deep learning. Use WarpGAN on iOS. [with converted model]

https://miro.medium.com/max/348/0*jBWuIeXeHbpDTfXm

Original Source Here

Caricature generation by deep learning. Use WarpGAN on iOS. [with converted model]

WarpGAN that can generate caricatures .

If you convert to Core ML, you can generate a caricature just by inputting an image from Image Picker Controller etc.
It became CoreMLTools4.0 and can be converted (it could not be converted with tfcoreml).
Converted Core ML model

1. Make the graph in pbtxt format.

# warpgan.pytf.io.write_graph(self.sess.graph_def, '', 'warpgan.pbtxt')

* allow_pickle had to be set

# detect_face.pydata_dict = np.load(data_path, encoding='latin1',allow_pickle=True).item()

2. Make a freezing graph from checkpoints.

from tensorflow.python.tools.freeze_graph import freeze_graphgraph_def_file = ‘warpgan.pbtxt’
checkpoint_file = ‘warpgan_pretrained/ckpt-100000’
frozen_model_file = ‘./frozen_model.pb’
output_node_names = ‘Decoder/Decoder/images_rendered’
freeze_graph(input_graph=graph_def_file,
input_saver=””, input_binary=False,
input_checkpoint=checkpoint_file,
output_node_names=output_node_names,
restore_op_name=”save/restore_all”,
filename_tensor_name=”save/Const:0",
output_graph=frozen_model_file, clear_devices=True,
initializer_nodes=””)

3. Convert with coremltools.

import coremltools as ct 
image_input = ct.ImageType(shape=(1, 256, 256, 3,), scale=2/255,bias=[-1,-1,-1])
coreml_model = ct.convert(“frozen_model.pb”,
inputs=[image_input], )
coreml_model.save(“warpgan.mlmodel”)

You can convert it beautifully by cropping it around your face with Vision and then applying it to the model.

🐣

****

Request for work:

rockyshikoku@gmail.com

We send information related to machine learning.

Twitter

AI/ML

Trending AI/ML Article Identified & Digested via Granola by Ramsey Elbasheer; a Machine-Driven RSS Bot

%d bloggers like this: