AliaksandrSiarohin / pose-gan

382 stars 79 forks source link

Question: How to serve the trained models? #26

Closed gayashanbc closed 5 years ago

gayashanbc commented 5 years ago

Question

Is it possible to use the trained model (i.e. checkpoints) for serving (i.e a tensorflow/serving) in a production environment? If yes, what is the procedure that I should follow in order to do that?

Example scenario

I want to input a single image of a person (not from the images used in the training datasets) to the system and synthesize that person image in a new pose

AliaksandrSiarohin commented 5 years ago

I never used serving. So I cant help you with that. Also I would not advise you to use this models in production, the quality of generated images is rather low compared to production requirements. Moreover it will not generalize outside the dataset. The closest thing I have is demo.py, usage is following: 1) Put an image of your person to data/source_image.jpg 2) Put image from which to extract pose to data/target_images 3) Download pose estimator and some checkpoint (see Readme where) 4) python demo.py --generator_checkpoint path_to_checkpoint --warp_skip mask --dataset dataset_name --cache_pose_rep 0 5) Result should be in output/generated_images

There are already some images in the repository, you will need to remove them/

gayashanbc commented 5 years ago

Thanks for the detailed explanation. I'm getting the following error when I followed the above steps. Traceback (most recent call last): File "demo.py", line 108, in <module> input_images, target_images, generated_images, names = generate_images(dataset, generator, args.use_input_pose) File "/home/shan/Documents/pg/test.py", line 90, in generate_images batch, name = dataset.next_generator_sample_test(with_names=True) File "/home/shan/Documents/pg/pose_dataset.py", line 174, in next_generator_sample_test batch = self.load_batch(index, False, True) File "/home/shan/Documents/pg/pose_dataset.py", line 153, in load_batch result = [self.load_image_batch(pair_df, 'from')] File "/home/shan/Documents/pg/pose_dataset.py", line 131, in load_image_batch batch[i] = imread(os.path.join(self._images_dir_test, p[direction]))

ValueError: could not broadcast input array from shape (128,64,3) into shape (256,256,3)

AliaksandrSiarohin commented 5 years ago

Ah, sorry. This was written for market. You should change resize in the line: https://github.com/AliaksandrSiarohin/pose-gan/blob/abda78780f5ef51092c154fd2ffe71fdeb41a693/demo.py#L61 to (256, 256).

gayashanbc commented 5 years ago

OK, it's working now Thanks 😄