質問編集履歴
2
説明追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -130,6 +130,66 @@
|
|
130
130
|
|
131
131
|
|
132
132
|
|
133
|
+
pose_detector.pyには、このように書かれています。
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
```python
|
138
|
+
|
139
|
+
if __name__ == '__main__':
|
140
|
+
|
141
|
+
parser = argparse.ArgumentParser(description='Pose detector')
|
142
|
+
|
143
|
+
parser.add_argument('arch', choices=params['archs'].keys(), default='posenet', help='Model architecture')
|
144
|
+
|
145
|
+
parser.add_argument('weights', help='weights file path')
|
146
|
+
|
147
|
+
parser.add_argument('--img', '-i', default=None, help='image file path')
|
148
|
+
|
149
|
+
parser.add_argument('--gpu', '-g', type=int, default=-1, help='GPU ID (negative value indicates CPU)')
|
150
|
+
|
151
|
+
parser.add_argument('--precise', action='store_true', help='do precise inference')
|
152
|
+
|
153
|
+
args = parser.parse_args()
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
chainer.config.enable_backprop = False
|
158
|
+
|
159
|
+
chainer.config.train = False
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
# load model
|
164
|
+
|
165
|
+
pose_detector = PoseDetector(args.arch, args.weights, device=args.gpu, precise=args.precise)
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
# read image
|
170
|
+
|
171
|
+
img = cv2.imread(args.img)
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
# inference
|
176
|
+
|
177
|
+
poses, _ = pose_detector(img)
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
# draw and save image
|
182
|
+
|
183
|
+
img = draw_person_pose(img, poses)
|
184
|
+
|
185
|
+
print('Saving result into result.png...')
|
186
|
+
|
187
|
+
cv2.imwrite('result.png', img)
|
188
|
+
|
189
|
+
```
|
190
|
+
|
191
|
+
|
192
|
+
|
133
193
|
どうすれば、--imgの読み込みができるのでしょうか。
|
134
194
|
|
135
195
|
ご回答よろしくおねがいします。
|
1
タイトル
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
python for文中での%run
|
1
|
+
python for文中での%runを実行するとエラーが出る。
|
test
CHANGED
File without changes
|