質問編集履歴

6

誤字

2017/12/06 04:31

投稿

TyoNgc
TyoNgc

スコア14

test CHANGED
File without changes
test CHANGED
@@ -223,3 +223,7 @@
223
223
  (80, 80, 3)
224
224
 
225
225
  (80, 80, 3)
226
+
227
+
228
+
229
+ ファイル名が重複し画像が上書きされている。最終的に4枚の画像しか作成されない。

5

プログラムの追加

2017/12/06 04:30

投稿

TyoNgc
TyoNgc

スコア14

test CHANGED
File without changes
test CHANGED
@@ -135,3 +135,91 @@
135
135
  実行結果
136
136
 
137
137
  プログラムのエラーは発生しないが、ディレクトリ内の画像に変化なし
138
+
139
+
140
+
141
+ 変更後のプログラム(2回目)
142
+
143
+ ```python
144
+
145
+ ...
146
+
147
+ for i in images:
148
+
149
+ if i == "Thumbs.db":
150
+
151
+ continue
152
+
153
+
154
+
155
+ image = np.array(Image.open("./data1/"+i))
156
+
157
+ array_list.append(i)
158
+
159
+ cropped = tf.random_crop(image, [height, width, 3])
160
+
161
+
162
+
163
+ with tf.Session() as sess:
164
+
165
+ coord = tf.train.Coordinator()
166
+
167
+ threads = tf.train.start_queue_runners(coord=coord)
168
+
169
+
170
+
171
+ for a in range(4):
172
+
173
+ image = sess.run(cropped)
174
+
175
+ print(image.shape)
176
+
177
+ Image.fromarray(np.uint8(image)).save('./data1/img{}.jpg'.format(a))
178
+
179
+ ```
180
+
181
+ 実行結果
182
+
183
+ (80, 80, 3)
184
+
185
+ (80, 80, 3)
186
+
187
+ (80, 80, 3)
188
+
189
+ (80, 80, 3)
190
+
191
+ (80, 80, 3)
192
+
193
+ (80, 80, 3)
194
+
195
+ (80, 80, 3)
196
+
197
+ (80, 80, 3)
198
+
199
+ (80, 80, 3)
200
+
201
+ (80, 80, 3)
202
+
203
+ (80, 80, 3)
204
+
205
+ (80, 80, 3)
206
+
207
+ (80, 80, 3)
208
+
209
+ (80, 80, 3)
210
+
211
+ (80, 80, 3)
212
+
213
+ (80, 80, 3)
214
+
215
+ (80, 80, 3)
216
+
217
+ (80, 80, 3)
218
+
219
+ (80, 80, 3)
220
+
221
+ (80, 80, 3)
222
+
223
+ (80, 80, 3)
224
+
225
+ (80, 80, 3)

4

プログラムの追加

2017/12/06 04:11

投稿

TyoNgc
TyoNgc

スコア14

test CHANGED
File without changes
test CHANGED
@@ -65,3 +65,73 @@
65
65
  Image.fromarray(np.uint8(img)).save('./data1/img{}.jpg'.format(i))
66
66
 
67
67
  ```
68
+
69
+
70
+
71
+
72
+
73
+ 変更後のプログラム
74
+
75
+ ```python
76
+
77
+ # -*- coding:utf-8 -*-
78
+
79
+ import tensorflow as tf
80
+
81
+ import numpy as np
82
+
83
+ import os
84
+
85
+ from PIL import Image
86
+
87
+
88
+
89
+ height = 80
90
+
91
+ width = 80
92
+
93
+
94
+
95
+ images = os.listdir("./data1/")
96
+
97
+ array_list = []
98
+
99
+
100
+
101
+ for i in images:
102
+
103
+ if i == "Thumbs.db":
104
+
105
+ continue
106
+
107
+
108
+
109
+ image = np.array(Image.open("./data1/"+i))
110
+
111
+ array_list.append(i)
112
+
113
+ cropped = tf.random_crop(image, [height, width, 3])
114
+
115
+
116
+
117
+ with tf.Session() as sess:
118
+
119
+ coord = tf.train.Coordinator()
120
+
121
+ threads = tf.train.start_queue_runners(coord=coord)
122
+
123
+
124
+
125
+ for a in range(4):
126
+
127
+ image = sess.run(cropped)
128
+
129
+ print(image.shape)
130
+
131
+ Image.formarray(np.unit8(image)).save('./data1/img{}.jpg'.format(a))
132
+
133
+ ```
134
+
135
+ 実行結果
136
+
137
+ プログラムのエラーは発生しないが、ディレクトリ内の画像に変化なし

3

誤字

2017/12/05 12:24

投稿

TyoNgc
TyoNgc

スコア14

test CHANGED
File without changes
test CHANGED
@@ -25,6 +25,8 @@
25
25
 
26
26
 
27
27
  images = os.listdir("./data1/")
28
+
29
+ array_list = []
28
30
 
29
31
 
30
32
 

2

誤字

2017/12/01 14:00

投稿

TyoNgc
TyoNgc

スコア14

test CHANGED
File without changes
test CHANGED
@@ -1,6 +1,6 @@
1
1
  Tensorflowでディレクトリ内にある画像を一括で水増ししたいのですが、このコードだと最後の画像のみしか水増しされません。for文をうまく使えば実行できると思うのですがどなたかご教授ください。
2
2
 
3
- 参考にしたサイト: https://endoyuta.com/2017/01/23/tensorflow-%E5%AD%A6%E7%BF%92%E7%B2%BE%E5%BA%A6%E3%82%92%E4%B8%8A%E3%81%92%E3%82%8B%E3%81%9F%E3%82%81%E3%81%AB%E7%94%BB%E5%83%8F%E5%8A%A0%E5%B7%A5%E3%81%97%E3%81%A6%E5%A2%97%E3%82%84%E3%81%99/
3
+ [参考にしたサイト](https://endoyuta.com/2017/01/23/tensorflow-%E5%AD%A6%E7%BF%92%E7%B2%BE%E5%BA%A6%E3%82%92%E4%B8%8A%E3%81%92%E3%82%8B%E3%81%9F%E3%82%81%E3%81%AB%E7%94%BB%E5%83%8F%E5%8A%A0%E5%B7%A5%E3%81%97%E3%81%A6%E5%A2%97%E3%82%84%E3%81%99/)
4
4
 
5
5
  このサイトと同じようなことがしたいです。
6
6
 

1

誤字

2017/12/01 07:16

投稿

TyoNgc
TyoNgc

スコア14

test CHANGED
File without changes
test CHANGED
@@ -1,6 +1,6 @@
1
1
  Tensorflowでディレクトリ内にある画像を一括で水増ししたいのですが、このコードだと最後の画像のみしか水増しされません。for文をうまく使えば実行できると思うのですがどなたかご教授ください。
2
2
 
3
- 参考にしたサイト: https://endoyuta.com/2017/01/23/tensorflow-学習精度を上げるために画像加工して増やす/
3
+ 参考にしたサイト: https://endoyuta.com/2017/01/23/tensorflow-%E5%AD%A6%E7%BF%92%E7%B2%BE%E5%BA%A6%E3%82%92%E4%B8%8A%E3%81%92%E3%82%8B%E3%81%9F%E3%82%81%E3%81%AB%E7%94%BB%E5%83%8F%E5%8A%A0%E5%B7%A5%E3%81%97%E3%81%A6%E5%A2%97%E3%82%84%E3%81%99/
4
4
 
5
5
  このサイトと同じようなことがしたいです。
6
6