Using the IBM Maximo Visual Inspection API key (Object Counting)

Ilustrasi-1: Login Page IBM Maximo Visual Insoection
Ilustrasi2: Home Page IBM Maximo Visual Inspection
Ilustrasi-3: Create Dataset
Ilustrasi-4: labeling Database
Ilustrasi-5: Augment Data Optional
Ilustrasi-6: Create Augment Data
Ilustrasi-7: Augment Data Result
Ilustrasi-8: Training Model Option
Ilustrasi-9: Training Model Process
Ilustrasi-10: Training Model Result
Ilustrasi-11: Deploy Model
Ilustrasi-12: Test Model Result
Ilustarsi-13: REST API Key Model.
import requests
import json
MAXIMO_URL = "<URL_API_KEY_IBM_Maximo_Visual_Inspection>"
s = requests.Session()def detect_objects(filename):with open(filename, 'rb') as f:
# WARNING! verify=False is here to allow an untrusted cert!
r = s.post(MAXIMO_URL,
files={'files': (filename, f)},
verify=False)
return r.status_code, json.loads(r.text)
rc, jsonresp = detect_objects('C:/Users/LENOVO/Downloads/chiken2.jpg')print("rc = %d" % rc)
print("jsonresp: %s" % jsonresp)
if 'classified' in jsonresp:
print("Got back %d objects" % len(jsonresp['classified']))
print(json.dumps(jsonresp, indent=2))
rc = 200
jsonresp: {'webAPIId': '5383da7e-07cb-4365-9b12-ae3855985874', 'imageUrl': 'http://dtemas-service:9080/dtemas-api/uploads/temp/5383da7e-07cb-4365-9b12-ae3855985874/8b2cad9d-51f3-4455-bcee-fd34803770d9.jpg', 'imageMd5': '27b8f85d2864f05a6b719dd92607056f', 'classified': [{'confidence': 0.9802093505859375, 'ymax': 794, 'label': 'ayam', 'xmax': 826, 'xmin': 184, 'ymin': 516, 'polygons': [[[277, 546], [242, 576], [242, 642], [184, 693], [184, 728], [230, 754], [230, 769], [289, 794], [663, 794], [686, 784], [698, 754], [756, 703], [756, 657], [803, 617], [780, 586], [721, 561], [651, 561], [593, 546], [534, 546], [464, 531], [370, 541], [312, 566]]]}, {'confidence': 0.9995076656341553, 'ymax': 334, 'label': 'ayam', 'xmax': 1422, 'xmin': 1094, 'ymin': 60, 'polygons': [[[1273, 60], [1273, 79], [1243, 104], [1237, 99], [1189, 119], [1171, 119], [1129, 149], [1105, 219], [1129, 259], [1153, 274], [1255, 314], [1273, 329], [1291, 324], [1303, 334], [1321, 334], [1422, 279], [1422, 134], [1327, 74], [1315, 60]]]}, {'confidence': 0.9991470575332642, 'ymax': 309, 'label': 'ayam', 'xmax': 823, 'xmin': 519, 'ymin': 65, 'polygons': [[[557, 96], [519, 154], [519, 203], [546, 229], [657, 287], [768, 296], [823, 274], [823, 225], [790, 185], [768, 131], [718, 78], [685, 65], [602, 65]]]}, {'confidence': 0.9908936023712158, 'ymax': 505, 'label': 'ayam', 'xmax': 556, 'xmin': 231, 'ymin': 186, 'polygons': [[[231, 244], [231, 308], [296, 360], [390, 395], [426, 424], [420, 430], [479, 488], [521, 488], [556, 465], [556, 395], [479, 331], [462, 273], [390, 186], [302, 186]]]}, {'confidence': 0.9977471232414246, 'ymax': 212, 'label': 'ayam', 'xmax': 1141, 'xmin': 774, 'ymin': 0, 'polygons': [[[787, 19], [780, 61], [840, 112], [914, 154], [914, 166], [941, 181], [974, 181], [1014, 166], [1021, 170], [1054, 158], [1088, 158], [1141, 120], [1141, 65], [1048, 0], [974, 0], [934, 19], [914, 19], [881, 0], [814, 0], [814, 7]]]}, {'confidence': 0.9977855682373047, 'ymax': 531, 'label': 'ayam', 'xmax': 1304, 'xmin': 967, 'ymin': 294, 'polygons': [[[1120, 298], [1077, 306], [1046, 328], [1016, 371], [967, 410], [967, 462], [1016, 497], [1034, 497], [1102, 523], [1151, 531], [1163, 523], [1194, 518], [1243, 488], [1304, 402], [1292, 393], [1280, 358], [1255, 345], [1261, 341], [1249, 332], [1212, 324], [1169, 302], [1163, 306]]]}, {'confidence': 0.9962655901908875, 'ymax': 610, 'label': 'ayam', 'xmax': 306, 'xmin': 6, 'ymin': 286, 'polygons': [[[6, 286], [6, 469], [16, 480], [44, 492], [109, 486], [164, 540], [219, 610], [252, 610], [306, 569], [306, 545], [290, 516], [246, 469], [246, 445], [235, 427], [241, 421], [213, 350], [159, 286]]]}, {'confidence': 0.9960111379623413, 'ymax': 666, 'label': 'ayam', 'xmax': 962, 'xmin': 626, 'ymin': 310, 'polygons': [[[877, 322], [858, 316], [711, 342], [662, 387], [662, 400], [626, 439], [626, 511], [650, 556], [632, 582], [626, 576], [626, 595], [644, 582], [675, 627], [687, 621], [705, 640], [693, 666], [760, 666], [779, 627], [766, 601], [766, 582], [779, 569], [834, 627], [864, 640], [889, 666], [950, 666], [962, 653], [962, 621], [938, 576], [920, 478], [926, 459], [901, 387], [907, 368]]]}], 'result': 'success'}
Got back 8 objects
{
"webAPIId": "5383da7e-07cb-4365-9b12-ae3855985874",
"imageUrl": "http://dtemas-service:9080/dtemas-api/uploads/temp/5383da7e-07cb-4365-9b12-ae3855985874/8b2cad9d-51f3-4455-bcee-fd34803770d9.jpg",
"imageMd5": "27b8f85d2864f05a6b719dd92607056f",
"classified": [
{
"confidence": 0.9802093505859375,
"ymax": 794,
"label": "ayam",
"xmax": 826,
"xmin": 184,
"ymin": 516,
"polygons": [
[
[
277,
546
],
[
242,
576
],
[
242,
642
],
[
184,
693
],
[
184,
728
],
[
230,
754
],
[
230,
769
],
[
289,
794
],
[
663,
794
],
[
686,
784
],
[
698,
754
],
[
756,
703
],
[
756,
657
],
[
803,
617
],
[
780,
586
],
[
721,
561
],
[
651,
561
],
[
593,
546
],
[
534,
546
],
[
464,
531
],
[
370,
541
],
[
312,
566
]
]
]
},
{
"confidence": 0.9995076656341553,
"ymax": 334,
"label": "ayam",
"xmax": 1422,
"xmin": 1094,
"ymin": 60,
"polygons": [
[
[
1273,
60
],
[
1273,
79
],
[
1243,
104
],
[
1237,
99
],
[
1189,
119
],
[
1171,
119
],
[
1129,
149
],
[
1105,
219
],
[
1129,
259
],
[
1153,
274
],
[
1255,
314
],
[
1273,
329
],
[
1291,
324
],
[
1303,
334
],
[
1321,
334
],
[
1422,
279
],
[
1422,
134
],
[
1327,
74
],
[
1315,
60
]
]
]
},
{
"confidence": 0.9991470575332642,
"ymax": 309,
"label": "ayam",
"xmax": 823,
"xmin": 519,
"ymin": 65,
"polygons": [
[
[
557,
96
],
[
519,
154
],
[
519,
203
],
[
546,
229
],
[
657,
287
],
[
768,
296
],
[
823,
274
],
[
823,
225
],
[
790,
185
],
[
768,
131
],
[
718,
78
],
[
685,
65
],
[
602,
65
]
]
]
},
{
"confidence": 0.9908936023712158,
"ymax": 505,
"label": "ayam",
"xmax": 556,
"xmin": 231,
"ymin": 186,
"polygons": [
[
[
231,
244
],
[
231,
308
],
[
296,
360
],
[
390,
395
],
[
426,
424
],
[
420,
430
],
[
479,
488
],
[
521,
488
],
[
556,
465
],
[
556,
395
],
[
479,
331
],
[
462,
273
],
[
390,
186
],
[
302,
186
]
]
]
},
{
"confidence": 0.9977471232414246,
"ymax": 212,
"label": "ayam",
"xmax": 1141,
"xmin": 774,
"ymin": 0,
"polygons": [
[
[
787,
19
],
[
780,
61
],
[
840,
112
],
[
914,
154
],
[
914,
166
],
[
941,
181
],
[
974,
181
],
[
1014,
166
],
[
1021,
170
],
[
1054,
158
],
[
1088,
158
],
[
1141,
120
],
[
1141,
65
],
[
1048,
0
],
[
974,
0
],
[
934,
19
],
[
914,
19
],
[
881,
0
],
[
814,
0
],
[
814,
7
]
]
]
},
{
"confidence": 0.9977855682373047,
"ymax": 531,
"label": "ayam",
"xmax": 1304,
"xmin": 967,
"ymin": 294,
"polygons": [
[
[
1120,
298
],
[
1077,
306
],
[
1046,
328
],
[
1016,
371
],
[
967,
410
],
[
967,
462
],
[
1016,
497
],
[
1034,
497
],
[
1102,
523
],
[
1151,
531
],
[
1163,
523
],
[
1194,
518
],
[
1243,
488
],
[
1304,
402
],
[
1292,
393
],
[
1280,
358
],
[
1255,
345
],
[
1261,
341
],
[
1249,
332
],
[
1212,
324
],
[
1169,
302
],
[
1163,
306
]
]
]
},
{
"confidence": 0.9962655901908875,
"ymax": 610,
"label": "ayam",
"xmax": 306,
"xmin": 6,
"ymin": 286,
"polygons": [
[
[
6,
286
],
[
6,
469
],
[
16,
480
],
[
44,
492
],
[
109,
486
],
[
164,
540
],
[
219,
610
],
[
252,
610
],
[
306,
569
],
[
306,
545
],
[
290,
516
],
[
246,
469
],
[
246,
445
],
[
235,
427
],
[
241,
421
],
[
213,
350
],
[
159,
286
]
]
]
},
{
"confidence": 0.9960111379623413,
"ymax": 666,
"label": "ayam",
"xmax": 962,
"xmin": 626,
"ymin": 310,
"polygons": [
[
[
877,
322
],
[
858,
316
],
[
711,
342
],
[
662,
387
],
[
662,
400
],
[
626,
439
],
[
626,
511
],
[
650,
556
],
[
632,
582
],
[
626,
576
],
[
626,
595
],
[
644,
582
],
[
675,
627
],
[
687,
621
],
[
705,
640
],
[
693,
666
],
[
760,
666
],
[
779,
627
],
[
766,
601
],
[
766,
582
],
[
779,
569
],
[
834,
627
],
[
864,
640
],
[
889,
666
],
[
950,
666
],
[
962,
653
],
[
962,
621
],
[
938,
576
],
[
920,
478
],
[
926,
459
],
[
901,
387
],
[
907,
368
]
]
]
}
],
"result": "success"
}
if 'classified' in jsonresp:
print("Got %d Chiken" % len(jsonresp['classified']))
Got 8 Chiken

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store