-
Notifications
You must be signed in to change notification settings - Fork 21
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
How to run inference? #17
Comments
The graph normalizes images within the graph and expect input between 0-255 as uint. The output you are using is however not normalized and is scaled between 0 and 1 so that rescaling is correct. |
Thanks, Aaron.
…On Sun, Jun 23, 2019, 17:29 Aaron Gokaslan ***@***.***> wrote:
The graph normalizes images within the graph and expect input between
0-255 as uint. The output you are using is however not normalized and is
scaled between 0 and 1 so that rescaling is correct.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#17?email_source=notifications&email_token=AARV4BA2IAKWQGQQ6C6U24DP37TLRA5CNFSM4H2XLYH2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODYLHOVY#issuecomment-504788823>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AARV4BCO6UM2HF5QFYSBLIDP37TLRANCNFSM4H2XLYHQ>
.
|
okay so it looks like based on the fact you are getting 3 separate images as output that you are using one of the Tensors in /viz? If you are, the first image should be the input, the second the translation, and the third the reconstruction. Are you still using Brad Pit as input? If so, the first image should look like Brad Pitt and it looks like an anime character. |
I am getting 3 images as output because I am testing with 3 separate pretrained models, as I mentioned in the first post:
I have downloaded the models from the link in the README. I am using the code above to produce these images by passing the appropriate I'm not sure what you mean by "Tensors in /viz". |
So I ran the code locally and found the issue. The Brad Pitt photo is just too zoomed ou. I tested your script on the CelebA dataset and pictures from my webcam and the script works fine when you zoom in further. You can recreate this by either resizing the shortest edge of celeba photo to 128 * 1.12 and then center cropping or by using opencv's face detector and modifying the bounding box a little like so.
Hope this helps! |
Could you post an example image for which I should expect reasonable results? |
Sorry, do you still need an example? The CelebA images are all cropped to the appropriate size if you need an example. |
Thank you for your patience. To clarify, did you try it on any other images in the dataset? Does your script work with any of the other model weights such as human2cat or human2doll? I haven't had to run the script posted above. |
I tried it on maybe 3 images, and it never worked. I haven't checked whether |
Which version of your script are you using? Did you ensure that the values are normalized correctly? |
Apologies for the long reply. Here is the script: import argparse
from pathlib import Path
import numpy as np
import skimage.io
from tensorpack import SaverRestore, PredictConfig, OfflinePredictor
from model import Model
parser = argparse.ArgumentParser()
parser.add_argument('--model_path', help='path to trained model', required=True)
parser.add_argument('--input_image_path', help='path to load input image from', required=True, type=Path)
parser.add_argument('--output_image_path', help='path to save output images', required=True, type=Path)
args = parser.parse_args()
if __name__ == '__main__':
pred_config = PredictConfig(
model=Model(),
session_init=SaverRestore(args.model_path),
input_names=['inputB'],
output_names=['gen/A/deconv3/output:0'],
)
predictor = OfflinePredictor(pred_config)
image = skimage.io.imread(args.input_image_path)
assert image.dtype == np.uint8
inputB = image.copy()[np.newaxis, ...]
outputA, = predictor(inputB)
outputA = (outputA[0].transpose((1, 2, 0)) * 255).astype(np.uint8)
args.output_image_path.mkdir(exist_ok=True, parents=True)
skimage.io.imsave(args.output_image_path / 'a.png', outputA) Input file: 3 models I used:
Corresponding outputs: CLI command: python run.py --model_path /path/to/models/<one of 3 models> --input_image_path /path/to/pitt.png --output_image_path /any/directory |
@dniku hi! Seems like I'm facing similar problem as yours. Did you solve the issue? |
@muxgt no. |
@Skylion007 Do you have any idea? Can you share your code that works with any pre-trained checkpoint? |
I am also curious about how to run inference with these models. Any chance you could add a test script? |
the problem is the pretrained models apparently, I trained one myself, (in cyclegan mode, with a ratio of 0.8, instead of 0.33) and the output is fine with the code given by @dniku |
This code should run the model with a webcam:
@iszotic Is that so, I'll need to double check the pretrained models and maybe retrain them. |
I am trying to get human → anime conversion to run. My current code is as follows:
As input, I am using this Brad Pitt photo. However, the output I am getting with
getchu_anime/JNet_dilsc_rsep_sl_r0316-084543/model-140000.index
model is:which looks like I miss some normalization or maybe retrieve a wrong tensor.
Same code with
good_anime/model-260000.index
:With
good_anime/JNet_dilsc_rsep_sl0304-120055/model-180000.index
:What am I doing wrong?
The text was updated successfully, but these errors were encountered: