Vivien Chappelier commited on
Commit
8798e5f
1 Parent(s): 2148bab

add script to detect with api

Browse files
Files changed (1) hide show
  1. detect_api.py +16 -0
detect_api.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+ import base64
3
+ import sys
4
+
5
+ def detect_api(filename):
6
+ b64 = base64.b64encode(open(sys.argv[1], 'rb').read()).decode('utf8')
7
+ data = dict(image = b64)
8
+ response = requests.post('https://bzh.imatag.com/bzh/api/v1.0/detect',
9
+ json=data)
10
+ if response.json()['p-value'] < 1e-3:
11
+ print("watermark detected")
12
+ else:
13
+ print("no watermark detected")
14
+
15
+ if __name__ == '__main__':
16
+ detect_api(sys.argv[1])