forked from Li-Ming-Fan/OCR-DETECTION-CTPN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript_detect.py
51 lines (37 loc) · 1012 Bytes
/
script_detect.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# -*- coding: utf-8 -*-
"""
@author: limingfan
"""
import model_detect_meta as meta
import model_detect_data as model_data
from model_detect_wrap import ModelDetect
import os
#
os.environ['CUDA_VISIBLE_DEVICES'] = '1' #使用 GPU 0
#os.environ['CUDA_VISIBLE_DEVICES'] = '0,1' # 使用 GPU 0,1
#
#
model = ModelDetect()
#
# data
print('loading data ...')
data_train = model_data.get_files_with_ext(meta.dir_images_train, 'png')
data_valid = model_data.get_files_with_ext(meta.dir_images_valid, 'png')
print('load finished.')
#
# train
model.train_and_valid(data_train, data_valid)
#
#
# predict
model.prepare_for_prediction()
#
list_images_valid = model_data.get_files_with_ext(meta.dir_images_valid, 'png')
for img_file in list_images_valid:
#
# img_file = './data_test/images/bkgd_1_0_generated_0.png'
#
print(img_file)
#
conn_bbox, text_bbox, conf_bbox = model.predict(img_file, out_dir = './results_prediction')
#