python中clear函数怎么用
Python中Turtle模块的基本指令都有哪些?
Python中Turtle模块的基本指令都有哪些?
Python中Turtle模块的基本指令都有 (#后是释意,turtle是python作图的一个工具)
画布(canvas)
(800, 600,
eclipse运行代码无反应,控制台显示终止?
1、可能控制台并非当前控制台,知运行前请点击clear console按钮。
2、可能后台正在进行,如刚进eclipse里面项目多,还在build workspace。显著标记就是右下角有process红点在。道
3、程序没有任何结果输出。退出了。
4、其他未知~
caffe多标签学习有没有方法显示整体的精确度?
拷贝convert_imageset,生成新工程convert_imageset_multi_label
修改源码
std::ifstream infile(argv[2])
std::vectorltstd::pairltstd::string, std::vectorltfloatgtgt gt lines
std::string filename
std::string label_count_string argv[5] int label_count std::atoi(label_count_string.c_str())
std::vectorltfloatgt label(label_count) while (infile gtgt filename) { for (int i 0 i lt label_count i )
infile gtgt label[i]
lines.push_back(std::make_pair(filename, label))
} if (FLAGS_shuffle) { // randomly shuffle data
LOG(INFO) ltlt Shuffling data
shuffle((), lines.end())
}
LOG(INFO) ltlt A total of ltlt () ltlt images. if (encode_() ampamp !encoded)
LOG(INFO) ltlt encode_type specified, assuming encodedtrue. int resize_height std::maxltintgt(0, FLAGS_resize_height) int resize_width std::maxltintgt(0, FLAGS_resize_width) // Create new DB
scoped_ptrltdb::DBgt db_image(db::GetDB(FLAGS_backend))
scoped_ptrltdb::DBgt db_label(db::GetDB(FLAGS_backend))
db_image-gtOpen(argv[3], db::NEW)
db_label-gtOpen(argv[4], db::NEW)
scoped_ptrltdb::Transactiongt txn_image(db_image-gtNewTransaction())
scoped_ptrltdb::Transactiongt txn_label(db_label-gtNewTransaction())// // Create new DB// scoped_ptrltdb::DBgt db(db::GetDB(FLAGS_backend))// db-gtOpen(argv[3], db::NEW)// scoped_ptrltdb::Transactiongt txn(db-gtNewTransaction()) // Storing to db
std::string root_folder(argv[1])
Datum datum_image
Datum datum_label int count 0 int data_size 0 bool data_size_initialized false for (int line_id 0 line_id lt () line_id) { bool status
std::string enc encode_type if (encoded ampamp !()) { // Guess the encoding type from the file name
string fn lines[line_id].first
size_t p fn.rfind(.) if ( p )
LOG(WARNING) ltlt Failed to guess the encoding of ltlt fn ltlt
enc (p)
std::transform((), enc.end(), (), ::tolower)
}
status ReadImageToDatum(root_folder lines[line_id].first,
lines[line_id].second[0], resize_height, resize_width, is_color,
enc, ampdatum_image) if (status false) continue if (check_size) { if (!data_size_initialized) {
data_size datum_() * datum_image.height() * datum_image.width()
data_size_initialized true
} else { const std::stringamp data datum_()
CHECK_EQ((), data_size) ltlt Incorrect data field size
ltlt ()
}
} // sequential
string key_str caffe::format_int(line_id, 8) _ lines[line_id].first // Put in db
string out
CHECK(datum_(ampout))
txn_image-gtPut(key_str, out) //////////////////////////////////////////////////////////////////////////
datum__channels(label_count)
datum__height(1)
datum__width(1)
datum__data()
datum__float_data()
datum__encoded(false)
std::vectorltfloatgt label_vec lines[line_id].second for (int i 0 i lt label_()i )
{ datum__float_data(label_vec[i])
} string out_label
CHECK(datum_(ampout_label))
txn_label-gtPut(key_str, out_label) ////////////////////////////////////////////////////////////////////////// if ( count % 1000 0) { // Commit db
txn_image-gtCommit()
txn_(db_image-gtNewTransaction())
txn_label-gtCommit()
txn_(db_label-gtNewTransaction())
LOG(INFO) ltlt Processed ltlt count ltlt files.
}
} // write the last batch
if (count % 1000 ! 0) {
txn_image-gtCommit()
txn_label-gtCommit()
LOG(INFO) ltlt Processed ltlt count ltlt files.
}上述方式使用了二个data层,编译之后,使用如下方式生成:
Buildx64Releasegtconvert_imageset_multi_label.exe ./ train.txt data/train_image_lmdb data/train_label_lmdb 4
train.txt文件格式如下:
data/00A03AF5-41C7-4966-8EF3-8B2C90DCF75C_ 1 2 3 6data/00A15FBD-9637-44C5-B2E7-81611263C88C_ 2 5 6 4
网络配置文件需要加入slice层将标签分割开来
layer { name: slice type: Slice bottom: label top: label_1 top: label_2 top: label_3 top: label_4 slice_param { axis: 1 slice_point: 1 slice_point: 2 slice_point: 3 }}
也可以通过python直接生成lmdb格式,其方式如下:
# -*- coding: utf-8 -*-Created on Sat Dec 24 20:57:28 2016
@author: zhoulyimport lmdbfrom skimage import ioimport numpy as np
import syscaffe_root (0, caffe_root /python)import caffeimport cv2root ../../file_inputopen(root data/train.txt,r)
in_image_(root examples/99/train_image_lmdb, map_sizeint(1e12))
in_label_(root examples/99/train_label_lmdb, map_sizeint(1e12))
in_image_txn in_image_(writeTrue)
in_label_txn in_label_(writeTrue)for in_idx, in_ in enumerate(file_input):
content in_.strip()
content content.split( )
im_file root data/verification/ content[0] try:
im (im_file) except: print -------------------------, im_file continue
im im[:,:, 3]
im (im, (224, 224), _LINEAR)
data ((3, 224, 224), np.uint8)
data[0, :, :] im[:, :]
data[1, :, :] im[:, :]
data[2, :, :] im[:, :]
im_dat _to_datum(data)
in_image_txn.put({:0gt10d}.format(in_idx), im_()) print data train: {} [{}].format(content[0], in_idx 1) del im_file, im, im_dat, data
target_label ((4, 1, 1))
target_label[0, 0, 0] int(content[1])
target_label[1, 0, 0] int(content[2])
target_label[2, 0, 0] int(content[3])
target_label[3, 0, 0] int(content[4])
label_data _to_datum(target_label)
in_label_txn.put({:0gt10d}.format(in_idx), label_()) del target_label, label_data
in_image_()
in_label_()
in_image_()
in_label_()
file_()