質問編集履歴
4
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -4,14 +4,13 @@
|
|
4
4
|
[https://github.com/totti0223/deepstomata](https://github.com/totti0223/deepstomata)
|
5
5
|
モデルが上手く復元できてないようです。
|
6
6
|
実行したモデルはVGG16を用いて学習させました。
|
7
|
-
原因は恐らく該当ソースコードとモデルの構造が一致していないことが原因と考えているのですが、
|
8
|
-
学習モデルをこれにどう対応させていいのかが分からないです。
|
9
7
|
このエラー自体の解決方法などご助言などいただければ幸いです。
|
10
8
|
よろしくお願いします。
|
11
|
-
|
9
|
+
[追記]
|
12
|
-
|
10
|
+
画像分類のコードが以下のリンクにあるutils.pyで動いています。その中の466行目から486行目でckptファイルの読み込みを行っています。
|
11
|
+
[https://github.com/totti0223/deepstomata/blob/master/deepstomata/utils.py](https://github.com/totti0223/deepstomata/blob/master/deepstomata/utils.py)
|
12
|
+
ここのサイト[https://louis-needless.hatenablog.com/entry/notfounderror-bully-me](https://louis-needless.hatenablog.com/entry/notfounderror-bully-me)を参考にarg_scopeをutils.pyの467行目に入れて行いましたが、上手くいきませんでした。
|
13
13
|
### 発生している問題・エラーメッセージ
|
14
|
-
|
15
14
|
```
|
16
15
|
>>> from deepstomata import *
|
17
16
|
>>> deepstomata("C:/Users/Rx-80/OneDrive/デスクトップ/研究室/stomata/201216/WT mock")
|
@@ -74,76 +73,42 @@
|
|
74
73
|
### 該当のソースコード
|
75
74
|
|
76
75
|
```python
|
77
|
-
import tensorflow as tf
|
78
|
-
|
76
|
+
with vgg.arg_scope(arg_scope):
|
79
|
-
|
77
|
+
net, end_points = vgg.vgg_16.vgg_16_50(input=input)
|
78
|
+
def stomata_stat_batch_classify(image, region_number, ckpt_path):
|
80
79
|
|
80
|
+
'''
|
81
|
+
input
|
82
|
+
image : image read by scipy. imread if by opencv, bgr to rgb must be performed
|
83
|
+
ckpt_path : checkpoint absolute path
|
84
|
+
output
|
85
|
+
most likely stat of stomata, confidential level of most likely stat of stomata
|
86
|
+
'''
|
87
|
+
DST_INPUT_SIZE = 56
|
88
|
+
NUM_CLASS = 4
|
89
|
+
tf.reset_default_graph()
|
81
90
|
|
91
|
+
image = tf.reshape(image, [-1, DST_INPUT_SIZE, DST_INPUT_SIZE, 3])
|
82
|
-
|
92
|
+
logits = stomata_model.tf_inference(image, region_number, DST_INPUT_SIZE, NUM_CLASS)
|
83
93
|
|
94
|
+
sess = tf.InteractiveSession()
|
95
|
+
saver = tf.train.Saver()
|
96
|
+
sess.run(tf.global_variables_initializer())
|
97
|
+
if ckpt_path:
|
98
|
+
saver.restore(sess, ckpt_path)
|
99
|
+
softmax = tf.nn.softmax(logits).eval()
|
100
|
+
results = [[None for _ in range(2)] for _ in range(region_number)]
|
101
|
+
q = 0
|
102
|
+
for logit in softmax:
|
103
|
+
logit = [round(n * 100, 1) for n in logit]
|
104
|
+
logit = np.asarray(logit)
|
105
|
+
result = [["open", logit[0]], ["closed", logit[1]], ["partially_open", logit[2]], ["false_positive", logit[3]]]
|
84
|
-
|
106
|
+
result = sorted(result, key =lambda x: int(x[1]), reverse = True)
|
85
|
-
|
107
|
+
results[q][0] = result[0][0]
|
108
|
+
results[q][1] = result[0][1]
|
86
|
-
|
109
|
+
q += 1
|
87
|
-
weight_decay = tf.mul(tf.nn.l2_loss(var), wd, name='weight_loss')
|
88
|
-
|
110
|
+
#print ("\t",results)
|
89
|
-
|
111
|
+
return results
|
90
|
-
|
91
|
-
def _activation_summary(x):
|
92
|
-
tensor_name = x.op.name
|
93
|
-
tf.scalar_summary(tensor_name + '/sparsity', tf.nn.zero_fraction(x))
|
94
|
-
|
95
|
-
with tf.variable_scope('conv1') as scope:
|
96
|
-
kernel = tf.get_variable('weights', shape=[3, 3, 3, 32], initializer=tf.truncated_normal_initializer(stddev=0.1))
|
97
|
-
conv = tf.nn.conv2d(images, kernel, [1, 1, 1, 1], padding='SAME')
|
98
|
-
biases = tf.get_variable('biases', shape=[32], initializer=tf.constant_initializer(0.0))
|
99
|
-
bias = tf.nn.bias_add(conv, biases)
|
100
|
-
conv1 = tf.nn.relu(bias, name=scope.name)
|
101
|
-
pool1 = tf.nn.max_pool(conv1, ksize=[1, 3, 3, 1], strides=[1, 2, 2, 1], padding='SAME', name='pool1')
|
102
|
-
|
103
|
-
with tf.variable_scope('conv2') as scope:
|
104
|
-
kernel = tf.get_variable('weights', shape=[3, 3, 32, 64], initializer=tf.truncated_normal_initializer(stddev=0.1))
|
105
|
-
conv = tf.nn.conv2d(pool1, kernel, [1, 1, 1, 1], padding='SAME')
|
106
|
-
biases = tf.get_variable('biases', shape=[64], initializer=tf.constant_initializer(0.0))
|
107
|
-
bias = tf.nn.bias_add(conv, biases)
|
108
|
-
conv2 = tf.nn.relu(bias, name=scope.name)
|
109
|
-
pool2 = tf.nn.max_pool(conv2, ksize=[1, 3, 3, 1], strides=[1, 2, 2, 1], padding='SAME', name='pool2')
|
110
|
-
|
111
|
-
with tf.variable_scope('conv3') as scope:
|
112
|
-
kernel = tf.get_variable('weights', shape=[3, 3, 64, 128], initializer=tf.truncated_normal_initializer(stddev=0.1))
|
113
|
-
conv = tf.nn.conv2d(pool2, kernel, [1, 1, 1, 1], padding='SAME')
|
114
|
-
biases = tf.get_variable('biases', shape=[128], initializer=tf.constant_initializer(0.0))
|
115
|
-
bias = tf.nn.bias_add(conv, biases)
|
116
|
-
conv3 = tf.nn.relu(bias, name=scope.name)
|
117
|
-
pool3 = tf.nn.max_pool(conv3, ksize=[1, 3, 3, 1], strides=[1, 2, 2, 1], padding='SAME', name='pool3')
|
118
|
-
|
119
|
-
with tf.variable_scope('conv4') as scope:
|
120
|
-
kernel = tf.get_variable('weights', shape=[3, 3, 128, 256], initializer=tf.truncated_normal_initializer(stddev=0.1))
|
121
|
-
conv = tf.nn.conv2d(pool3, kernel, [1, 1, 1, 1], padding='SAME')
|
122
|
-
biases = tf.get_variable('biases', shape=[256], initializer=tf.constant_initializer(0.0))
|
123
|
-
bias = tf.nn.bias_add(conv, biases)
|
124
|
-
conv4 = tf.nn.relu(bias, name=scope.name)
|
125
|
-
pool4 = tf.nn.max_pool(conv4, ksize=[1, 3, 3, 1], strides=[1, 2, 2, 1], padding='SAME', name='pool4')
|
126
|
-
|
127
|
-
with tf.variable_scope('fc5') as scope:
|
128
|
-
dim = 1
|
129
|
-
for d in pool4.get_shape()[1:].as_list():
|
130
|
-
dim *= d
|
131
|
-
reshape = tf.reshape(pool4, [BATCH_SIZE, dim])
|
132
|
-
weights = _variable_with_weight_decay('weights', shape=[dim, 1024], stddev=0.02, wd=0.005)
|
133
|
-
biases = tf.get_variable('biases', shape=[1024], initializer=tf.constant_initializer(0.0))
|
134
|
-
fc5 = tf.nn.relu(tf.nn.bias_add(tf.matmul(reshape, weights), biases), name=scope.name)
|
135
|
-
|
136
|
-
with tf.variable_scope('fc6') as scope:
|
137
|
-
weights = _variable_with_weight_decay('weights', shape=[1024, 256], stddev=0.02, wd=0.005)
|
138
|
-
biases = tf.get_variable('biases', shape=[256], initializer=tf.constant_initializer(0.0))
|
139
|
-
fc6 = tf.nn.relu(tf.nn.bias_add(tf.matmul(fc5, weights), biases), name=scope.name)
|
140
|
-
|
141
|
-
with tf.variable_scope('fc7') as scope:
|
142
|
-
weights = tf.get_variable('weights', shape=[256, NUM_CLASSES], initializer=tf.truncated_normal_initializer(stddev=0.02))
|
143
|
-
biases = tf.get_variable('biases', shape=[NUM_CLASSES], initializer=tf.constant_initializer(0.0))
|
144
|
-
fc7 = tf.nn.bias_add(tf.matmul(fc6, weights), biases, name=scope.name)
|
145
|
-
|
146
|
-
return fc7
|
147
112
|
```
|
148
113
|
|
149
114
|
### 試したこと
|
@@ -161,4 +126,5 @@
|
|
161
126
|
keras 1.2.2
|
162
127
|
matplotlib 2.0.0
|
163
128
|
pandas 0.25.3
|
164
|
-
numpy 1.15.2
|
129
|
+
numpy 1.15.2
|
130
|
+
原因は恐らく[ここ](https://github.com/totti0223/deepstomata/blob/master/deepstomata/stomata_model.py)のコードとモデルの構造が一致していないことが原因と考えているのですが、学習モデルをこれにどう対応させていいのかが分からないです。
|
3
文言の修正
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
ckptファイル復元(Tensor name "xxx" not found in checkpoint files)
|
1
|
+
ckptファイル復元(Tensor name "xxx" not found in checkpoint files)ができません
|
body
CHANGED
@@ -8,6 +8,8 @@
|
|
8
8
|
学習モデルをこれにどう対応させていいのかが分からないです。
|
9
9
|
このエラー自体の解決方法などご助言などいただければ幸いです。
|
10
10
|
よろしくお願いします。
|
11
|
+
|
12
|
+
|
11
13
|
### 発生している問題・エラーメッセージ
|
12
14
|
|
13
15
|
```
|
2
タイトルの変更
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
Tensor name "xxx" not found in checkpoint filesについて
|
1
|
+
ckptファイル復元(Tensor name "xxx" not found in checkpoint files)について
|
body
CHANGED
File without changes
|
1
質問に若干の変更を加えました
title
CHANGED
File without changes
|
body
CHANGED
@@ -2,10 +2,11 @@
|
|
2
2
|
ckptファイルを用いた画像認識プログラムを実行した際に以下のようなエラーが出ました。
|
3
3
|
以下がそのプログラムのリンクです。
|
4
4
|
[https://github.com/totti0223/deepstomata](https://github.com/totti0223/deepstomata)
|
5
|
+
モデルが上手く復元できてないようです。
|
5
6
|
実行したモデルはVGG16を用いて学習させました。
|
6
7
|
原因は恐らく該当ソースコードとモデルの構造が一致していないことが原因と考えているのですが、
|
7
8
|
学習モデルをこれにどう対応させていいのかが分からないです。
|
8
|
-
ご助言などいただければ幸いです。
|
9
|
+
このエラー自体の解決方法などご助言などいただければ幸いです。
|
9
10
|
よろしくお願いします。
|
10
11
|
### 発生している問題・エラーメッセージ
|
11
12
|
|