whai362 / pan_pp.pytorch

Official implementations of PSENet, PAN and PAN++.
Apache License 2.0
435 stars 90 forks source link

Custom image Inference #91

Open kdh-awraw1019 opened 2 years ago

kdh-awraw1019 commented 2 years ago

I want to inference about a custom image.

this image is not in 'Prepare datasets' ex) ic17, ic15, ...

How can I inference a custom image?

How should I change it here? ▼▼

./config/pan_pp/pan_pp_r18_ic15_joint_train.py

data = dict( batch_size=16, train=dict( type='PAN_PP_JointTrain', split='train', is_transform=True, img_size=736, short_size=736, kernel_scale=0.5, read_type='pil', with_rec=True ), test=dict( type='PAN_PP_IC15', split='test', short_size=720, read_type='pil', with_rec=True ) )

EMRAN-SALEH-CORSEARCH commented 2 years ago

Yeah, Same here. I want ro do inference of PAN++ on custom image. I do not see that in the repo.

kdh-awraw1019 commented 2 years ago

Yeah, Same here. I want ro do inference of PAN++ on custom image. I do not see that in the repo.

I did modified some codes and inference with my cunstom data.

1) pan_pp.pytorch/dataset/pan_pp/pan_pp_joint_train.py

import math import random import string

import cv2 import mmcv import numpy as np import Polygon as plg import pyclipper import scipy.io as scio import torch import torchvision.transforms as transforms from PIL import Image from torch.utils import data

from .coco_text import COCO_Text

EPS = 1e-6 synth_root_dir = './data/SynthText/' synth_train_data_dir = synth_root_dir synth_train_gt_path = synth_root_dir + 'gt.mat'

ic17_root_dir = './data/ICDAR2017MLT/' ic17_train_data_dir = ic17_root_dir + 'ch8_training_images/' ic17_train_gt_dir = ic17_root_dir + \ 'ch8_training_localization_transcription_gt_v2/'

ct_root_dir = './data/COCO-Text/' ct_train_data_dir = ct_root_dir + 'train2014/' ct_train_gt_path = ct_root_dir + 'COCO_Text.json'

''' ic15_root_dir = './data/ICDAR2015/Challenge4/' ic15_train_data_dir = ic15_root_dir + 'ch4_training_images/' ic15_train_gt_dir = ic15_root_dir + \ 'ch4_training_localization_transcription_gt/' ''' ############ modified ####### ic15_root_dir = your dataset path location ## ic15_test_data_dir = ic15_root_dir + 'imgs/' ic15_test_gt_dir = ic15_root_dir + 'gts/'

##################################

2) pan_pp.pytorch/configs/pan_pp/pan_pp_r18_ic15_joint_train.py data = dict( batch_size=1, train=dict( type='PAN_PP_JointTrain', split='train', is_transform=True, img_size=736,# 736, short_size=736,# 736, kernel_scale=0.5, read_type='pil', with_rec=True ), test=dict( type='PAN_PP_IC15', ## my custom dataset's format is ic15 split='test', short_size=96,# default : 720, read_type='pil', with_rec=True ) )

Devin521314 commented 2 years ago

How to predict a new image using the training weight?it doesn't work below.

python test.py config/pan/pan_r18_ic15.py checkpoints/pan_r18_ic15/checkpoint.pth.tar cd eval/ ./eval_ic15.sh

please inform me with qushanghui@niii.com or wechat SanQian-2012,thanks you so much.