@@ -30,34 +30,50 @@ from alibabacloud_tea_rpc.models import Config
30
30
31
31
''' ImageSearch Example'''
32
32
33
-
34
- f = open (' pic.jpg' , ' rb' )
35
- # init Request
36
- request = SearchImageByPicAdvanceRequest(
37
- instance_name = ' name' ,
38
- pic_content_object = f
39
- )
40
-
41
- # init Config
42
- config = Config(
43
- access_key_id = ' <your_accsee_key_id>' ,
44
- access_key_secret = ' <your_access_key_secret>' ,
45
- endpoint = ' <your_endpoint>' ,
46
- region_id = ' cn-shanghai' ,
47
- type = ' access_key'
48
- )
49
-
50
- # init RuntimeObject
51
- runtime_option = RuntimeOptions()
52
-
53
- # init Client
54
- client = Client(config)
55
-
56
- # call api
57
- response = client.search_image_by_pic_advance(request, runtime_option)
58
-
59
- print (response.to_map())
60
- f.close()
33
+ with open (' pic.jpg' , ' rb' ) as f:
34
+ # init Request
35
+ request = SearchImageByPicAdvanceRequest(
36
+ instance_name = ' name' ,
37
+ pic_content_object = f
38
+ )
39
+
40
+ # init Config
41
+ config = Config(
42
+ access_key_id = ' <your_accsee_key_id>' ,
43
+ access_key_secret = ' <your_access_key_secret>' ,
44
+ endpoint = ' <your_endpoint>' ,
45
+ region_id = ' cn-shanghai' ,
46
+ type = ' access_key'
47
+ )
48
+
49
+ # init RuntimeObject
50
+ runtime_option = RuntimeOptions()
51
+
52
+ # init Client
53
+ client = Client(config)
54
+
55
+ # call api
56
+ response = client.search_image_by_pic_advance(request, runtime_option)
57
+
58
+ print (response)
59
+ print (' request id:' , response.request_id)
60
+ print (' code:' , response.code)
61
+ print (' message:' , response.msg)
62
+
63
+ # head
64
+ print (' docs return:' , response.head.docs_return)
65
+ print (' docs found:' , response.head.docs_found)
66
+ print (' search time:' , response.head.search_time)
67
+
68
+ # pic info
69
+ print (' category id:' , response.pic_info.category_id)
70
+ print (' region:' , response.pic_info.region)
71
+ print (' all categories:' , response.pic_info.all_categories)
72
+
73
+ # Auctions
74
+ for aut in response.auctions:
75
+ print (' category id:' , aut.category_id)
76
+ print (' product id:' , aut.product_id)
61
77
```
62
78
63
79
## Parameter Specification
0 commit comments