質問するログイン新規登録

質問編集履歴

3

2019/09/11 14:23

投稿

trafalbad
trafalbad

スコア303

title CHANGED
File without changes
body CHANGED
@@ -6,6 +6,7 @@
6
6
 
7
7
 
8
8
  ```python
9
+ # 画像の読み込み
9
10
  get_ipython().system('wget -O test.jpg https://images.pexels.com/photos/242829/pexels-photo-242829.jpeg')
10
11
  filename = 'test.jpg'
11
12
 
@@ -21,7 +22,7 @@
21
22
  f = image.read()
22
23
  b = bytearray(f)
23
24
 
24
-
25
+ # エンドポイントで推論
25
26
  endpoint_response = boto3.client('sagemaker-runtime').invoke_endpoint(
26
27
  EndpointName='semantic-segmentation',
27
28
  Body=b,

2

2019/09/11 14:23

投稿

trafalbad
trafalbad

スコア303

title CHANGED
File without changes
body CHANGED
@@ -6,6 +6,28 @@
6
6
 
7
7
 
8
8
  ```python
9
+ get_ipython().system('wget -O test.jpg https://images.pexels.com/photos/242829/pexels-photo-242829.jpeg')
10
+ filename = 'test.jpg'
11
+
12
+ im = PIL.Image.open(filename)
13
+ im.thumbnail([800,600],PIL.Image.ANTIALIAS)
14
+ im.save(filename, "JPEG")
15
+
16
+
17
+ get_ipython().run_line_magic('matplotlib', 'inline')
18
+ plt.imshow(im)
19
+ plt.axis('off')
20
+ with open(filename, 'rb') as image:
21
+ f = image.read()
22
+ b = bytearray(f)
23
+
24
+
25
+ endpoint_response = boto3.client('sagemaker-runtime').invoke_endpoint(
26
+ EndpointName='semantic-segmentation',
27
+ Body=b,
28
+ ContentType='image/jpeg'
29
+ )
30
+ results = endpoint_response['Body'].read()
9
31
  detections = json.loads(results)
10
32
  >>>
11
33
  UnicodeDecodeError: 'utf-8' codec can't decode byte 0x93 in position 0: invalid start byte

1

追記

2019/09/11 14:21

投稿

trafalbad
trafalbad

スコア303

title CHANGED
File without changes
body CHANGED
File without changes