コード例 #1
0
def crop_circles(input_folder, ouput_folder):
    clear_folder(ouput_folder)
    input_files = os.listdir(input_folder)
    i = 0
    for input_file in input_files:
        path_input_file = input_folder + input_file
        img = cv2.imread(path_input_file)
        # print(path_input_file)
        imgResize = cv2.resize(img,
                               None,
                               fx=0.2,
                               fy=0.2,
                               interpolation=cv2.INTER_CUBIC)
        imgPreprocessed = preprocess1(imgResize)
        circles = process1(imgPreprocessed)
        # only one coin per image, filter bad recognition
        if len(circles) == 1:
            path = ouput_folder + str(i) + ".jpeg"
            i += 1
            rois, rois_masked = get_rois_from_image_and_circles(
                imgResize, circles)
            # print("write " + path)
            cv2.imwrite(path, rois_masked[0])
コード例 #2
0
ファイル: GBDT_cidai.py プロジェクト: wutonghua/fenlei
#分别把各个类别数据整理成一个列表形式
sentences = []
prep = preprocess(sentences, bingyin, zhenduan, zhengzhuang, zhiliao)
prep.preprocess_text(bingyin, sentences, 'pathogeny')
prep.preprocess_text(zhenduan, sentences, 'diagnosis')
prep.preprocess_text(zhengzhuang, sentences, 'symptom')
prep.preprocess_text(zhiliao, sentences, 'treatment')
random.shuffle(sentences)

#分别把各个类别数据整理成各个列表形式
bingyin_list = []
zhenduan_list = []
zhengzhuang_list = []
zhiliao_list = []
prep = preprocess1(bingyin_list, zhenduan_list, zhengzhuang_list, zhiliao_list,
                   bingyin, zhenduan, zhengzhuang, zhiliao)
prep.preprocess_lines(bingyin, bingyin_list)
prep.preprocess_lines(zhenduan, zhenduan_list)
prep.preprocess_lines(zhengzhuang, zhengzhuang_list)
prep.preprocess_lines(zhiliao, zhiliao_list)

#分割数据
x, y = zip(*sentences)
x_train, x_test, y_train, y_test = train_test_split(x, y, random_state=1234)

#训练数据,并训练各自的疾病数据成向量
text_classifier = TextClassifier()
text_classifier.fit(x_train, y_train)
print(text_classifier.score(x_test, y_test))
bingyin_xl = text_classifier.features(bingyin_list).todense()
zhiliao_xl = text_classifier.features(zhiliao_list).todense()