计算速度优化,摄像头读取逻辑改变,分类器更新。
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -4,6 +4,7 @@ build
|
|||||||
Mark
|
Mark
|
||||||
armor_box_photo
|
armor_box_photo
|
||||||
tools/TrainCNN/.idea
|
tools/TrainCNN/.idea
|
||||||
|
tools/TrainCNN/model
|
||||||
tools/TrainCNN/__pycache__
|
tools/TrainCNN/__pycache__
|
||||||
others/include/config/config.h
|
others/include/config/config.h
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|||||||
@@ -51,10 +51,11 @@ extern std::map<string, int> prior_red;
|
|||||||
class LightBlob {
|
class LightBlob {
|
||||||
public:
|
public:
|
||||||
cv::RotatedRect rect; //灯条位置
|
cv::RotatedRect rect; //灯条位置
|
||||||
|
double areaRatio;
|
||||||
double length; //灯条长度
|
double length; //灯条长度
|
||||||
uint8_t blob_color; //灯条颜色
|
uint8_t blob_color; //灯条颜色
|
||||||
|
|
||||||
LightBlob(cv::RotatedRect &r, uint8_t color) : rect(r), blob_color(color) {
|
LightBlob(cv::RotatedRect &r, double ratio, uint8_t color) : rect(r), areaRatio(ratio), blob_color(color) {
|
||||||
length = max(rect.size.height, rect.size.width);
|
length = max(rect.size.height, rect.size.width);
|
||||||
};
|
};
|
||||||
LightBlob() = default;
|
LightBlob() = default;
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ class Classifier {
|
|||||||
private:
|
private:
|
||||||
bool state;
|
bool state;
|
||||||
|
|
||||||
vector<vector<MatrixXd>> conv1_w, conv2_w;
|
vector<vector<MatrixXd>> conv1_w, conv2_w, conv3_w;
|
||||||
vector<double> conv1_b, conv2_b;
|
vector<double> conv1_b, conv2_b, conv3_b;
|
||||||
MatrixXd fc1_w, fc2_w;
|
MatrixXd fc1_w, fc2_w;
|
||||||
VectorXd fc1_b, fc2_b;
|
VectorXd fc1_b, fc2_b;
|
||||||
|
|
||||||
@@ -30,8 +30,10 @@ private:
|
|||||||
|
|
||||||
MatrixXd softmax(const MatrixXd &input);
|
MatrixXd softmax(const MatrixXd &input);
|
||||||
MatrixXd relu(const MatrixXd &input);
|
MatrixXd relu(const MatrixXd &input);
|
||||||
|
MatrixXd leaky_relu(const MatrixXd &input, float alpha);
|
||||||
vector<vector<MatrixXd>> apply_bias(const vector<vector<MatrixXd>> &input, const vector<double> &bias);
|
vector<vector<MatrixXd>> apply_bias(const vector<vector<MatrixXd>> &input, const vector<double> &bias);
|
||||||
vector<vector<MatrixXd>> relu(const vector<vector<MatrixXd>> &input);
|
vector<vector<MatrixXd>> relu(const vector<vector<MatrixXd>> &input);
|
||||||
|
vector<vector<MatrixXd>> leaky_relu(const vector<vector<MatrixXd>> &input, float alpha);
|
||||||
vector<vector<MatrixXd>> max_pool(const vector<vector<MatrixXd>> &input, int size);
|
vector<vector<MatrixXd>> max_pool(const vector<vector<MatrixXd>> &input, int size);
|
||||||
vector<vector<MatrixXd>> mean_pool(const vector<vector<MatrixXd>> &input, int size);
|
vector<vector<MatrixXd>> mean_pool(const vector<vector<MatrixXd>> &input, int size);
|
||||||
vector<vector<MatrixXd>> pand(const vector<vector<MatrixXd>> &input, int val);
|
vector<vector<MatrixXd>> pand(const vector<vector<MatrixXd>> &input, int val);
|
||||||
|
|||||||
@@ -3,12 +3,9 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include <armor_finder/armor_finder.h>
|
#include <armor_finder/armor_finder.h>
|
||||||
|
#include <additions/additions.h>
|
||||||
#include <log.h>
|
#include <log.h>
|
||||||
|
|
||||||
static double getTimeIntervalms(const timeval& now, const timeval &last){
|
|
||||||
return (now.tv_sec-last.tv_sec)*1000.0 + (now.tv_usec-last.tv_usec)/1000.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ArmorFinder::antiTop() {
|
void ArmorFinder::antiTop() {
|
||||||
static double top_periodms = 0;
|
static double top_periodms = 0;
|
||||||
static double last_top_periodms = 0;
|
static double last_top_periodms = 0;
|
||||||
|
|||||||
@@ -58,8 +58,8 @@ ArmorFinder::ArmorFinder(uint8_t &color, Serial &u, const string ¶s_folder,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ArmorFinder::run(cv::Mat &src) {
|
void ArmorFinder::run(cv::Mat &src) {
|
||||||
// stateSearchingTarget(src); // for debug
|
stateSearchingTarget(src); // for debug
|
||||||
// goto end;
|
goto end;
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case SEARCHING_STATE:
|
case SEARCHING_STATE:
|
||||||
if (stateSearchingTarget(src)) {
|
if (stateSearchingTarget(src)) {
|
||||||
|
|||||||
@@ -162,6 +162,12 @@ MatrixXd Classifier::relu(const MatrixXd &input){
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MatrixXd Classifier::leaky_relu(const MatrixXd &input, float alpha){
|
||||||
|
return input.unaryExpr([&](double val){
|
||||||
|
return (val>0)?(val):(alpha*val);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
vector<vector<MatrixXd>> Classifier::relu(const vector<vector<MatrixXd>> &input){
|
vector<vector<MatrixXd>> Classifier::relu(const vector<vector<MatrixXd>> &input){
|
||||||
vector<vector<MatrixXd>> result;
|
vector<vector<MatrixXd>> result;
|
||||||
for(int samples=0; samples<input.size(); samples++){
|
for(int samples=0; samples<input.size(); samples++){
|
||||||
@@ -174,6 +180,18 @@ vector<vector<MatrixXd>> Classifier::relu(const vector<vector<MatrixXd>> &input)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vector<vector<MatrixXd>> Classifier::leaky_relu(const vector<vector<MatrixXd>> &input, float alpha){
|
||||||
|
vector<vector<MatrixXd>> result;
|
||||||
|
for(int samples=0; samples<input.size(); samples++){
|
||||||
|
vector<MatrixXd> sub;
|
||||||
|
for(int channels=0; channels<input[0].size(); channels++){
|
||||||
|
sub.emplace_back(leaky_relu(input[samples][channels], alpha));
|
||||||
|
}
|
||||||
|
result.emplace_back(sub);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
vector<vector<MatrixXd>> Classifier::pand(const vector<vector<MatrixXd>> &input, int val){
|
vector<vector<MatrixXd>> Classifier::pand(const vector<vector<MatrixXd>> &input, int val){
|
||||||
vector<vector<MatrixXd>> result;
|
vector<vector<MatrixXd>> result;
|
||||||
for(int sample=0; sample<input.size(); sample++){
|
for(int sample=0; sample<input.size(); sample++){
|
||||||
@@ -254,6 +272,8 @@ Classifier::Classifier(const string &folder) : state(true){
|
|||||||
conv1_b = load_conv_b(folder+"conv1_b");
|
conv1_b = load_conv_b(folder+"conv1_b");
|
||||||
conv2_w = load_conv_w(folder+"conv2_w");
|
conv2_w = load_conv_w(folder+"conv2_w");
|
||||||
conv2_b = load_conv_b(folder+"conv2_b");
|
conv2_b = load_conv_b(folder+"conv2_b");
|
||||||
|
conv3_w = load_conv_w(folder+"conv3_w");
|
||||||
|
conv3_b = load_conv_b(folder+"conv3_b");
|
||||||
fc1_w = load_fc_w(folder+"fc1_w");
|
fc1_w = load_fc_w(folder+"fc1_w");
|
||||||
fc1_b = load_fc_b(folder+"fc1_b");
|
fc1_b = load_fc_b(folder+"fc1_b");
|
||||||
fc2_w = load_fc_w(folder+"fc2_w");
|
fc2_w = load_fc_w(folder+"fc2_w");
|
||||||
@@ -273,7 +293,8 @@ MatrixXd Classifier::calculate(const vector<vector<MatrixXd>> &input) {
|
|||||||
vector<vector<MatrixXd>> pool1_result = mean_pool(conv1_result, 2);
|
vector<vector<MatrixXd>> pool1_result = mean_pool(conv1_result, 2);
|
||||||
vector<vector<MatrixXd>> conv2_result = relu(apply_bias(conv2(conv2_w, pool1_result), conv2_b));
|
vector<vector<MatrixXd>> conv2_result = relu(apply_bias(conv2(conv2_w, pool1_result), conv2_b));
|
||||||
vector<vector<MatrixXd>> pool2_result = mean_pool(conv2_result, 2);
|
vector<vector<MatrixXd>> pool2_result = mean_pool(conv2_result, 2);
|
||||||
MatrixXd flattened = flatten(pool2_result);
|
vector<vector<MatrixXd>> conv3_result = relu(apply_bias(conv2(conv3_w, pool2_result), conv3_b));
|
||||||
|
MatrixXd flattened = flatten(conv3_result);
|
||||||
MatrixXd y1 = fc1_w * flattened;
|
MatrixXd y1 = fc1_w * flattened;
|
||||||
y1.colwise() += fc1_b;
|
y1.colwise() += fc1_b;
|
||||||
MatrixXd fc1 = relu(y1);
|
MatrixXd fc1 = relu(y1);
|
||||||
@@ -303,7 +324,7 @@ int Classifier::operator()(const cv::Mat &image) {
|
|||||||
// cout << result << "==============" <<endl;
|
// cout << result << "==============" <<endl;
|
||||||
MatrixXd::Index minRow, minCol;
|
MatrixXd::Index minRow, minCol;
|
||||||
result.maxCoeff(&minRow, &minCol);
|
result.maxCoeff(&minRow, &minCol);
|
||||||
if(result(minRow, minCol) > 0.9){
|
if(result(minRow, minCol) > 0.90){
|
||||||
return minRow;
|
return minRow;
|
||||||
}else{
|
}else{
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include <show_images/show_images.h>
|
#include <show_images/show_images.h>
|
||||||
#include <options/options.h>
|
#include <options/options.h>
|
||||||
#include <opencv2/highgui.hpp>
|
#include <opencv2/highgui.hpp>
|
||||||
|
#define DO_NOT_CNT_TIME
|
||||||
#include <log.h>
|
#include <log.h>
|
||||||
|
|
||||||
|
|
||||||
@@ -27,7 +28,7 @@ static bool lengthJudge(const LightBlob &light_blob_i, const LightBlob &light_bl
|
|||||||
double side_length;
|
double side_length;
|
||||||
cv::Point2f centers = light_blob_i.rect.center - light_blob_j.rect.center;
|
cv::Point2f centers = light_blob_i.rect.center - light_blob_j.rect.center;
|
||||||
side_length = sqrt(centers.ddot(centers));
|
side_length = sqrt(centers.ddot(centers));
|
||||||
return (side_length / light_blob_i.length < 8 && side_length / light_blob_i.length > 0.5);
|
return (side_length / light_blob_i.length < 10 && side_length / light_blob_i.length > 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool lengthRatioJudge(const LightBlob &light_blob_i, const LightBlob &light_blob_j) {
|
static bool lengthRatioJudge(const LightBlob &light_blob_i, const LightBlob &light_blob_j) {
|
||||||
@@ -99,6 +100,7 @@ bool matchArmorBoxes(const cv::Mat &src, const LightBlobs &light_blobs, ArmorBox
|
|||||||
if (min_x < 0 || max_x > src.cols || min_y < 0 || max_y > src.rows) {
|
if (min_x < 0 || max_x > src.cols || min_y < 0 || max_y > src.rows) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if((max_x-min_x)/(max_y-min_y) < 0.8) continue;
|
||||||
LightBlobs pair_blobs = {light_blobs.at(i), light_blobs.at(j)};
|
LightBlobs pair_blobs = {light_blobs.at(i), light_blobs.at(j)};
|
||||||
armor_boxes.emplace_back(
|
armor_boxes.emplace_back(
|
||||||
cv::Rect2d(min_x, min_y, max_x - min_x, max_y - min_y),
|
cv::Rect2d(min_x, min_y, max_x - min_x, max_y - min_y),
|
||||||
@@ -116,31 +118,35 @@ bool ArmorFinder::findArmorBox(const cv::Mat &src, ArmorBox &box) {
|
|||||||
|
|
||||||
box.rect = cv::Rect2d(0, 0, 0, 0);
|
box.rect = cv::Rect2d(0, 0, 0, 0);
|
||||||
box.id = -1;
|
box.id = -1;
|
||||||
|
CNT_TIME("blob", {
|
||||||
if (!findLightBlobs(src, light_blobs)) {
|
if (!findLightBlobs(src, light_blobs)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
});
|
||||||
if (show_light_blobs && src.size() == cv::Size(640, 480)) {
|
if (show_light_blobs && src.size() == cv::Size(640, 480)) {
|
||||||
showLightBlobs("light_blobs", src, light_blobs);
|
showLightBlobs("light_blobs", src, light_blobs);
|
||||||
cv::waitKey(1);
|
cv::waitKey(1);
|
||||||
}
|
}
|
||||||
|
CNT_TIME("boxes",{
|
||||||
if (!matchArmorBoxes(src, light_blobs, armor_boxes, enemy_color)) {
|
if (!matchArmorBoxes(src, light_blobs, armor_boxes, enemy_color)) {
|
||||||
// cout << "Box fail!" << endl;
|
// cout << "Box fail!" << endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
});
|
||||||
if (show_armor_boxes && src.size() == cv::Size(640, 480)) {
|
if (show_armor_boxes && src.size() == cv::Size(640, 480)) {
|
||||||
showArmorBoxes("boxes", src, armor_boxes);
|
showArmorBoxes("boxes", src, armor_boxes);
|
||||||
cv::waitKey(1);
|
cv::waitKey(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (classifier && use_classifier) {
|
if (classifier && use_classifier) {
|
||||||
|
CNT_TIME("classify: %d", {
|
||||||
for (auto &armor_box : armor_boxes) {
|
for (auto &armor_box : armor_boxes) {
|
||||||
cv::Mat roi = src(armor_box.rect).clone();
|
cv::Mat roi = src(armor_box.rect).clone();
|
||||||
cv::resize(roi, roi, cv::Size(48, 36));
|
cv::resize(roi, roi, cv::Size(48, 36));
|
||||||
int c = classifier(roi);
|
int c = classifier(roi);
|
||||||
armor_box.id = c;
|
armor_box.id = c;
|
||||||
}
|
}
|
||||||
|
}, armor_boxes.size());
|
||||||
sort(armor_boxes.begin(), armor_boxes.end());
|
sort(armor_boxes.begin(), armor_boxes.end());
|
||||||
if(armor_boxes[0].id != 0){
|
if(armor_boxes[0].id != 0){
|
||||||
box = armor_boxes[0];
|
box = armor_boxes[0];
|
||||||
|
|||||||
@@ -95,6 +95,11 @@ static double get_blob_color_opt(const cv::Mat &src, cv::RotatedRect blobPos) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool isSameBlob(LightBlob blob1, LightBlob blob2) {
|
||||||
|
auto dist = blob1.rect.center - blob2.rect.center;
|
||||||
|
return (dist.x * dist.x + dist.y * dist.y) < 9;
|
||||||
|
}
|
||||||
|
|
||||||
static void imagePreProcess(cv::Mat &src) {
|
static void imagePreProcess(cv::Mat &src) {
|
||||||
static cv::Mat kernel_erode = getStructuringElement(cv::MORPH_RECT, cv::Size(3, 5));
|
static cv::Mat kernel_erode = getStructuringElement(cv::MORPH_RECT, cv::Size(3, 5));
|
||||||
erode(src, src, kernel_erode);
|
erode(src, src, kernel_erode);
|
||||||
@@ -126,7 +131,6 @@ bool ArmorFinder::findLightBlobs(const cv::Mat &src, LightBlobs &light_blobs) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cv::threshold(color_channel, src_bin_light, 200, 255, CV_THRESH_BINARY); // 二值化对应通道
|
cv::threshold(color_channel, src_bin_light, 200, 255, CV_THRESH_BINARY); // 二值化对应通道
|
||||||
if (src_bin_light.empty()) return false;
|
if (src_bin_light.empty()) return false;
|
||||||
imagePreProcess(src_bin_light); // 开闭运算
|
imagePreProcess(src_bin_light); // 开闭运算
|
||||||
@@ -141,19 +145,55 @@ bool ArmorFinder::findLightBlobs(const cv::Mat &src, LightBlobs &light_blobs) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::vector<cv::Point>> light_contours_light, light_contours_dim;
|
std::vector<std::vector<cv::Point>> light_contours_light, light_contours_dim;
|
||||||
cv::findContours(src_bin_light, light_contours_light, CV_RETR_LIST, CV_CHAIN_APPROX_NONE);
|
LightBlobs light_blobs_light, light_blobs_dim;
|
||||||
cv::findContours(src_bin_dim, light_contours_dim, CV_RETR_LIST, CV_CHAIN_APPROX_NONE);
|
std::vector<cv::Vec4i> hierarchy_light, hierarchy_dim;
|
||||||
for (auto &light_contour : light_contours_light) {
|
cv::findContours(src_bin_light, light_contours_light, hierarchy_light, CV_RETR_CCOMP, CV_CHAIN_APPROX_NONE);
|
||||||
cv::RotatedRect rect = cv::minAreaRect(light_contour);
|
cv::findContours(src_bin_dim, light_contours_dim, hierarchy_dim, CV_RETR_CCOMP, CV_CHAIN_APPROX_NONE);
|
||||||
if (isValidLightBlob(light_contour, rect)) {
|
for (int i = 0; i < light_contours_light.size(); i++) {
|
||||||
light_blobs.emplace_back(rect, get_blob_color(src, rect));
|
if (hierarchy_light[i][2] == -1) {
|
||||||
|
cv::RotatedRect rect = cv::minAreaRect(light_contours_light[i]);
|
||||||
|
if (isValidLightBlob(light_contours_light[i], rect)) {
|
||||||
|
light_blobs_light.emplace_back(
|
||||||
|
rect, areaRatio(light_contours_light[i], rect), get_blob_color(src, rect)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (auto &light_contour : light_contours_dim) {
|
|
||||||
cv::RotatedRect rect = cv::minAreaRect(light_contour);
|
|
||||||
if (isValidLightBlob(light_contour, rect)) {
|
|
||||||
light_blobs.emplace_back(rect, get_blob_color(src, rect));
|
|
||||||
}
|
}
|
||||||
|
for (int i = 0; i < light_contours_dim.size(); i++) {
|
||||||
|
if (hierarchy_dim[i][2] == -1) {
|
||||||
|
cv::RotatedRect rect = cv::minAreaRect(light_contours_dim[i]);
|
||||||
|
if (isValidLightBlob(light_contours_dim[i], rect)) {
|
||||||
|
light_blobs_dim.emplace_back(
|
||||||
|
rect, areaRatio(light_contours_dim[i], rect), get_blob_color(src, rect)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
vector<int> light_to_remove, dim_to_remove;
|
||||||
|
for (int l = 0; l != light_blobs_light.size(); l++) {
|
||||||
|
for (int d = 0; d != light_blobs_dim.size(); d++) {
|
||||||
|
if (isSameBlob(light_blobs_light[l], light_blobs_dim[d])) {
|
||||||
|
if (light_blobs_light[l].areaRatio > light_blobs_dim[d].areaRatio) {
|
||||||
|
dim_to_remove.emplace_back(d);
|
||||||
|
} else {
|
||||||
|
light_to_remove.emplace_back(l);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sort(light_to_remove.begin(), light_to_remove.end(), [](int a, int b) { return a > b; });
|
||||||
|
sort(dim_to_remove.begin(), dim_to_remove.end(), [](int a, int b) { return a > b; });
|
||||||
|
for (auto x : light_to_remove) {
|
||||||
|
light_blobs_light.erase(light_blobs_light.begin() + x);
|
||||||
|
}
|
||||||
|
for (auto x : dim_to_remove) {
|
||||||
|
light_blobs_dim.erase(light_blobs_dim.begin() + x);
|
||||||
|
}
|
||||||
|
for (const auto &light : light_blobs_light) {
|
||||||
|
light_blobs.emplace_back(light);
|
||||||
|
}
|
||||||
|
for (const auto &dim : light_blobs_dim) {
|
||||||
|
light_blobs.emplace_back(dim);
|
||||||
}
|
}
|
||||||
return light_blobs.size() >= 2;
|
return light_blobs.size() >= 2;
|
||||||
}
|
}
|
||||||
|
|||||||
24
main.cpp
24
main.cpp
@@ -20,7 +20,7 @@
|
|||||||
#include <additions/additions.h>
|
#include <additions/additions.h>
|
||||||
#include <config/setconfig.h>
|
#include <config/setconfig.h>
|
||||||
|
|
||||||
#define DO_NOT_CNT_TIME
|
//#define DO_NOT_CNT_TIME
|
||||||
|
|
||||||
#include <log.h>
|
#include <log.h>
|
||||||
|
|
||||||
@@ -63,8 +63,8 @@ int main(int argc, char *argv[]) {
|
|||||||
while (true) {
|
while (true) {
|
||||||
// 打开视频源
|
// 打开视频源
|
||||||
if (from_camera) {
|
if (from_camera) {
|
||||||
video_gimbal = new CameraWrapper(ARMOR_CAMERA_GAIN, 0/*, "armor"*/);
|
video_gimbal = new CameraWrapper(ARMOR_CAMERA_GAIN, 2/*, "armor"*/);
|
||||||
video_chassis = new CameraWrapper(ENERGY_CAMERA_GAIN, 0/*, "energy"*/);
|
video_chassis = new CameraWrapper(ENERGY_CAMERA_GAIN, 2/*, "energy"*/);
|
||||||
} else {
|
} else {
|
||||||
video_gimbal = new VideoWrapper("/home/sun/项目/energy_video/7.27.avi");
|
video_gimbal = new VideoWrapper("/home/sun/项目/energy_video/7.27.avi");
|
||||||
video_chassis = new VideoWrapper("/home/sun/项目/energy_video/7.27.avi");
|
video_chassis = new VideoWrapper("/home/sun/项目/energy_video/7.27.avi");
|
||||||
@@ -93,14 +93,14 @@ int main(int argc, char *argv[]) {
|
|||||||
bool ok = true;
|
bool ok = true;
|
||||||
cout << "start running" << endl;
|
cout << "start running" << endl;
|
||||||
do {
|
do {
|
||||||
// CNT_TIME("Total", {
|
CNT_TIME("Total", {
|
||||||
if (mcuData.state == BIG_ENERGY_STATE) {//大能量机关模式
|
if (mcuData.state == BIG_ENERGY_STATE) {//大能量机关模式
|
||||||
if (last_state != BIG_ENERGY_STATE) {//若上一帧不是大能量机关模式,即刚往完成切换,则需要初始化
|
if (last_state != BIG_ENERGY_STATE) {//若上一帧不是大能量机关模式,即刚往完成切换,则需要初始化
|
||||||
LOGM(STR_CTR(WORD_BLUE, "Start Big Energy!"));
|
LOGM(STR_CTR(WORD_BLUE, "Start Big Energy!"));
|
||||||
destroyAllWindows();
|
destroyAllWindows();
|
||||||
if (from_camera) {
|
if (from_camera) {
|
||||||
delete video_gimbal;
|
delete video_gimbal;
|
||||||
video_gimbal = new CameraWrapper(ENERGY_CAMERA_GAIN, 0/*, "armor"*/);
|
video_gimbal = new CameraWrapper(ENERGY_CAMERA_GAIN, 2/*, "armor"*/);
|
||||||
if (video_gimbal->init()) {
|
if (video_gimbal->init()) {
|
||||||
LOGM("video_gimbal source initialization successfully.");
|
LOGM("video_gimbal source initialization successfully.");
|
||||||
} else {
|
} else {
|
||||||
@@ -130,7 +130,7 @@ int main(int argc, char *argv[]) {
|
|||||||
destroyAllWindows();
|
destroyAllWindows();
|
||||||
if (from_camera) {
|
if (from_camera) {
|
||||||
delete video_gimbal;
|
delete video_gimbal;
|
||||||
video_gimbal = new CameraWrapper(ENERGY_CAMERA_GAIN, 0/*, "armor"*/);
|
video_gimbal = new CameraWrapper(ENERGY_CAMERA_GAIN, 2/*, "armor"*/);
|
||||||
if (video_gimbal->init()) {
|
if (video_gimbal->init()) {
|
||||||
LOGM("video_gimbal source initialization successfully.");
|
LOGM("video_gimbal source initialization successfully.");
|
||||||
} else {
|
} else {
|
||||||
@@ -154,7 +154,7 @@ int main(int argc, char *argv[]) {
|
|||||||
destroyAllWindows();
|
destroyAllWindows();
|
||||||
if (from_camera) {
|
if (from_camera) {
|
||||||
delete video_gimbal;
|
delete video_gimbal;
|
||||||
video_gimbal = new CameraWrapper(ARMOR_CAMERA_GAIN, 0/*, "armor"*/);
|
video_gimbal = new CameraWrapper(ARMOR_CAMERA_GAIN, 2/*, "armor"*/);
|
||||||
if (video_gimbal->init()) {
|
if (video_gimbal->init()) {
|
||||||
LOGM("video_gimbal source initialization successfully.");
|
LOGM("video_gimbal source initialization successfully.");
|
||||||
} else {
|
} else {
|
||||||
@@ -163,19 +163,23 @@ int main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
last_state = mcuData.state;
|
last_state = mcuData.state;
|
||||||
ok = checkReconnect(video_gimbal->read(gimbal_src));
|
CNT_TIME(STR_CTR(WORD_GREEN, "read img"), {
|
||||||
|
if(!checkReconnect(video_gimbal->read(gimbal_src))) continue;
|
||||||
|
});
|
||||||
#ifdef GIMBAL_FLIP_MODE
|
#ifdef GIMBAL_FLIP_MODE
|
||||||
flip(gimbal_src, gimbal_src, GIMBAL_FLIP_MODE);
|
flip(gimbal_src, gimbal_src, GIMBAL_FLIP_MODE);
|
||||||
#endif
|
#endif
|
||||||
|
// CNT_TIME("something whatever", {
|
||||||
if (!from_camera) extract(gimbal_src);
|
if (!from_camera) extract(gimbal_src);
|
||||||
if (save_video) saveVideos(gimbal_src);
|
if (save_video) saveVideos(gimbal_src);
|
||||||
if (show_origin) showOrigin(gimbal_src);
|
if (show_origin) showOrigin(gimbal_src);
|
||||||
CNT_TIME("Armor Time", {
|
// });
|
||||||
|
CNT_TIME(STR_CTR(WORD_CYAN, "Armor Time"), {
|
||||||
armorFinder.run(gimbal_src);
|
armorFinder.run(gimbal_src);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// cv::waitKey(0);
|
// cv::waitKey(0);
|
||||||
// });
|
});
|
||||||
} while (ok);
|
} while (ok);
|
||||||
delete video_gimbal;
|
delete video_gimbal;
|
||||||
video_gimbal = nullptr;
|
video_gimbal = nullptr;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#define _ADDITIONS_H_
|
#define _ADDITIONS_H_
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <sys/time.h>
|
||||||
#include <serial/serial.h>
|
#include <serial/serial.h>
|
||||||
|
|
||||||
struct mcu_data{
|
struct mcu_data{
|
||||||
@@ -30,5 +31,6 @@ void showOrigin(const cv::Mat &gimbal_src, const cv::Mat &chassis_src);
|
|||||||
void showOrigin(const cv::Mat &gimbal_src);
|
void showOrigin(const cv::Mat &gimbal_src);
|
||||||
void extract(cv::Mat &gimbal_src, cv::Mat &chassis_src);
|
void extract(cv::Mat &gimbal_src, cv::Mat &chassis_src);
|
||||||
void extract(cv::Mat &gimbal_src);
|
void extract(cv::Mat &gimbal_src);
|
||||||
|
double getTimeIntervalms(const timeval& now, const timeval &last);
|
||||||
|
|
||||||
#endif /* _ADDITIONS_H_ */
|
#endif /* _ADDITIONS_H_ */
|
||||||
|
|||||||
@@ -9,11 +9,12 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <thread>
|
||||||
#include "opencv2/core/core.hpp"
|
#include "opencv2/core/core.hpp"
|
||||||
#include "opencv2/highgui/highgui.hpp"
|
#include "opencv2/highgui/highgui.hpp"
|
||||||
#include <opencv2/imgproc/imgproc.hpp>
|
#include <opencv2/imgproc/imgproc.hpp>
|
||||||
|
|
||||||
#include "camera/wrapper_head.h"
|
#include "camera/wrapper_head.h"
|
||||||
|
|
||||||
#ifdef Windows
|
#ifdef Windows
|
||||||
#include "camera/CameraApi.h"
|
#include "camera/CameraApi.h"
|
||||||
#elif defined(Linux) || defined(Darwin)
|
#elif defined(Linux) || defined(Darwin)
|
||||||
@@ -21,10 +22,13 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
class CameraWrapper: public WrapperHead {
|
class CameraWrapper: public WrapperHead {
|
||||||
|
friend void cameraCallback(CameraHandle hCamera, BYTE *pFrameBuffer, tSdkFrameHead* pFrameHead,PVOID pContext);
|
||||||
private:
|
private:
|
||||||
const std::string name;
|
const std::string name;
|
||||||
int mode;
|
int mode;
|
||||||
|
|
||||||
|
bool init_done;
|
||||||
|
|
||||||
unsigned char* rgb_buffer;
|
unsigned char* rgb_buffer;
|
||||||
int camera_cnts;
|
int camera_cnts;
|
||||||
int camera_status;
|
int camera_status;
|
||||||
@@ -38,6 +42,11 @@ private:
|
|||||||
IplImage* iplImage;
|
IplImage* iplImage;
|
||||||
int channel;
|
int channel;
|
||||||
|
|
||||||
|
cv::Mat src_queue[2];
|
||||||
|
volatile int qhead;
|
||||||
|
volatile int qtail;
|
||||||
|
|
||||||
|
std::thread *readThread;
|
||||||
public:
|
public:
|
||||||
int gain;
|
int gain;
|
||||||
|
|
||||||
@@ -48,6 +57,8 @@ public:
|
|||||||
bool read(cv::Mat& src) final;
|
bool read(cv::Mat& src) final;
|
||||||
bool readRaw(cv::Mat& src);
|
bool readRaw(cv::Mat& src);
|
||||||
bool readProcessed(cv::Mat& src);
|
bool readProcessed(cv::Mat& src);
|
||||||
|
bool readCallback(cv::Mat& src);
|
||||||
|
bool readWithThread(cv::Mat &src);
|
||||||
bool changeBrightness(int brightness);
|
bool changeBrightness(int brightness);
|
||||||
// bool once
|
// bool once
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -146,7 +146,7 @@
|
|||||||
gettimeofday(&ts, NULL); \
|
gettimeofday(&ts, NULL); \
|
||||||
codes; \
|
codes; \
|
||||||
gettimeofday(&te, NULL); \
|
gettimeofday(&te, NULL); \
|
||||||
LOGM(tag": %.1lfms", (te.tv_sec-ts.tv_sec)*1000.0+(te.tv_usec-ts.tv_usec)/1000.0); \
|
LOGM(tag": %.1lfms", ##__VA_ARGS__, (te.tv_sec-ts.tv_sec)*1000.0+(te.tv_usec-ts.tv_usec)/1000.0); \
|
||||||
}while (0)
|
}while (0)
|
||||||
#else
|
#else
|
||||||
#warning "Unsupport plantform for CNT_TIME"
|
#warning "Unsupport plantform for CNT_TIME"
|
||||||
|
|||||||
@@ -169,3 +169,7 @@ void extract(cv::Mat &gimbal_src) {//图像预处理,将视频切成640×480
|
|||||||
gimbal_src = gimbal_src(Rect(0, (width - 480) / 2, 640, 480));
|
gimbal_src = gimbal_src(Rect(0, (width - 480) / 2, 640, 480));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double getTimeIntervalms(const timeval& now, const timeval &last){
|
||||||
|
return (now.tv_sec-last.tv_sec)*1000.0 + (now.tv_usec-last.tv_usec)/1000.0;
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include <camera/camera_wrapper.h>
|
#include <camera/camera_wrapper.h>
|
||||||
#include <log.h>
|
#include <log.h>
|
||||||
|
#include <additions/additions.h>
|
||||||
#include <options/options.h>
|
#include <options/options.h>
|
||||||
#include <config/setconfig.h>
|
#include <config/setconfig.h>
|
||||||
|
|
||||||
@@ -15,15 +16,33 @@ using namespace cv;
|
|||||||
|
|
||||||
CameraWrapper::CameraWrapper(int gain, int camera_mode, const std::string &n) :
|
CameraWrapper::CameraWrapper(int gain, int camera_mode, const std::string &n) :
|
||||||
name(n),
|
name(n),
|
||||||
|
init_done(false),
|
||||||
mode(camera_mode),
|
mode(camera_mode),
|
||||||
camera_cnts(2),
|
camera_cnts(2),
|
||||||
camera_status(-1),
|
camera_status(-1),
|
||||||
iplImage(nullptr),
|
iplImage(nullptr),
|
||||||
rgb_buffer(nullptr),
|
rgb_buffer(nullptr),
|
||||||
channel(3),
|
channel(3),
|
||||||
gain(gain){
|
gain(gain),
|
||||||
|
qhead(0),
|
||||||
|
qtail(0),
|
||||||
|
readThread(nullptr){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cameraCallback(CameraHandle hCamera, BYTE *pFrameBuffer, tSdkFrameHead* pFrameHead,PVOID pContext){
|
||||||
|
CameraWrapper *c = (CameraWrapper*)pContext;
|
||||||
|
CameraImageProcess(hCamera, pFrameBuffer, c->rgb_buffer, pFrameHead);
|
||||||
|
auto iplImage = cvCreateImageHeader(cvSize(pFrameHead->iWidth, pFrameHead->iHeight), IPL_DEPTH_8U, c->channel);
|
||||||
|
cvSetData(iplImage, c->rgb_buffer, pFrameHead->iWidth * c->channel); //此处只是设置指针,无图像块数据拷贝,不需担心转换效率
|
||||||
|
c->src_queue[c->qhead] = cv::cvarrToMat(iplImage).clone();
|
||||||
|
if((c->qhead+1)%2 == c->qtail){
|
||||||
|
c->qhead = (c->qhead+1)%2;
|
||||||
|
c->qtail = (c->qtail+1)%2;
|
||||||
|
} else {
|
||||||
|
c->qhead = (c->qhead+1)%2;
|
||||||
|
}
|
||||||
|
// LOGM("Get image, [%d %d]", c->qhead, c->qtail);
|
||||||
|
}
|
||||||
|
|
||||||
bool CameraWrapper::init() {
|
bool CameraWrapper::init() {
|
||||||
CameraSdkInit(1);
|
CameraSdkInit(1);
|
||||||
@@ -76,6 +95,8 @@ bool CameraWrapper::init() {
|
|||||||
}
|
}
|
||||||
LOGM("successfully loaded %s!", filepath);
|
LOGM("successfully loaded %s!", filepath);
|
||||||
#elif defined(Linux)
|
#elif defined(Linux)
|
||||||
|
CameraReadParameterFromFile(h_camera, PROJECT_DIR"/others/MV-UB31-Group0.config");
|
||||||
|
CameraLoadParameter(h_camera, PARAMETER_TEAM_A);
|
||||||
CameraSetAeState(h_camera, false);
|
CameraSetAeState(h_camera, false);
|
||||||
CameraSetExposureTime(h_camera, CAMERA_EXPOSURE * 1000);
|
CameraSetExposureTime(h_camera, CAMERA_EXPOSURE * 1000);
|
||||||
#ifndef WITH_TIME_BASED_CAMERA_GAIN
|
#ifndef WITH_TIME_BASED_CAMERA_GAIN
|
||||||
@@ -106,14 +127,13 @@ bool CameraWrapper::init() {
|
|||||||
}
|
}
|
||||||
CameraSetAnalogGain(h_camera, gain);
|
CameraSetAnalogGain(h_camera, gain);
|
||||||
#endif
|
#endif
|
||||||
if (mode == 0) {
|
|
||||||
CameraSetGain(h_camera, CAMERA_RED_GAIN, CAMERA_GREEN_GAIN, CAMERA_BLUE_GAIN);
|
|
||||||
CameraSetLutMode(h_camera, LUTMODE_PRESET);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
double t;
|
double t;
|
||||||
|
int g;
|
||||||
CameraGetExposureTime(h_camera, &t);
|
CameraGetExposureTime(h_camera, &t);
|
||||||
LOGM("Exposure time: %lfms", t / 1000.0);
|
CameraGetAnalogGain(h_camera, &g);
|
||||||
|
LOGM("Exposure time: %lfms, gain:%d", t / 1000.0, g);
|
||||||
/*让SDK进入工作模式,开始接收来自相机发送的图像
|
/*让SDK进入工作模式,开始接收来自相机发送的图像
|
||||||
数据。如果当前相机是触发模式,则需要接收到
|
数据。如果当前相机是触发模式,则需要接收到
|
||||||
触发帧以后才会更新图像。 */
|
触发帧以后才会更新图像。 */
|
||||||
@@ -135,6 +155,10 @@ bool CameraWrapper::init() {
|
|||||||
CameraSetIspOutFormat(h_camera, CAMERA_MEDIA_TYPE_BGR8);
|
CameraSetIspOutFormat(h_camera, CAMERA_MEDIA_TYPE_BGR8);
|
||||||
LOGM("camera %s color ", camera_name);
|
LOGM("camera %s color ", camera_name);
|
||||||
}
|
}
|
||||||
|
if(mode == 2){
|
||||||
|
CameraSetCallbackFunction(h_camera, cameraCallback, this, nullptr);
|
||||||
|
}
|
||||||
|
init_done = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,12 +168,18 @@ bool CameraWrapper::changeBrightness(int brightness) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool CameraWrapper::read(cv::Mat &src) {
|
bool CameraWrapper::read(cv::Mat &src) {
|
||||||
|
if(init_done) {
|
||||||
if (mode == 0)return readProcessed(src);
|
if (mode == 0)return readProcessed(src);
|
||||||
if (mode == 1)return readRaw(src);
|
if (mode == 1)return readRaw(src);
|
||||||
|
if (mode == 2)return readCallback(src);
|
||||||
|
if (mode == 3)return readWithThread(src);
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CameraWrapper::readRaw(cv::Mat &src) {
|
bool CameraWrapper::readRaw(cv::Mat &src) {
|
||||||
if (CameraGetImageBuffer(h_camera, &frame_info, &pby_buffer, 1000) == CAMERA_STATUS_SUCCESS) {
|
if (CameraGetImageBuffer(h_camera, &frame_info, &pby_buffer, 500) == CAMERA_STATUS_SUCCESS) {
|
||||||
if (iplImage) {
|
if (iplImage) {
|
||||||
cvReleaseImageHeader(&iplImage);
|
cvReleaseImageHeader(&iplImage);
|
||||||
}
|
}
|
||||||
@@ -173,7 +203,7 @@ bool CameraWrapper::readRaw(cv::Mat &src) {
|
|||||||
|
|
||||||
bool CameraWrapper::readProcessed(cv::Mat &src) {
|
bool CameraWrapper::readProcessed(cv::Mat &src) {
|
||||||
// cerr << "Get-1" << endl;
|
// cerr << "Get-1" << endl;
|
||||||
if (CameraGetImageBuffer(h_camera, &frame_info, &pby_buffer, 1000) == CAMERA_STATUS_SUCCESS) {
|
if (CameraGetImageBuffer(h_camera, &frame_info, &pby_buffer, 500) == CAMERA_STATUS_SUCCESS) {
|
||||||
CameraImageProcess(h_camera, pby_buffer, rgb_buffer,
|
CameraImageProcess(h_camera, pby_buffer, rgb_buffer,
|
||||||
&frame_info); // this function is super slow, better not to use it.
|
&frame_info); // this function is super slow, better not to use it.
|
||||||
if (iplImage) {
|
if (iplImage) {
|
||||||
@@ -192,9 +222,56 @@ bool CameraWrapper::readProcessed(cv::Mat &src) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CameraWrapper::readCallback(cv::Mat &src) {
|
||||||
|
timeval ts, te;
|
||||||
|
gettimeofday(&ts, NULL);
|
||||||
|
while(qtail==qhead){
|
||||||
|
gettimeofday(&te, NULL);
|
||||||
|
if(getTimeIntervalms(te, ts) > 500){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
src = src_queue[qtail];
|
||||||
|
// cout << src.size << endl;
|
||||||
|
qtail = (qtail+1)%2;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CameraWrapper::readWithThread(cv::Mat &src){
|
||||||
|
if(readThread != nullptr){
|
||||||
|
readThread->join();
|
||||||
|
src = src_queue[qtail];
|
||||||
|
qtail = (qtail+1)%2;
|
||||||
|
delete readThread;
|
||||||
|
readThread = new std::thread([&](){
|
||||||
|
readProcessed(src_queue[qhead]);
|
||||||
|
qhead = (qhead+1)%2;
|
||||||
|
});
|
||||||
|
}else{
|
||||||
|
readThread = new std::thread([&](){
|
||||||
|
readProcessed(src_queue[qhead]);
|
||||||
|
qhead = (qhead+1)%2;
|
||||||
|
});
|
||||||
|
readThread->join();
|
||||||
|
src = src_queue[qtail];
|
||||||
|
qtail = (qtail+1)%2;
|
||||||
|
delete readThread;
|
||||||
|
readThread = new std::thread([&](){
|
||||||
|
readProcessed(src_queue[qhead]);
|
||||||
|
qhead = (qhead+1)%2;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
CameraWrapper::~CameraWrapper() {
|
CameraWrapper::~CameraWrapper() {
|
||||||
CameraUnInit(h_camera);
|
CameraUnInit(h_camera);
|
||||||
//注意,先反初始化后再free
|
//注意,先反初始化后再free
|
||||||
if (rgb_buffer != nullptr)
|
if (rgb_buffer != nullptr)
|
||||||
free(rgb_buffer);
|
free(rgb_buffer);
|
||||||
|
if(readThread != nullptr){
|
||||||
|
readThread->detach();
|
||||||
|
delete readThread;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
print("Preparing...")
|
print("Preparing...")
|
||||||
import tensorflow as tf
|
import tensorflow as tf
|
||||||
|
import os
|
||||||
from tqdm import tqdm
|
from tqdm import tqdm
|
||||||
import generate
|
import generate
|
||||||
import forward
|
import forward
|
||||||
@@ -35,28 +36,22 @@ def save_bias(fp, val):
|
|||||||
print(val[i], file=fp)
|
print(val[i], file=fp)
|
||||||
|
|
||||||
|
|
||||||
def save_para(folder, paras):
|
def save_para(folder, paras, names, info):
|
||||||
with open(folder + "/conv1_w", "w") as fp:
|
os.system("mkdir %s/%s" % (folder, info))
|
||||||
save_kernal(fp, paras[0])
|
for para, name in zip(paras, names):
|
||||||
with open(folder + "/conv1_b", "w") as fp:
|
fp = open("%s/%s/%s" % (folder, info, name), "w")
|
||||||
save_bias(fp, paras[1])
|
if name[-1:] == "b":
|
||||||
with open(folder + "/conv2_w", "w") as fp:
|
save_bias(fp, para)
|
||||||
save_kernal(fp, paras[2])
|
elif name[:2] == "fc":
|
||||||
with open(folder + "/conv2_b", "w") as fp:
|
save_weight_mat(fp, para)
|
||||||
save_bias(fp, paras[3])
|
elif name[:4] == "conv":
|
||||||
with open(folder + "/fc1_w", "w") as fp:
|
save_kernal(fp, para)
|
||||||
save_weight_mat(fp, paras[4])
|
fp.close()
|
||||||
with open(folder + "/fc1_b", "w") as fp:
|
|
||||||
save_bias(fp, paras[5])
|
|
||||||
with open(folder + "/fc2_w", "w") as fp:
|
|
||||||
save_weight_mat(fp, paras[6])
|
|
||||||
with open(folder + "/fc2_b", "w") as fp:
|
|
||||||
save_bias(fp, paras[7])
|
|
||||||
|
|
||||||
|
|
||||||
STEPS = 60000
|
STEPS = 50000
|
||||||
BATCH = 50
|
BATCH = 30
|
||||||
LEARNING_RATE_BASE = 0.001
|
LEARNING_RATE_BASE = 0.0005
|
||||||
LEARNING_RATE_DECAY = 0.99
|
LEARNING_RATE_DECAY = 0.99
|
||||||
MOVING_AVERAGE_DECAY = 0.99
|
MOVING_AVERAGE_DECAY = 0.99
|
||||||
|
|
||||||
@@ -65,7 +60,7 @@ def train(dataset, show_bar=False):
|
|||||||
x = tf.placeholder(tf.float32, [None, generate.SRC_ROWS, generate.SRC_COLS, generate.SRC_CHANNELS])
|
x = tf.placeholder(tf.float32, [None, generate.SRC_ROWS, generate.SRC_COLS, generate.SRC_CHANNELS])
|
||||||
y_= tf.placeholder(tf.float32, [None, forward.OUTPUT_NODES])
|
y_= tf.placeholder(tf.float32, [None, forward.OUTPUT_NODES])
|
||||||
keep_rate = tf.placeholder(tf.float32)
|
keep_rate = tf.placeholder(tf.float32)
|
||||||
nodes, vars = forward.forward(x, 0.01)
|
nodes, vars, vars_name = forward.forward(x, 0.01)
|
||||||
y = nodes[-1]
|
y = nodes[-1]
|
||||||
|
|
||||||
ce = tf.nn.sparse_softmax_cross_entropy_with_logits(logits=y, labels=tf.argmax(y_, 1))
|
ce = tf.nn.sparse_softmax_cross_entropy_with_logits(logits=y, labels=tf.argmax(y_, 1))
|
||||||
@@ -101,12 +96,11 @@ def train(dataset, show_bar=False):
|
|||||||
|
|
||||||
_, loss_value, step = sess.run(
|
_, loss_value, step = sess.run(
|
||||||
[train_op, loss, global_step],
|
[train_op, loss, global_step],
|
||||||
feed_dict={x: images_samples, y_: labels_samples, keep_rate:0.2}
|
feed_dict={x: images_samples, y_: labels_samples, keep_rate:0.4}
|
||||||
)
|
)
|
||||||
|
|
||||||
if (i-1) % 100 == 0:
|
if step % 500 == 0:
|
||||||
if (i-1) % 500 == 0:
|
test_images, test_labels = dataset.sample_test_sets(6000)
|
||||||
test_images, test_labels = dataset.sample_test_sets(5000)
|
|
||||||
test_acc, output = sess.run([accuracy, y], feed_dict={x: test_images, y_: test_labels, keep_rate:1.0})
|
test_acc, output = sess.run([accuracy, y], feed_dict={x: test_images, y_: test_labels, keep_rate:1.0})
|
||||||
output = np.argmax(output, axis=1)
|
output = np.argmax(output, axis=1)
|
||||||
real = np.argmax(test_labels, axis=1)
|
real = np.argmax(test_labels, axis=1)
|
||||||
@@ -115,7 +109,7 @@ def train(dataset, show_bar=False):
|
|||||||
print("label: %d, precise: %f, recall: %f" %
|
print("label: %d, precise: %f, recall: %f" %
|
||||||
(n, np.mean(real[output==n]==n), np.mean(output[real==n]==n)))
|
(n, np.mean(real[output==n]==n), np.mean(output[real==n]==n)))
|
||||||
|
|
||||||
train_images, train_labels = dataset.sample_train_sets(5000)
|
train_images, train_labels = dataset.sample_train_sets(6000)
|
||||||
train_acc, output = sess.run([accuracy, y], feed_dict={x: train_images, y_: train_labels, keep_rate:1.0})
|
train_acc, output = sess.run([accuracy, y], feed_dict={x: train_images, y_: train_labels, keep_rate:1.0})
|
||||||
output = np.argmax(output, axis=1)
|
output = np.argmax(output, axis=1)
|
||||||
real = np.argmax(train_labels, axis=1)
|
real = np.argmax(train_labels, axis=1)
|
||||||
@@ -124,12 +118,16 @@ def train(dataset, show_bar=False):
|
|||||||
print("label: %d, precise: %f, recall: %f" %
|
print("label: %d, precise: %f, recall: %f" %
|
||||||
(n, np.mean(real[output==n]==n), np.mean(output[real==n]==n)))
|
(n, np.mean(real[output==n]==n), np.mean(output[real==n]==n)))
|
||||||
print("\n")
|
print("\n")
|
||||||
|
if train_acc >= 0.99 and test_acc >= 0.99:
|
||||||
bar.set_postfix({"loss": loss_value, "train_acc": train_acc, "test_acc": test_acc})
|
|
||||||
|
|
||||||
vars_val = sess.run(vars)
|
vars_val = sess.run(vars)
|
||||||
save_para("/home/xinyang/Workspace/RM_auto-aim/tools/para", vars_val)
|
save_para(
|
||||||
print("save done!")
|
"model",
|
||||||
|
vars_val,
|
||||||
|
vars_name,
|
||||||
|
"steps:%d-train_acc:%f-test_acc:%f" % (step, train_acc, test_acc)
|
||||||
|
)
|
||||||
|
bar.set_postfix({"loss": loss_value, "train_acc": train_acc, "test_acc": test_acc})
|
||||||
|
# print("save done!")
|
||||||
|
|
||||||
# pred = sess.run(y, feed_dict={x: test_images, keep_rate:1.0})
|
# pred = sess.run(y, feed_dict={x: test_images, keep_rate:1.0})
|
||||||
|
|
||||||
|
|||||||
@@ -29,16 +29,22 @@ def max_pool_2x2(x):
|
|||||||
CONV1_KERNAL_SIZE = 5
|
CONV1_KERNAL_SIZE = 5
|
||||||
|
|
||||||
# 第一层卷积输出通道数
|
# 第一层卷积输出通道数
|
||||||
CONV1_OUTPUT_CHANNELS = 8
|
CONV1_OUTPUT_CHANNELS = 4
|
||||||
|
|
||||||
# 第二层卷积核大小
|
# 第二层卷积核大小
|
||||||
CONV2_KERNAL_SIZE = 3
|
CONV2_KERNAL_SIZE = 3
|
||||||
|
|
||||||
# 第二层卷积输出通道数
|
# 第二层卷积输出通道数
|
||||||
CONV2_OUTPUT_CHANNELS = 16
|
CONV2_OUTPUT_CHANNELS = 6
|
||||||
|
|
||||||
|
# 第三层卷积核大小
|
||||||
|
CONV3_KERNAL_SIZE = 3
|
||||||
|
|
||||||
|
# 第三层卷积输出通道数
|
||||||
|
CONV3_OUTPUT_CHANNELS = 8
|
||||||
|
|
||||||
# 第一层全连接宽度
|
# 第一层全连接宽度
|
||||||
FC1_OUTPUT_NODES = 100
|
FC1_OUTPUT_NODES = 50
|
||||||
|
|
||||||
# 第二层全连接宽度(输出标签类型数)
|
# 第二层全连接宽度(输出标签类型数)
|
||||||
FC2_OUTPUT_NODES = 15
|
FC2_OUTPUT_NODES = 15
|
||||||
@@ -49,6 +55,7 @@ OUTPUT_NODES = FC2_OUTPUT_NODES
|
|||||||
|
|
||||||
def forward(x, regularizer=None, keep_rate=tf.constant(1.0)):
|
def forward(x, regularizer=None, keep_rate=tf.constant(1.0)):
|
||||||
vars = []
|
vars = []
|
||||||
|
vars_name = []
|
||||||
nodes = []
|
nodes = []
|
||||||
|
|
||||||
conv1_w = get_weight(
|
conv1_w = get_weight(
|
||||||
@@ -57,7 +64,10 @@ def forward(x, regularizer=None, keep_rate=tf.constant(1.0)):
|
|||||||
conv1_b = get_bias([CONV1_OUTPUT_CHANNELS])
|
conv1_b = get_bias([CONV1_OUTPUT_CHANNELS])
|
||||||
conv1 = tf.nn.relu(tf.nn.bias_add(conv2d(x, conv1_w), conv1_b))
|
conv1 = tf.nn.relu(tf.nn.bias_add(conv2d(x, conv1_w), conv1_b))
|
||||||
pool1 = avg_pool_2x2(conv1)
|
pool1 = avg_pool_2x2(conv1)
|
||||||
|
print("conv1: ", conv1.shape)
|
||||||
|
print("pool1: ", pool1.shape)
|
||||||
vars.extend([conv1_w, conv1_b])
|
vars.extend([conv1_w, conv1_b])
|
||||||
|
vars_name.extend(["conv1_w", "conv1_b"])
|
||||||
nodes.extend([conv1, pool1])
|
nodes.extend([conv1, pool1])
|
||||||
|
|
||||||
conv2_w = get_weight(
|
conv2_w = get_weight(
|
||||||
@@ -66,27 +76,41 @@ def forward(x, regularizer=None, keep_rate=tf.constant(1.0)):
|
|||||||
conv2_b = get_bias([CONV2_OUTPUT_CHANNELS])
|
conv2_b = get_bias([CONV2_OUTPUT_CHANNELS])
|
||||||
conv2 = tf.nn.relu(tf.nn.bias_add(conv2d(pool1, conv2_w), conv2_b))
|
conv2 = tf.nn.relu(tf.nn.bias_add(conv2d(pool1, conv2_w), conv2_b))
|
||||||
pool2 = avg_pool_2x2(conv2)
|
pool2 = avg_pool_2x2(conv2)
|
||||||
|
print("conv2: ", conv2.shape)
|
||||||
|
print("pool2: ", pool2.shape)
|
||||||
vars.extend([conv2_w, conv2_b])
|
vars.extend([conv2_w, conv2_b])
|
||||||
|
vars_name.extend(["conv2_w", "conv2_b"])
|
||||||
nodes.extend([conv2, pool2])
|
nodes.extend([conv2, pool2])
|
||||||
|
|
||||||
pool_shape = pool2.get_shape().as_list()
|
conv3_w = get_weight(
|
||||||
node = pool_shape[1] * pool_shape[2] * pool_shape[3]
|
[CONV3_KERNAL_SIZE, CONV3_KERNAL_SIZE, CONV2_OUTPUT_CHANNELS, CONV3_OUTPUT_CHANNELS]
|
||||||
reshaped = tf.reshape(pool2, [-1, node])
|
)
|
||||||
|
conv3_b = get_bias([CONV3_OUTPUT_CHANNELS])
|
||||||
|
conv3 = tf.nn.relu(tf.nn.bias_add(conv2d(pool2, conv3_w), conv3_b))
|
||||||
|
print("conv3: ", conv3.shape)
|
||||||
|
vars.extend([conv3_w, conv3_b])
|
||||||
|
vars_name.extend(["conv3_w", "conv3_b"])
|
||||||
|
nodes.extend([conv3])
|
||||||
|
|
||||||
|
conv_shape = conv3.get_shape().as_list()
|
||||||
|
node = conv_shape[1] * conv_shape[2] * conv_shape[3]
|
||||||
|
reshaped = tf.reshape(conv3, [-1, node])
|
||||||
reshaped = tf.nn.dropout(reshaped, keep_rate)
|
reshaped = tf.nn.dropout(reshaped, keep_rate)
|
||||||
|
print("reshaped: ", reshaped.shape)
|
||||||
|
|
||||||
fc1_w = get_weight([node, FC1_OUTPUT_NODES], regularizer)
|
fc1_w = get_weight([node, FC1_OUTPUT_NODES], regularizer)
|
||||||
fc1_b = get_bias([FC1_OUTPUT_NODES])
|
fc1_b = get_bias([FC1_OUTPUT_NODES])
|
||||||
fc1 = tf.nn.relu(tf.matmul(reshaped, fc1_w) + fc1_b)
|
fc1 = tf.nn.relu(tf.matmul(reshaped, fc1_w) + fc1_b)
|
||||||
fc1 = tf.nn.dropout(fc1, keep_rate)
|
|
||||||
vars.extend([fc1_w, fc1_b])
|
vars.extend([fc1_w, fc1_b])
|
||||||
|
vars_name.extend(["fc1_w", "fc1_b"])
|
||||||
nodes.extend([fc1])
|
nodes.extend([fc1])
|
||||||
|
|
||||||
fc2_w = get_weight([FC1_OUTPUT_NODES, FC2_OUTPUT_NODES], regularizer)
|
fc2_w = get_weight([FC1_OUTPUT_NODES, FC2_OUTPUT_NODES], regularizer)
|
||||||
fc2_b = get_bias([FC2_OUTPUT_NODES])
|
fc2_b = get_bias([FC2_OUTPUT_NODES])
|
||||||
# fc2 = tf.nn.softmax(tf.matmul(fc1, fc2_w) + fc2_b)
|
|
||||||
fc2 = tf.matmul(fc1, fc2_w) + fc2_b
|
fc2 = tf.matmul(fc1, fc2_w) + fc2_b
|
||||||
vars.extend([fc2_w, fc2_b])
|
vars.extend([fc2_w, fc2_b])
|
||||||
|
vars_name.extend(["fc2_w", "fc2_b"])
|
||||||
nodes.extend([fc2])
|
nodes.extend([fc2])
|
||||||
|
|
||||||
return nodes, vars
|
return nodes, vars, vars_name
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
8
|
4
|
||||||
-0.19897088
|
0.30789205
|
||||||
2.2773967
|
-0.043525748
|
||||||
-0.07212669
|
0.2050164
|
||||||
-0.22893764
|
0.74044687
|
||||||
-0.022769619
|
|
||||||
0.9122422
|
|
||||||
1.3221853
|
|
||||||
-0.21709026
|
|
||||||
|
|||||||
@@ -1,604 +1,304 @@
|
|||||||
3
|
3
|
||||||
8
|
4
|
||||||
5
|
5
|
||||||
5
|
5
|
||||||
-0.42449534
|
-0.10729549
|
||||||
-0.14145629
|
0.09332296
|
||||||
0.12018829
|
0.16133511
|
||||||
0.4759054
|
-0.030649675
|
||||||
0.54840434
|
0.06557881
|
||||||
0.28412497
|
-0.053242918
|
||||||
0.40357414
|
0.19213735
|
||||||
0.6718681
|
0.15569621
|
||||||
0.92518467
|
0.3419906
|
||||||
0.68381476
|
0.1786888
|
||||||
0.28161842
|
0.19507813
|
||||||
0.5942867
|
0.24212381
|
||||||
0.594364
|
0.4231631
|
||||||
0.7217546
|
0.08838954
|
||||||
0.77334726
|
0.14048508
|
||||||
0.18300368
|
0.15044038
|
||||||
0.3455078
|
0.28268903
|
||||||
0.270947
|
0.13327996
|
||||||
0.3452664
|
0.15814759
|
||||||
0.3419373
|
-0.112561114
|
||||||
-0.07475002
|
0.056091413
|
||||||
-0.23191033
|
0.16789797
|
||||||
-0.5056218
|
-0.11966196
|
||||||
-0.5653023
|
0.038136892
|
||||||
-0.49549124
|
-0.14447927
|
||||||
-0.356733
|
0.5679466
|
||||||
-0.70811594
|
0.48397887
|
||||||
-0.6640918
|
0.70058227
|
||||||
-0.5230208
|
0.5070652
|
||||||
-0.5567686
|
0.62130994
|
||||||
-0.34954152
|
0.5227163
|
||||||
-0.49958408
|
0.6784681
|
||||||
-0.31039435
|
0.5526853
|
||||||
-0.55455387
|
0.5210595
|
||||||
-0.3291702
|
0.396152
|
||||||
-0.0030061502
|
0.31640542
|
||||||
-0.13863257
|
0.459686
|
||||||
-0.40160847
|
0.5702434
|
||||||
-0.53651094
|
0.5931808
|
||||||
-0.24113898
|
0.36256674
|
||||||
-0.1733842
|
0.3457865
|
||||||
-0.2476929
|
0.37771964
|
||||||
-0.5121031
|
0.4625998
|
||||||
-0.47203135
|
0.47415066
|
||||||
-0.43864155
|
0.3938988
|
||||||
-0.058570273
|
0.49735737
|
||||||
-0.33658004
|
0.26142278
|
||||||
-0.6619966
|
0.32298478
|
||||||
-0.73419136
|
0.3374469
|
||||||
-0.7045188
|
0.47159982
|
||||||
0.32072416
|
-0.18274228
|
||||||
0.330073
|
-0.28124171
|
||||||
0.55653447
|
-0.20628488
|
||||||
0.5957652
|
-0.10543057
|
||||||
0.50899994
|
-0.05156752
|
||||||
0.50545204
|
-0.091269255
|
||||||
0.7220086
|
-0.0054441793
|
||||||
0.7438928
|
0.11289734
|
||||||
0.7675144
|
-0.03441205
|
||||||
0.7756041
|
-0.13315572
|
||||||
0.7274903
|
0.20559654
|
||||||
0.7188184
|
0.10798551
|
||||||
0.88465214
|
-0.07475637
|
||||||
1.1385522
|
-0.0047787298
|
||||||
0.87919647
|
-0.22890174
|
||||||
0.6987736
|
0.09388285
|
||||||
0.9527178
|
0.059628867
|
||||||
0.95726067
|
0.019401075
|
||||||
0.88654906
|
0.05334341
|
||||||
0.8920211
|
-0.1582362
|
||||||
0.63958967
|
0.017811468
|
||||||
0.8072574
|
-0.04889371
|
||||||
0.8347145
|
-0.065829955
|
||||||
0.7488403
|
-0.04788549
|
||||||
0.6869278
|
-0.33305293
|
||||||
-0.90990585
|
-0.19116391
|
||||||
-0.6184357
|
-0.28003454
|
||||||
-0.1404704
|
-0.0820173
|
||||||
0.20029725
|
-0.26577657
|
||||||
0.23383331
|
-0.11826798
|
||||||
-0.5078964
|
-0.39622292
|
||||||
0.07829093
|
-0.36510658
|
||||||
0.41757903
|
-0.11750732
|
||||||
0.5164328
|
-0.24734864
|
||||||
0.5336988
|
-0.2803419
|
||||||
-0.21864063
|
-0.1519
|
||||||
0.07738885
|
-0.23317525
|
||||||
0.46755105
|
-0.007902931
|
||||||
0.6110745
|
-0.16537969
|
||||||
0.64779043
|
-0.19139121
|
||||||
-0.17151009
|
-0.023329364
|
||||||
0.07808888
|
-0.30243063
|
||||||
-0.014565518
|
-0.24868572
|
||||||
0.27556416
|
-0.029912082
|
||||||
0.21755305
|
-0.23020941
|
||||||
-0.42132428
|
-0.31355116
|
||||||
-0.4472937
|
-0.11182503
|
||||||
-0.686964
|
-0.0692445
|
||||||
-0.6123315
|
-0.35592338
|
||||||
-0.36468038
|
-0.09419684
|
||||||
0.39503688
|
0.14571323
|
||||||
0.7375632
|
0.5725029
|
||||||
0.6933682
|
1.193062
|
||||||
0.59439814
|
1.2903835
|
||||||
0.5431905
|
0.9622877
|
||||||
0.4742321
|
0.525414
|
||||||
0.8823627
|
1.0394033
|
||||||
0.77081895
|
1.4996175
|
||||||
0.7913887
|
1.8389359
|
||||||
0.5136633
|
1.3628953
|
||||||
0.5808819
|
0.80069596
|
||||||
0.80829126
|
1.4277213
|
||||||
1.0471532
|
1.6703882
|
||||||
0.6837362
|
1.7443689
|
||||||
0.6456983
|
1.4166398
|
||||||
0.6088025
|
0.6203115
|
||||||
0.9599121
|
1.1946497
|
||||||
0.79199773
|
1.7266799
|
||||||
0.64847285
|
1.6697397
|
||||||
0.7558641
|
1.3126082
|
||||||
0.72989166
|
0.47843987
|
||||||
0.8269554
|
0.89622074
|
||||||
0.70485115
|
1.0277275
|
||||||
0.773673
|
1.0125589
|
||||||
0.5633863
|
0.8202855
|
||||||
-0.6651138
|
0.5230944
|
||||||
-0.6533556
|
0.6464553
|
||||||
-0.8055196
|
0.5895753
|
||||||
-0.70568013
|
0.54708016
|
||||||
-0.59960866
|
0.26677945
|
||||||
-0.38753736
|
0.4320181
|
||||||
-0.75367606
|
0.59073323
|
||||||
-0.6284249
|
0.50776094
|
||||||
-0.73716867
|
0.50096244
|
||||||
-0.4809728
|
0.4625974
|
||||||
-0.43523777
|
0.49336708
|
||||||
-0.5271899
|
0.34545958
|
||||||
-0.6199644
|
0.56925744
|
||||||
-0.6201511
|
0.34867597
|
||||||
-0.58342254
|
0.16094568
|
||||||
-0.41127473
|
0.3861315
|
||||||
-0.54275876
|
0.5891766
|
||||||
-0.53538835
|
0.2174486
|
||||||
-0.56108046
|
0.20948303
|
||||||
-0.48543084
|
0.1000691
|
||||||
-0.74164164
|
0.21441981
|
||||||
-0.64662766
|
0.22367561
|
||||||
-0.856863
|
0.19896027
|
||||||
-0.6305302
|
0.13936864
|
||||||
-0.5739134
|
0.03653052
|
||||||
0.95437706
|
0.084119834
|
||||||
1.2035962
|
0.3999692
|
||||||
1.2448038
|
0.5730208
|
||||||
1.1763076
|
0.6282694
|
||||||
1.0001042
|
0.37436715
|
||||||
0.78790265
|
0.46807006
|
||||||
1.0511717
|
0.78820395
|
||||||
1.0552691
|
0.96178275
|
||||||
1.2410581
|
0.90761256
|
||||||
0.8918281
|
0.87396187
|
||||||
0.68448544
|
0.53964555
|
||||||
0.8909238
|
0.9532658
|
||||||
0.8172731
|
0.9813636
|
||||||
0.8248441
|
1.0613359
|
||||||
0.9374103
|
0.7933851
|
||||||
0.545665
|
0.5819338
|
||||||
0.65757316
|
0.9753471
|
||||||
0.88965493
|
1.2284292
|
||||||
0.78279305
|
0.94796246
|
||||||
0.5069958
|
0.82767236
|
||||||
0.4710934
|
0.499911
|
||||||
0.6540229
|
0.75207883
|
||||||
0.7689269
|
0.68719465
|
||||||
0.5900862
|
0.8145963
|
||||||
0.6000688
|
0.6596423
|
||||||
-0.8985509
|
0.011669106
|
||||||
-0.5367204
|
0.18070999
|
||||||
-0.17939755
|
0.36343256
|
||||||
0.1239284
|
0.3169534
|
||||||
0.31574073
|
0.20783305
|
||||||
-0.29208726
|
0.03404153
|
||||||
0.11087964
|
0.43459386
|
||||||
0.13841438
|
0.36061177
|
||||||
0.6425852
|
0.43950805
|
||||||
0.6579574
|
0.38309076
|
||||||
0.1677956
|
0.25803936
|
||||||
0.5068273
|
0.4289157
|
||||||
0.6169031
|
0.58764404
|
||||||
0.46504426
|
0.58137804
|
||||||
0.56336105
|
0.46296367
|
||||||
0.007133658
|
0.1991764
|
||||||
0.056750543
|
0.33899468
|
||||||
0.083241865
|
0.64967453
|
||||||
0.06789419
|
0.74104553
|
||||||
0.14583983
|
0.57953227
|
||||||
-0.6158809
|
0.1818072
|
||||||
-0.87346137
|
0.32919815
|
||||||
-0.80676347
|
0.6142047
|
||||||
-0.70183337
|
0.47143123
|
||||||
-0.6015298
|
0.3723565
|
||||||
1.5393821
|
-0.29113623
|
||||||
2.1624126
|
0.08584255
|
||||||
2.5511134
|
0.49546224
|
||||||
2.7846441
|
0.80879575
|
||||||
2.368676
|
0.72197473
|
||||||
2.4525952
|
-0.01818511
|
||||||
3.2989857
|
0.4448289
|
||||||
4.029959
|
0.86975175
|
||||||
3.827302
|
1.0318508
|
||||||
3.2697773
|
0.70635146
|
||||||
2.9329424
|
0.2590701
|
||||||
3.9139073
|
0.55703586
|
||||||
4.2881436
|
1.2021183
|
||||||
4.3753977
|
1.1355498
|
||||||
3.3441596
|
0.929514
|
||||||
2.6599689
|
-0.0021778075
|
||||||
3.4512682
|
0.49526876
|
||||||
3.6378286
|
0.8620847
|
||||||
3.5350695
|
0.97750324
|
||||||
2.7694979
|
0.80483395
|
||||||
2.0715785
|
0.066819414
|
||||||
2.4096649
|
0.0533782
|
||||||
2.262437
|
0.2378203
|
||||||
1.9068127
|
0.48883578
|
||||||
1.4933991
|
0.46825472
|
||||||
0.067793235
|
-0.08690677
|
||||||
0.4761605
|
-0.098846406
|
||||||
0.8775232
|
-0.11066464
|
||||||
0.79931116
|
-0.33117262
|
||||||
1.0089498
|
-0.13379335
|
||||||
0.3564602
|
-0.10680438
|
||||||
0.70624393
|
-0.092536114
|
||||||
1.1053402
|
-0.06396752
|
||||||
1.3865718
|
-0.2411913
|
||||||
1.4715241
|
-0.4162492
|
||||||
0.46418893
|
-0.27065766
|
||||||
1.059161
|
-0.0127258655
|
||||||
1.4488351
|
-0.22221713
|
||||||
1.5534589
|
-0.10054428
|
||||||
1.6705322
|
-0.25341535
|
||||||
0.79103005
|
-0.36750633
|
||||||
1.1441072
|
-0.0970442
|
||||||
1.3800188
|
-0.28783646
|
||||||
1.5281351
|
-0.3083135
|
||||||
1.5740242
|
-0.37662375
|
||||||
0.9623409
|
-0.24937427
|
||||||
0.98793215
|
-0.36285818
|
||||||
1.1669405
|
-0.32178807
|
||||||
1.1152183
|
-0.41167092
|
||||||
1.2492605
|
-0.64311564
|
||||||
-0.15674886
|
0.15358478
|
||||||
-0.038593877
|
0.45863125
|
||||||
-0.17274536
|
0.680853
|
||||||
0.09258732
|
0.69516915
|
||||||
0.17494603
|
0.73355865
|
||||||
0.105809644
|
0.36617115
|
||||||
0.31649294
|
0.8283799
|
||||||
0.343589
|
0.94936144
|
||||||
0.53679705
|
0.96523696
|
||||||
0.4734059
|
0.7651339
|
||||||
0.3889172
|
0.4159632
|
||||||
0.5807728
|
0.9592908
|
||||||
0.67378217
|
1.038713
|
||||||
0.6827083
|
1.1703031
|
||||||
0.7268035
|
0.83268124
|
||||||
0.60358465
|
0.62078
|
||||||
0.7300566
|
0.8680032
|
||||||
1.0874548
|
1.1751134
|
||||||
1.0207677
|
1.0394844
|
||||||
0.84341484
|
0.9290284
|
||||||
0.60612875
|
0.527504
|
||||||
0.8210886
|
0.75912774
|
||||||
1.0350081
|
0.86471754
|
||||||
0.87764287
|
0.89958185
|
||||||
1.0081718
|
0.7007667
|
||||||
1.3859847
|
0.11127112
|
||||||
2.0778801
|
0.30424586
|
||||||
2.148741
|
0.6125697
|
||||||
2.4518552
|
0.51516706
|
||||||
1.9672226
|
0.4895497
|
||||||
2.5095375
|
0.32818803
|
||||||
3.0291762
|
0.44973958
|
||||||
3.4696164
|
0.61502695
|
||||||
3.2318525
|
0.57045287
|
||||||
2.4367645
|
0.58641577
|
||||||
2.8905299
|
0.28688067
|
||||||
3.4577188
|
0.6754326
|
||||||
3.8412285
|
0.85857826
|
||||||
3.5718715
|
0.6959833
|
||||||
2.7076635
|
0.67804474
|
||||||
2.91653
|
0.38325444
|
||||||
3.1068695
|
0.5163973
|
||||||
3.2963896
|
0.64538044
|
||||||
2.8063552
|
0.79433715
|
||||||
1.9206675
|
0.70066565
|
||||||
1.9905787
|
0.38258222
|
||||||
2.0144224
|
0.5113986
|
||||||
1.754742
|
0.61964786
|
||||||
1.4237579
|
0.8566454
|
||||||
0.83947563
|
0.7331395
|
||||||
0.2254852
|
|
||||||
0.03469266
|
|
||||||
-0.05631122
|
|
||||||
0.04464834
|
|
||||||
-0.2178017
|
|
||||||
0.13702668
|
|
||||||
0.16909239
|
|
||||||
0.26976383
|
|
||||||
0.068580456
|
|
||||||
0.12111518
|
|
||||||
0.39565983
|
|
||||||
0.57780766
|
|
||||||
0.48672187
|
|
||||||
0.3581179
|
|
||||||
0.2925836
|
|
||||||
0.5067063
|
|
||||||
0.42480332
|
|
||||||
0.46175724
|
|
||||||
0.51814044
|
|
||||||
0.094496034
|
|
||||||
0.3766073
|
|
||||||
0.46016395
|
|
||||||
0.40080497
|
|
||||||
0.3402491
|
|
||||||
0.21284883
|
|
||||||
0.13231997
|
|
||||||
-0.013396452
|
|
||||||
-0.083948776
|
|
||||||
0.012691039
|
|
||||||
0.11314143
|
|
||||||
0.09580059
|
|
||||||
0.2377315
|
|
||||||
0.41866076
|
|
||||||
0.15490921
|
|
||||||
0.103149235
|
|
||||||
0.18240465
|
|
||||||
0.1797153
|
|
||||||
0.4242559
|
|
||||||
0.18161982
|
|
||||||
0.2963119
|
|
||||||
0.20458256
|
|
||||||
0.20636415
|
|
||||||
0.39781362
|
|
||||||
0.23634791
|
|
||||||
0.122939676
|
|
||||||
0.24806741
|
|
||||||
0.13085991
|
|
||||||
0.16097488
|
|
||||||
-0.020796934
|
|
||||||
0.17553945
|
|
||||||
0.6122431
|
|
||||||
0.5468711
|
|
||||||
0.7881819
|
|
||||||
0.70415086
|
|
||||||
0.76530534
|
|
||||||
0.23065606
|
|
||||||
0.26207468
|
|
||||||
0.22612737
|
|
||||||
0.3477262
|
|
||||||
0.33311552
|
|
||||||
0.1145771
|
|
||||||
-0.064461164
|
|
||||||
-0.15550038
|
|
||||||
-0.17301485
|
|
||||||
-0.1755835
|
|
||||||
-0.46472925
|
|
||||||
-0.32503256
|
|
||||||
-0.30224133
|
|
||||||
-0.49536815
|
|
||||||
-0.5347998
|
|
||||||
-0.62774706
|
|
||||||
-0.52409613
|
|
||||||
-0.46520838
|
|
||||||
-0.47201794
|
|
||||||
-0.62468505
|
|
||||||
1.2727304
|
|
||||||
1.8184105
|
|
||||||
2.2249503
|
|
||||||
2.4140065
|
|
||||||
1.7565204
|
|
||||||
2.7623854
|
|
||||||
3.196057
|
|
||||||
3.6894598
|
|
||||||
3.521049
|
|
||||||
2.7936237
|
|
||||||
3.4329123
|
|
||||||
3.8600874
|
|
||||||
4.2160697
|
|
||||||
3.905414
|
|
||||||
2.9514873
|
|
||||||
3.2884743
|
|
||||||
3.810133
|
|
||||||
3.8212693
|
|
||||||
3.4374819
|
|
||||||
2.47835
|
|
||||||
2.4106874
|
|
||||||
2.5125678
|
|
||||||
2.35327
|
|
||||||
1.9101305
|
|
||||||
1.2425265
|
|
||||||
-0.03470229
|
|
||||||
0.7919308
|
|
||||||
1.3452832
|
|
||||||
1.2696229
|
|
||||||
1.04937
|
|
||||||
0.9344194
|
|
||||||
1.8166728
|
|
||||||
2.1765978
|
|
||||||
2.4447913
|
|
||||||
1.6805668
|
|
||||||
1.2032535
|
|
||||||
2.2395353
|
|
||||||
2.6600883
|
|
||||||
2.8381574
|
|
||||||
1.9751589
|
|
||||||
1.1395236
|
|
||||||
1.8099883
|
|
||||||
2.0537355
|
|
||||||
2.181522
|
|
||||||
1.5130651
|
|
||||||
0.4666265
|
|
||||||
0.76658946
|
|
||||||
0.99030006
|
|
||||||
0.7782916
|
|
||||||
0.19490543
|
|
||||||
-0.86873436
|
|
||||||
-0.6494321
|
|
||||||
-0.3110133
|
|
||||||
-0.086757496
|
|
||||||
-0.061029676
|
|
||||||
-0.79375947
|
|
||||||
-0.47139648
|
|
||||||
0.07530813
|
|
||||||
0.17621484
|
|
||||||
0.28143188
|
|
||||||
-0.54239106
|
|
||||||
-0.15787664
|
|
||||||
0.18588926
|
|
||||||
0.3305964
|
|
||||||
0.52410334
|
|
||||||
-0.43658426
|
|
||||||
-0.16318789
|
|
||||||
0.25725472
|
|
||||||
0.3821112
|
|
||||||
0.43296495
|
|
||||||
-0.34542954
|
|
||||||
-0.13750273
|
|
||||||
0.1684193
|
|
||||||
0.066175155
|
|
||||||
-0.109317034
|
|
||||||
-0.6713239
|
|
||||||
-0.704688
|
|
||||||
-0.41100273
|
|
||||||
-0.5969387
|
|
||||||
-0.5914036
|
|
||||||
-0.5237271
|
|
||||||
-0.36877418
|
|
||||||
-0.32102436
|
|
||||||
-0.2706671
|
|
||||||
-0.14425935
|
|
||||||
-0.24273401
|
|
||||||
-0.05300261
|
|
||||||
0.0068080607
|
|
||||||
-0.030264616
|
|
||||||
-0.07868397
|
|
||||||
-0.11762654
|
|
||||||
0.19707958
|
|
||||||
0.21811731
|
|
||||||
0.44130355
|
|
||||||
0.21699134
|
|
||||||
0.060512982
|
|
||||||
0.19437213
|
|
||||||
0.55949223
|
|
||||||
0.32470936
|
|
||||||
0.28635567
|
|
||||||
1.1079576
|
|
||||||
1.7189704
|
|
||||||
2.413394
|
|
||||||
2.4546094
|
|
||||||
1.8035649
|
|
||||||
2.1479077
|
|
||||||
3.1008422
|
|
||||||
3.601715
|
|
||||||
3.365891
|
|
||||||
2.4578235
|
|
||||||
2.5486002
|
|
||||||
3.5174582
|
|
||||||
3.9265308
|
|
||||||
3.515769
|
|
||||||
2.5787847
|
|
||||||
2.4205306
|
|
||||||
3.1097507
|
|
||||||
3.152673
|
|
||||||
2.882059
|
|
||||||
1.976877
|
|
||||||
1.6673613
|
|
||||||
1.9114503
|
|
||||||
1.7297668
|
|
||||||
1.4748011
|
|
||||||
0.6597555
|
|
||||||
-0.42657572
|
|
||||||
-0.52120584
|
|
||||||
-0.68196577
|
|
||||||
-0.69425035
|
|
||||||
-0.9403177
|
|
||||||
-0.30822635
|
|
||||||
-0.46618125
|
|
||||||
-0.5267847
|
|
||||||
-0.493324
|
|
||||||
-0.65498495
|
|
||||||
-0.23576419
|
|
||||||
-0.16038808
|
|
||||||
-0.16629791
|
|
||||||
-0.3212767
|
|
||||||
-0.59757406
|
|
||||||
-0.004436309
|
|
||||||
-0.00716624
|
|
||||||
-0.11501519
|
|
||||||
-0.18837191
|
|
||||||
-0.39238173
|
|
||||||
0.050632488
|
|
||||||
0.14269532
|
|
||||||
-0.121495865
|
|
||||||
-0.26217306
|
|
||||||
-0.37235448
|
|
||||||
0.6217619
|
|
||||||
0.75724506
|
|
||||||
0.81917787
|
|
||||||
0.82933223
|
|
||||||
0.8388242
|
|
||||||
0.8166705
|
|
||||||
0.95639604
|
|
||||||
0.9749462
|
|
||||||
1.0679555
|
|
||||||
0.88015705
|
|
||||||
0.9423948
|
|
||||||
1.1189271
|
|
||||||
0.9902488
|
|
||||||
1.072058
|
|
||||||
1.1399423
|
|
||||||
0.96763176
|
|
||||||
0.97359556
|
|
||||||
1.1033723
|
|
||||||
1.064764
|
|
||||||
0.90642184
|
|
||||||
0.70701605
|
|
||||||
0.80866563
|
|
||||||
0.71614605
|
|
||||||
0.6529501
|
|
||||||
0.8378095
|
|
||||||
-0.0864334
|
|
||||||
0.05153916
|
|
||||||
0.06473441
|
|
||||||
-0.12220235
|
|
||||||
0.11894611
|
|
||||||
-0.2647296
|
|
||||||
-0.62840766
|
|
||||||
-0.621625
|
|
||||||
-0.4897769
|
|
||||||
-0.37764832
|
|
||||||
-0.6673036
|
|
||||||
-1.0537109
|
|
||||||
-1.1991285
|
|
||||||
-1.0963191
|
|
||||||
-0.96230215
|
|
||||||
-1.0695108
|
|
||||||
-1.3443365
|
|
||||||
-1.3382062
|
|
||||||
-1.6774666
|
|
||||||
-1.5912658
|
|
||||||
-1.3784939
|
|
||||||
-1.3979015
|
|
||||||
-1.6025708
|
|
||||||
-1.6357968
|
|
||||||
-1.8174925
|
|
||||||
0.57204753
|
|
||||||
1.1402864
|
|
||||||
1.5789323
|
|
||||||
1.6362445
|
|
||||||
1.1193172
|
|
||||||
1.8848814
|
|
||||||
2.7911117
|
|
||||||
3.185937
|
|
||||||
3.0631964
|
|
||||||
1.9419188
|
|
||||||
2.6837914
|
|
||||||
3.625602
|
|
||||||
4.0801044
|
|
||||||
3.6807868
|
|
||||||
2.4854035
|
|
||||||
2.679125
|
|
||||||
3.3659801
|
|
||||||
3.3164527
|
|
||||||
3.082823
|
|
||||||
1.911974
|
|
||||||
1.7753979
|
|
||||||
2.046517
|
|
||||||
1.8074046
|
|
||||||
1.2649333
|
|
||||||
0.53168595
|
|
||||||
|
|||||||
@@ -1,17 +1,7 @@
|
|||||||
16
|
6
|
||||||
0.032270256
|
-0.66018975
|
||||||
2.3110154
|
-0.010440656
|
||||||
0.4078679
|
1.4320896
|
||||||
0.30516425
|
0.6933768
|
||||||
-0.027841559
|
-0.65163565
|
||||||
0.80007833
|
0.5277429
|
||||||
0.10999302
|
|
||||||
0.83167756
|
|
||||||
-0.09058099
|
|
||||||
0.67901427
|
|
||||||
0.2736649
|
|
||||||
0.08881351
|
|
||||||
0.10975416
|
|
||||||
0.25698876
|
|
||||||
0.076515704
|
|
||||||
-0.017468728
|
|
||||||
|
|||||||
1372
tools/para/conv2_w
1372
tools/para/conv2_w
File diff suppressed because it is too large
Load Diff
152
tools/para/fc1_b
152
tools/para/fc1_b
@@ -1,101 +1,51 @@
|
|||||||
100
|
50
|
||||||
-0.39040318
|
-0.24530283
|
||||||
-0.031096617
|
-0.073897995
|
||||||
-0.06425226
|
-0.067673266
|
||||||
0.24911235
|
-0.043941643
|
||||||
-0.002578787
|
0.339086
|
||||||
-0.086705275
|
-0.2782574
|
||||||
-0.0322658
|
-0.16835077
|
||||||
-0.017816741
|
-0.01852681
|
||||||
-0.11621032
|
0.3498275
|
||||||
0.21196772
|
0.38015145
|
||||||
-0.004639828
|
-0.016264258
|
||||||
-0.023076132
|
-0.14133461
|
||||||
-0.50997764
|
0.24981335
|
||||||
-0.04299724
|
-0.025037237
|
||||||
-0.01989839
|
0.736614
|
||||||
-0.011238396
|
-0.1785015
|
||||||
-0.003221448
|
-0.040974453
|
||||||
-0.019384952
|
0.2144458
|
||||||
-0.0007764693
|
0.23580065
|
||||||
-0.015599826
|
-0.115499295
|
||||||
0.16373938
|
-0.09057627
|
||||||
-0.0027049272
|
0.28634802
|
||||||
-0.18095633
|
0.58878446
|
||||||
-0.050923813
|
-0.12215623
|
||||||
0.12674743
|
-0.10074399
|
||||||
-0.064153716
|
0.32165715
|
||||||
-0.028386148
|
0.39080995
|
||||||
-0.059802737
|
0.26881945
|
||||||
-0.036068685
|
-0.14676444
|
||||||
-0.004065791
|
0.50808805
|
||||||
-0.03783843
|
-0.053912967
|
||||||
-0.16458924
|
-0.111540824
|
||||||
-0.0328307
|
-0.10144225
|
||||||
-0.032716025
|
0.0035003617
|
||||||
-0.020594684
|
-0.010641405
|
||||||
-0.042352736
|
0.3912463
|
||||||
-0.084991984
|
0.06348127
|
||||||
-0.028080234
|
-0.11809033
|
||||||
-0.001538593
|
-0.024349451
|
||||||
-0.10711875
|
0.4927379
|
||||||
-0.024680987
|
0.23499253
|
||||||
-0.008004385
|
-0.042348947
|
||||||
-0.5063542
|
0.44671503
|
||||||
-0.09158748
|
0.23698664
|
||||||
-0.08181085
|
-0.18389338
|
||||||
-0.22574262
|
0.10498202
|
||||||
-0.075171836
|
-0.12768361
|
||||||
0.28233245
|
-0.03513563
|
||||||
-0.024944687
|
0.14860639
|
||||||
-0.0029645876
|
0.22698319
|
||||||
-0.041441295
|
|
||||||
-0.08904015
|
|
||||||
0.30993482
|
|
||||||
-0.06328518
|
|
||||||
-0.0075723003
|
|
||||||
-0.005151164
|
|
||||||
-0.0021952058
|
|
||||||
-0.013833341
|
|
||||||
-0.023337327
|
|
||||||
-0.01824665
|
|
||||||
-0.025177158
|
|
||||||
-0.067239
|
|
||||||
-0.02126352
|
|
||||||
0.11769418
|
|
||||||
-0.64603645
|
|
||||||
-0.014887376
|
|
||||||
-0.14686602
|
|
||||||
-0.020528413
|
|
||||||
-0.018256638
|
|
||||||
-0.0017088759
|
|
||||||
-0.018110225
|
|
||||||
-0.003289471
|
|
||||||
1.0441891
|
|
||||||
0.30619404
|
|
||||||
-0.001282074
|
|
||||||
-0.09424017
|
|
||||||
-0.24455559
|
|
||||||
-0.026046017
|
|
||||||
-0.004658401
|
|
||||||
-0.022633847
|
|
||||||
-0.022873487
|
|
||||||
0.4393057
|
|
||||||
-0.033948973
|
|
||||||
-0.042779494
|
|
||||||
-0.0059623853
|
|
||||||
0.6859317
|
|
||||||
-0.19052452
|
|
||||||
-0.020080235
|
|
||||||
-0.010588832
|
|
||||||
0.012147919
|
|
||||||
-0.002949453
|
|
||||||
0.41500625
|
|
||||||
-0.16353038
|
|
||||||
-0.023607356
|
|
||||||
-0.38747007
|
|
||||||
-0.014272043
|
|
||||||
-0.0033837124
|
|
||||||
-0.1627222
|
|
||||||
-0.055108108
|
|
||||||
0.74174875
|
|
||||||
|
|||||||
128002
tools/para/fc1_w
128002
tools/para/fc1_w
File diff suppressed because it is too large
Load Diff
@@ -1,16 +1,16 @@
|
|||||||
15
|
15
|
||||||
0.7158619
|
0.45424584
|
||||||
0.074666105
|
-0.028361967
|
||||||
-0.20262705
|
-0.06438486
|
||||||
-0.32018387
|
-0.15962061
|
||||||
-0.35891113
|
-0.20572336
|
||||||
-0.021645868
|
-0.111016475
|
||||||
0.2373232
|
0.24467993
|
||||||
0.17633525
|
-0.012314044
|
||||||
-0.4311263
|
-0.11952816
|
||||||
-0.2179705
|
-0.20754007
|
||||||
-0.21293324
|
-0.18928203
|
||||||
0.20182535
|
-0.10316595
|
||||||
-0.8007338
|
-0.33859444
|
||||||
-0.02198011
|
0.15107821
|
||||||
0.30222887
|
0.022365652
|
||||||
|
|||||||
2252
tools/para/fc2_w
2252
tools/para/fc2_w
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user