質問編集履歴

3

文字コードの追加

2018/11/14 12:17

投稿

fufufu000
fufufu000

スコア29

test CHANGED
File without changes
test CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
 
4
4
 
5
+ 文字コード
6
+
7
+ sjis
8
+
5
9
  ```python
6
10
 
7
11
  # -*- coding: utf-8 -*-

2

エラーメッセージの追加

2018/11/14 12:17

投稿

fufufu000
fufufu000

スコア29

test CHANGED
File without changes
test CHANGED
@@ -202,8 +202,66 @@
202
202
 
203
203
  ### エラーメッセージ
204
204
 
205
+ C:\Users\saito\Anaconda3\envs\in_anaconda\python.exe C:/Users/saito/PycharmProjects/in_anaconda/views.py
206
+
207
+ * Serving Flask app "views" (lazy loading)
208
+
209
+ * Environment: production
210
+
211
+ WARNING: Do not use the development server in a production environment.
212
+
213
+ Use a production WSGI server instead.
214
+
215
+ * Debug mode: on
216
+
217
+ * Restarting with stat
218
+
219
+ * Debugger is active!
220
+
221
+ * Debugger PIN: 332-401-681
222
+
223
+ Exception in thread Thread-1:
224
+
225
+ Traceback (most recent call last):
226
+
227
+ File "C:\Users\saito\Anaconda3\envs\in_anaconda\lib\threading.py", line 916, in _bootstrap_inner
228
+
229
+ self.run()
230
+
231
+ File "C:\Users\saito\Anaconda3\envs\in_anaconda\lib\threading.py", line 864, in run
232
+
233
+ self._target(*self._args, **self._kwargs)
234
+
235
+ File "C:\Users\saito\Anaconda3\envs\in_anaconda\lib\site-packages\werkzeug\serving.py", line 774, in inner
236
+
237
+ fd=fd)
238
+
239
+ File "C:\Users\saito\Anaconda3\envs\in_anaconda\lib\site-packages\werkzeug\serving.py", line 660, in make_server
240
+
241
+ passthrough_errors, ssl_context, fd=fd)
242
+
243
+ File "C:\Users\saito\Anaconda3\envs\in_anaconda\lib\site-packages\werkzeug\serving.py", line 577, in __init__
244
+
245
+ self.address_family), handler)
246
+
247
+ File "C:\Users\saito\Anaconda3\envs\in_anaconda\lib\socketserver.py", line 453, in __init__
248
+
249
+ self.server_bind()
250
+
251
+ File "C:\Users\saito\Anaconda3\envs\in_anaconda\lib\http\server.py", line 138, in server_bind
252
+
253
+ self.server_name = socket.getfqdn(host)
254
+
255
+ File "C:\Users\saito\Anaconda3\envs\in_anaconda\lib\socket.py", line 673, in getfqdn
256
+
257
+ hostname, aliases, ipaddrs = gethostbyaddr(name)
258
+
205
259
  UnicodeDecodeError: 'utf-8' codec can't decode byte 0x82 in position 0: invalid start byte
206
260
 
207
261
 
208
262
 
263
+
264
+
265
+
266
+
209
267
  どのような処理をすれば実行できるかコメントお願いします!!

1

コードの追加

2018/11/14 07:48

投稿

fufufu000
fufufu000

スコア29

test CHANGED
File without changes
test CHANGED
@@ -1,17 +1,209 @@
1
- githubをpythonを起動させようとしているのですが、
2
-
3
1
  エラーが出てしまいます。
4
2
 
5
3
 
6
4
 
7
5
  ```python
8
6
 
7
+ # -*- coding: utf-8 -*-
8
+
9
+
10
+
11
+ from flask import *
12
+
13
+ import os
14
+
15
+ import json
16
+
17
+ import re
18
+
19
+ import sys
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+ app = Flask(__name__)
30
+
31
+ app.secret_key = '佐久間さん可愛い'
32
+
33
+
34
+
35
+ #画像の準備
36
+
37
+ image_ptrn = re.compile('.*[.](jpg|jpeg|png)|')
38
+
39
+ image_dir = os.path.join( 'TrainingAssistant','static', 'img' )
40
+
41
+ images = []
42
+
43
+ images = [ image for image in os.listdir( image_dir ) if re.match( image_ptrn, image ) ]
44
+
45
+ if not len( images ):
46
+
47
+ sys.exit( 'Error: Could not find images')
48
+
49
+
50
+
51
+ logf = open('log.dat', 'w')
52
+
53
+
54
+
55
+ pos = 0
56
+
57
+
58
+
59
+ @app.route('/')
60
+
61
+ def index():
62
+
63
+
64
+
65
+ global pos
66
+
67
+
68
+
69
+ #正例と負例用のファイル
70
+
71
+ global positive
72
+
73
+ global negative
74
+
75
+
76
+
77
+ positive = open('info.dat', 'a')
78
+
79
+ negative = open('bg.txt', 'a')
80
+
81
+
82
+
83
+ #最初の画像
84
+
85
+ imgsrc = os.path.join( image_dir, images[pos] )
86
+
87
+ imgnum = len(images)
88
+
89
+ count = pos
90
+
91
+ counter = ''.join( [ str(pos+1).zfill( len(str(imgnum)) ), ' of ', str(imgnum) ] )
92
+
93
+
94
+
95
+ return render_template( 'index.html', imgsrc=imgsrc, imgnum=imgnum, count=count, counter=counter )
96
+
97
+
98
+
99
+ @app.route('/_next')
100
+
101
+ def _next():
102
+
103
+
104
+
105
+ global pos
106
+
107
+
108
+
109
+ #その画像をスキップするか
110
+
111
+ skip = request.args.get('skip')
112
+
113
+
114
+
115
+ if skip == u'0':
116
+
117
+
118
+
119
+ #囲まれた範囲の座標
120
+
121
+ coords = request.args.get('coords')
122
+
123
+ coords = json.loads(coords)
124
+
125
+
126
+
127
+ #処理中の画像のパス
128
+
129
+ image_path = os.path.join( image_dir, images[pos] )
130
+
131
+
132
+
133
+ #正例か負例か
134
+
135
+ if len(coords) == 0:
136
+
137
+ negative.write( ''.join( [ image_path, '\n' ] ) )
138
+
139
+ logf.write( ''.join( [ image_path, '\n' ] ) )
140
+
141
+ logf.flush()
142
+
143
+
144
+
145
+ else:
146
+
147
+ s = ''
148
+
149
+ for coord in coords:
150
+
151
+ s = ' '.join( [ s, ' '.join( [ str(int(e)) for e in coord ] ) ] )
152
+
153
+
154
+
155
+ positive.write('%s %d%s\n' % (image_path, len(coords), s))
156
+
157
+ logf.write( "%s %d%s\n" % (image_path, len(coords), s) )
158
+
159
+ logf.flush()
160
+
161
+
162
+
163
+ #まだ画像があるか
164
+
165
+ if pos+1 >= len(images):
166
+
167
+ imgsrc = ""
168
+
169
+ finished = True
170
+
171
+ pos = pos + 1
172
+
173
+ logf.close()
174
+
175
+ negative.close()
176
+
177
+ positive.close()
178
+
179
+ else:
180
+
181
+ finished = False
182
+
183
+ imgsrc = os.path.join( image_dir, images[pos+1] )
184
+
185
+ pos = pos + 1
186
+
187
+
188
+
189
+ return jsonify( imgsrc=imgsrc, finished=finished, count=pos )
190
+
191
+
192
+
193
+ if __name__ == '__main__':
194
+
195
+ app.debug = True
196
+
197
+ app.run()
198
+
199
+
200
+
201
+ ```
202
+
203
+ ### エラーメッセージ
204
+
9
205
  UnicodeDecodeError: 'utf-8' codec can't decode byte 0x82 in position 0: invalid start byte
10
206
 
11
207
 
12
208
 
13
- ```
14
-
15
-
16
-
17
209
  どのような処理をすれば実行できるかコメントお願いします!!