yangwu commited on
Commit
0595a8e
1 Parent(s): b33e395

update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -4,15 +4,20 @@ import requests
4
 
5
 
6
  def test():
 
7
  url = 'http://81.70.158.155:5005/predict'
8
  with open('./2680.jpg', 'rb') as f:
9
- r = requests.post(url, files = {'image' : f})
10
- ret = json.loads(r.text)
 
 
 
 
11
 
12
  # image level cls score
13
  pred_cls_score = ret['cls_score']
14
  print('--------', pred_cls_score)
15
-
16
 
17
  def predict(img):
18
  url = 'http://81.70.158.155:5005/predict'
 
4
 
5
 
6
  def test():
7
+ print('testing backend interface...')
8
  url = 'http://81.70.158.155:5005/predict'
9
  with open('./2680.jpg', 'rb') as f:
10
+ try:
11
+ r = requests.post(url, files = {'image' : f}, timeout=10)
12
+ ret = json.loads(r.text)
13
+ except Exception as e:
14
+ print('backend test failed')
15
+ return
16
 
17
  # image level cls score
18
  pred_cls_score = ret['cls_score']
19
  print('--------', pred_cls_score)
20
+ print('backend test success')
21
 
22
  def predict(img):
23
  url = 'http://81.70.158.155:5005/predict'