Skip to content

Commit 992242d

Browse files
committed
init.
0 parents  commit 992242d

File tree

4,090 files changed

+1533630
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

4,090 files changed

+1533630
-0
lines changed

.gitignore

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
.DS_Store
2+
.ipynb_checkpoints
3+
node_modules
4+
/.bazelrc
5+
/.tf_configure.bazelrc
6+
/bazel-*
7+
/bazel_pip
8+
/tools/python_bin_path.sh
9+
/tools/git/gen
10+
/pip_test
11+
/_python_build
12+
*.pyc
13+
__pycache__
14+
*.swp
15+
*.db
16+
*.opendb
17+
.vscode/
18+
cmake_build/
19+
.idea/**
20+
/build/vc14/Debug
21+
/build/vc14/Release
22+
/build/vc14/x64
23+
/tensorflow/core/util/version_info.cc
24+
/tensorflow/contrib/cmake/build
25+
/app/classifier
26+
/app/trainner
27+
/app/dataGen
28+
/bin
29+
/extra/others
30+
/extra/tensorflow-r1.4/lib

README.md

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
2+
## DEye
3+
4+
### 1. Introduction
5+
6+
Defect Eye is an open source software library based on tensorflow1.4, which focus on surface defect inspection. The application area cover the full range of yield applications within the manufacturing environment, including incoming process tool qualification, wafer qualification, glass surface qualification, reticle qualification, research and development, and tool, process and line monitoring. Patterned and unpatterned wafer defect inspection and qualification tools find particles and pattern defects on the front surface, back surface and edge of the wafer, allowing engineers to detect and monitor critical yield excursions. Also, It can be used for medical image inpsection, including Lung PET/CT,breast MRI, CT Colongraphy, Digital Chest X-ray images.
7+
8+
![DEye](https://i.imgur.com/YfiOMJf.png)
9+
10+
### 2. Usage
11+
12+
Compiled tensorflow-r1.4 GPU version using CMake,VisualStudio 2015, CUDA8.0, cudnn6.0.
13+
14+
- tensorflow.dll, tensorflow.lib, libprotobuf.lib
15+
16+
- Download Address: 链接:https://pan.baidu.com/s/1o9tv1n8 密码:ekec
17+
18+
### DEye使用教程
19+
20+
### 准备工作
21+
22+
- 安装VisualStudio Community 2015 安装NVIDIA CUDA 8.0
23+
24+
- git clone https://github.com/sundyCoder/DEye
25+
26+
- 下载tensorflow.dll,放置在DEye/bin目录下
27+
28+
- 下载tensorflow.lib、libprotobuf.lib,放置在DEye/extra/tensorflow-r1.4/lib/目录下
29+
30+
- 下载inception_v3_2016_08_28_frozen.pb,放置在DEye/data目录下
31+
32+
- 打开DEye/build/vc14目录下的visual studio Solution 'tensorflow_classification', 将编译选项为 'Release' 'x64'
33+
34+
### How to use DEye
35+
36+
- Install VisualStudio Community2015 Install NVIDIA CUDA 8.0
37+
38+
- git clone https://github.com/sundyCoder/DEye
39+
40+
- Download tensorflow.dll, place it under DEye/bin
41+
42+
- Download tensorflow.lib and libprotobuf.lib, place theme under DEye/extra/tensorflow-r1.4/
43+
44+
- Download inception_v3_2016_08_28_frozen.pb, place it under DEye/data
45+
46+
- Open Visual Studio Solution "DEye.sln" which should be under DEye/build/vc14,Solution configurations option choose "Release", Soluton Platform option choose "x64".
47+
48+
## 3. License
49+
Apache License 2.0

app/example/convertMnist.cpp

+180
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
#include <iostream>
2+
#include <fstream>
3+
#include "opencv2/core/core.hpp"
4+
#include "opencv2/highgui/highgui.hpp"
5+
#include "opencv2/imgproc/imgproc.hpp"
6+
#include <cstdio>
7+
using namespace std;
8+
9+
int ReverseInt(int i)
10+
{
11+
unsigned char ch1, ch2, ch3, ch4;
12+
ch1 = i & 255;
13+
ch2 = (i >> 8) & 255;
14+
ch3 = (i >> 16) & 255;
15+
ch4 = (i >> 24) & 255;
16+
return((int)ch1 << 24) + ((int)ch2 << 16) + ((int)ch3 << 8) + ch4;
17+
}
18+
void read_Mnist(string filename, vector<cv::Mat> &vec)
19+
{
20+
ifstream file(filename, ios::binary);
21+
if (file.is_open()) {
22+
int magic_number = 0;
23+
int number_of_images = 0;
24+
int n_rows = 0;
25+
int n_cols = 0;
26+
file.read((char*)&magic_number, sizeof(magic_number));
27+
magic_number = ReverseInt(magic_number);
28+
file.read((char*)&number_of_images, sizeof(number_of_images));
29+
number_of_images = ReverseInt(number_of_images);
30+
file.read((char*)&n_rows, sizeof(n_rows));
31+
n_rows = ReverseInt(n_rows);
32+
file.read((char*)&n_cols, sizeof(n_cols));
33+
n_cols = ReverseInt(n_cols);
34+
for (int i = 0; i < number_of_images; ++i) {
35+
cv::Mat tp = cv::Mat::zeros(n_rows, n_cols, CV_8UC1);
36+
for (int r = 0; r < n_rows; ++r) {
37+
for (int c = 0; c < n_cols; ++c) {
38+
unsigned char temp = 0;
39+
file.read((char*)&temp, sizeof(temp));
40+
tp.at<uchar>(r, c) = (int)temp;
41+
}
42+
}
43+
vec.push_back(tp);
44+
}
45+
}
46+
}
47+
void read_Mnist_Label(string filename, vector<int> &vec)
48+
{
49+
ifstream file(filename, ios::in | ios::binary);
50+
if (file.is_open()) {
51+
int magic_number = 0;
52+
int number_of_images = 0;
53+
int n_rows = 0;
54+
int n_cols = 0;
55+
file.read((char*)&magic_number, sizeof(magic_number));
56+
magic_number = ReverseInt(magic_number);
57+
file.read((char*)&number_of_images, sizeof(number_of_images));
58+
number_of_images = ReverseInt(number_of_images);
59+
for (int i = 0; i < number_of_images; ++i) {
60+
unsigned char temp = 0;
61+
file.read((char*)&temp, sizeof(temp));
62+
vec[i] = (int)temp;
63+
}
64+
}
65+
}
66+
string GetImageName(int number, int arr[])
67+
{
68+
string str1, str2;
69+
for (int i = 0; i < 10; i++) {
70+
if (number == i) {
71+
arr[i]++;
72+
char ch1[10];
73+
sprintf(ch1, "%d", arr[i]);
74+
str1 = std::string(ch1);
75+
if (arr[i] < 10) {
76+
str1 = "0000" + str1;
77+
}
78+
else if (arr[i] < 100) {
79+
str1 = "000" + str1;
80+
}
81+
else if (arr[i] < 1000) {
82+
str1 = "00" + str1;
83+
}
84+
else if (arr[i] < 10000) {
85+
str1 = "0" + str1;
86+
}
87+
break;
88+
}
89+
}
90+
char ch2[10];
91+
sprintf(ch2, "%d", number);
92+
str2 = std::string(ch2);
93+
str2 = str2 + "_" + str1;
94+
95+
return str2;
96+
}
97+
98+
99+
int main1(int argc, char *argv[])
100+
{
101+
//reference: http://eric-yuan.me/cpp-read-mnist/
102+
//test images and test labels
103+
//read MNIST image into OpenCV Mat vector
104+
FILE* fpTrain = fopen("examples/trainLabel.txt", "w+");
105+
FILE* fpTest = fopen("examples/testLabel.txt", "w+");
106+
if (argc < 6) {
107+
std::cout << "please input parameters!" << std::endl;
108+
return 0;
109+
}
110+
string filename_test_images = argv[1];
111+
int number_of_test_images = 10000;
112+
vector<cv::Mat> vec_test_images;
113+
read_Mnist(filename_test_images, vec_test_images);
114+
115+
//read MNIST label into int vector
116+
string filename_test_labels = argv[2];
117+
vector<int> vec_test_labels(number_of_test_images);
118+
read_Mnist_Label(filename_test_labels, vec_test_labels);
119+
120+
if (vec_test_images.size() != vec_test_labels.size()) {
121+
cout << "parse MNIST test file error" << endl;
122+
return -1;
123+
}
124+
//save test images
125+
int count_digits[10];
126+
for (int i = 0; i < 10; i++)
127+
count_digits[i] = 0;
128+
string save_test_images_path = argv[3];
129+
130+
for (unsigned int i = 0; i < vec_test_images.size(); i++) {
131+
int number = vec_test_labels[i];
132+
string image_name = GetImageName(number, count_digits);
133+
image_name = save_test_images_path + image_name + ".jpg";
134+
// cv::imwrite(image_name, vec_test_images[i]);
135+
136+
string str;
137+
// image_name = image_name.substr(14,11);
138+
str = image_name + " " + std::to_string(number);
139+
int length = str.length();
140+
fwrite(str.c_str(), length, 1, fpTest);
141+
fputc('\n', fpTest);
142+
}
143+
//train images and train labels
144+
//read MNIST image into OpenCV Mat vector
145+
string filename_train_images = argv[4];
146+
int number_of_train_images = 60000;
147+
vector<cv::Mat> vec_train_images;
148+
read_Mnist(filename_train_images, vec_train_images);
149+
150+
//read MNIST label into int vector
151+
string filename_train_labels = argv[5];
152+
vector<int> vec_train_labels(number_of_train_images);
153+
read_Mnist_Label(filename_train_labels, vec_train_labels);
154+
155+
if (vec_train_images.size() != vec_train_labels.size()) {
156+
cout << "parse MNIST train file error" << endl;
157+
return -1;
158+
}
159+
//save train images
160+
for (int i = 0; i < 10; i++)
161+
count_digits[i] = 0;
162+
string save_train_images_path = argv[6];
163+
164+
for (size_t i = 0; i < vec_train_images.size(); i++) {
165+
int number = vec_train_labels[i];
166+
string image_name = GetImageName(number, count_digits);
167+
image_name = save_train_images_path + image_name + ".jpg";
168+
// cv::imwrite(image_name, vec_train_images[i]);
169+
170+
string str;
171+
// image_name = image_name.substr(15, 11);
172+
str = image_name + " " + std::to_string(number);
173+
int length = str.length();
174+
fwrite(str.c_str(), length, 1, fpTrain);
175+
fputc('\n', fpTrain);
176+
}
177+
fclose(fpTest);
178+
fclose(fpTrain);
179+
return 0;
180+
}

0 commit comments

Comments
 (0)