clovaai / ext_portrait_segmentation

MIT License
239 stars 68 forks source link

Testing new Image #23

Open ZshahRA opened 4 years ago

ZshahRA commented 4 years ago

Hello @HYOJINPARK ,

I successfully trained the ExtremeC3Net. Now I want to test new images to see the testing accuracy. I am not sure what to do next. I tried putting images in Link512DATA folder and run Test_model.py. But there is no option to show images results. 1) Where I should put my testing images? I mean which folder. 2) And how to see segmented results? I can't see any of the following. I am not sure where? cv2.imwrite("%s.jpg" %idx,np.asarray(segmented)) fig, axes = plt.subplots(1, 2, figsize=(12, 10)) axes[0].imshow(image)

Your response would be highly appreciated. Thank you

HYOJINPARK commented 4 years ago

Dear @ZshahRA

Sorry to uncomfortable showing result images

please refer main.py line 247 to add image information to visdom.

 if args.visualize:
                if train_config["loss"] == "Lovasz":
                    grid_outputs = torchvision.utils.make_grid(color_transform((save_est[0] > 0).cpu().data), nrow=6)
                else:
                    grid_outputs = torchvision.utils.make_grid(
                        color_transform(save_est[0].unsqueeze(0).cpu().max(1)[1].data), nrow=6)

This is visualized the validation image.
If you want own image please refer "./etc/Visualize_video" You can test your custom video file.

ZshahRA commented 4 years ago

Thank you @HYOJINPARK, I tried visualize_video, I had the following issues. 1) File "Visualize_video.py", line 19, in from etc.utils import * # commented by rahmat this line only ModuleNotFoundError: No module named 'etc' I used the following code, but again it shows the same issue. conda install -c conda-forge python-utils

2) I commented from etc.utils import *. so that I can run the code and i input my model information from line 253 in visualize_video.py as shown below.

if name == 'main': import models parser = ArgumentParser() parser.add_argument('-c', '--config', type=str, default='./setting/ExtremeC3Net.json', #parser.add_argument('-c', '--config', type=str, default='../setting/SINet.json', help='JSON file for configuration') Max_name = "./result/Stage2_ExtremeC3Net05-04_0316/model_234.pth" #Max_name = "../result/Dnc_SINet11-24_2218/model_3.pth" logdir= "./video/Stage2_ExtremeC3Net05-04_0316" #logdir= "../video/Dnc_SINet11-24_2218" mean = [107.304565, 115.69884, 132.35703 ] std = [63.97182, 65.1337, 68.29726] args = parser.parse_args() with open(args.config) as fin: config = json.load(fin) train_config = config['train_config'] data_config = config['data_config'] model_name = "Stage2_ExtremeC3" #model_name = "Dnc_SINet" Lovasz = train_config["loss"] == "Lovasz" if Lovasz: train_config["num_classes"] = train_config["num_classes"] -1 model = models.dict[model_name](classes=train_config["num_classes"], p=train_config["p"], q=train_config["q"], chnn=train_config["chnn"]) if torch.cuda.device_count() > 0: model=model.cuda() ExportVideo(model, Max_name, "./video/", logdir, "video1.mp4", data_config["h"], data_config["w"], mean, std, Lovasz, pil=False)

but i had the following issue

Traceback (most recent call last): File "Visualize_video.py", line 254, in import models ModuleNotFoundError: No module named 'models'