質問編集履歴
3
test
CHANGED
File without changes
|
test
CHANGED
@@ -13,6 +13,8 @@
|
|
13
13
|
|
14
14
|
|
15
15
|
```python
|
16
|
+
|
17
|
+
# 画像の読み込み
|
16
18
|
|
17
19
|
get_ipython().system('wget -O test.jpg https://images.pexels.com/photos/242829/pexels-photo-242829.jpeg')
|
18
20
|
|
@@ -44,7 +46,7 @@
|
|
44
46
|
|
45
47
|
|
46
48
|
|
47
|
-
|
49
|
+
# エンドポイントで推論
|
48
50
|
|
49
51
|
endpoint_response = boto3.client('sagemaker-runtime').invoke_endpoint(
|
50
52
|
|
2
test
CHANGED
File without changes
|
test
CHANGED
@@ -13,6 +13,50 @@
|
|
13
13
|
|
14
14
|
|
15
15
|
```python
|
16
|
+
|
17
|
+
get_ipython().system('wget -O test.jpg https://images.pexels.com/photos/242829/pexels-photo-242829.jpeg')
|
18
|
+
|
19
|
+
filename = 'test.jpg'
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
im = PIL.Image.open(filename)
|
24
|
+
|
25
|
+
im.thumbnail([800,600],PIL.Image.ANTIALIAS)
|
26
|
+
|
27
|
+
im.save(filename, "JPEG")
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
get_ipython().run_line_magic('matplotlib', 'inline')
|
34
|
+
|
35
|
+
plt.imshow(im)
|
36
|
+
|
37
|
+
plt.axis('off')
|
38
|
+
|
39
|
+
with open(filename, 'rb') as image:
|
40
|
+
|
41
|
+
f = image.read()
|
42
|
+
|
43
|
+
b = bytearray(f)
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
endpoint_response = boto3.client('sagemaker-runtime').invoke_endpoint(
|
50
|
+
|
51
|
+
EndpointName='semantic-segmentation',
|
52
|
+
|
53
|
+
Body=b,
|
54
|
+
|
55
|
+
ContentType='image/jpeg'
|
56
|
+
|
57
|
+
)
|
58
|
+
|
59
|
+
results = endpoint_response['Body'].read()
|
16
60
|
|
17
61
|
detections = json.loads(results)
|
18
62
|
|
1
追記
test
CHANGED
File without changes
|
test
CHANGED
File without changes
|