Comments (5)
I modified the test code and it's generating and saving the images.
Please find below very simple version of test.py
import os
import cv2
import numpy as np
from PIL import Image
from util import util
from options.test_options import TestOptions
from models.pix2pix_model import Pix2PixModel
from data.base_dataset import get_params, get_transform
#Loading the trained model
opt = TestOptions().parse()
model = Pix2PixModel(opt)
model.eval()
#Loading Semantic Label
label_path = 'datasets/test_sketch/annotations/validation/test_val_00000002.png'
label = Image.open(label_path)
params = get_params(opt, label.size)
transform_label = get_transform(opt, params, method=Image.NEAREST, normalize=False)
label_tensor = transform_label(label) * 255.0
label_tensor[label_tensor == 255] = opt.label_nc
print("-- Label tensor :", np.shape(label_tensor))
#Creating data_dictionary
data_i = {}
data_i['label'] = label_tensor.unsqueeze(0)
data_i['path'] = [None]
data_i['image'] = [None]
data_i['instance'] = [None]
#Inference code
generated = model(data_i, mode='inference')
for b in range(generated.shape[0]):
generated_image = generated[b]
# generated_image = np.moveaxis(generated_image.cpu().detach().numpy(), 0, -1)
generated_image = util.tensor2im(generated_image)
generated_image_path_ = generated_image_path[:-4]+str(b)+".png"
print('---- generated image ', generated_image_path_, np.shape(generated_image))
cv2.imwrite(generated_image_path_, generated_image)
To run this code,
python test.py --name ade20k_pretrained --dataset_mode ade20k --dataroot datasets/test_sketch/ --gpu_ids -1 --results_dir results/test_sketch
from spade.
For this, you will need to modify the code of the dataset class (CocoDataset for example) to be able to load the layouts only.
The image generation process entirely depends on the label layout, and does not depend on the validation image. Therefore, the output result will not change even if you change the image. The groud-truth RGB image is merely used for comparison.
from spade.
@jmoberreuter have you solved the issue?
from spade.
@jmoberreuter @MrWwei Have you resolved the issue?
@taesungp Could you please explain a bit more about changes to be made.
from spade.
I got the solution, the dataloader code is using the val_img path for reference.
data_i in dataloader is a dictionary with following keys: dict_keys(['label', 'instance', 'image', 'path'])
data_i[path] contains list of name of validation images, but it is not being used in Evaluation code in inference mode.
from spade.
Related Issues (20)
- How can I run this using RGB label as input ? HOT 4
- CUDA error: device-side assert triggered HOT 1
- Two update_learning_rate with same name
- RuntimeError: cublas runtime error : an access to GPU memory space failed at
- Converting to onnx HOT 2
- Choice between multi-scale discriminator and progrssive growing of GANs ?
- How many categories have you predicted for flickr data using deeplab?
- How "label_nc" in the setting works? HOT 2
- CUDA Error?? HOT 4
- Public API
- Extend to instance segmentation
- IndexError with custom dataset HOT 2
- errors with custom dataset HOT 3
- how to prepare the custom datasets?
- Issue a black background is added to the transparent image HOT 1
- GauGAN2 Paper HOT 1
- add --tf_log , program can not run HOT 1
- any pretrained models on ade20k or cityscapes with use_vae?
- Online demo app no longer on nvidia site?
- Training the model for Image to Image translation without label_nc and instance maps.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spade.