Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not compatible with current pix2pix and its models exported #7

Open
skabbit opened this issue Jan 14, 2020 · 1 comment
Open

Not compatible with current pix2pix and its models exported #7

skabbit opened this issue Jan 14, 2020 · 1 comment

Comments

@skabbit
Copy link

skabbit commented Jan 14, 2020

If you try your own trained models, you'll get the error:
tensorflow.python.framework.errors_impl.InvalidArgumentError: You must feed a value for placeholder tensor 'Placeholder' with dtype string and shape [1]

Current pix2pix (mode=export) use base64 PNG as an input value. It is easy to fix webcam-pix2pix-tensorflow in predictor.py, patch starting from line 77:

-        img = np.expand_dims(img, 0) if len(img.shape) < 4 else img
-        model_out = self.sess.run( [self.output_op], { self.input_op: img })[0]

+        pil_img = Image.fromarray(img, mode="RGB")
+        buff = BytesIO()
+        pil_img.save(buff, format="PNG")
+        img_base64 = base64.urlsafe_b64encode(buff.getvalue())
+        model_out = self.sess.run( [self.output_op], { "Placeholder:0": [img_base64] })[0]

@skabbit
Copy link
Author

skabbit commented Jan 16, 2020

Oops. Re-tested this solution, it works somehow another way.
Resulted image is not really connected to the source, no readable shapes or anything.
I've rollback the "export" mode of pix2pix to an older version, and it works well.
Will discover the things further.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant