phuochungus commited on
Commit
4f3205b
1 Parent(s): 494a6d9
Files changed (1) hide show
  1. app/routers/image.py +6 -6
app/routers/image.py CHANGED
@@ -18,14 +18,14 @@ async def handleImageRequest(
18
  ):
19
  try:
20
  img = imfrombytes(file, cv2.IMREAD_COLOR)
21
- except:
22
- raise Response(content="Failed to read image", status_code=400)
 
23
 
24
- if raw:
25
- bboxes, labels = inferenceImage(img, threshold, raw)
26
- return {"bboxes": bboxes.tolist(), "labels": labels.tolist()}
27
 
28
- img = inferenceImage(img, threshold, raw)
29
  ret, jpeg = cv2.imencode(".jpg", img)
30
 
31
  if not ret:
 
18
  ):
19
  try:
20
  img = imfrombytes(file, cv2.IMREAD_COLOR)
21
+ if raw:
22
+ bboxes, labels = inferenceImage(img, threshold, True)
23
+ return {"bboxes": bboxes.tolist(), "labels": labels.tolist()}
24
 
25
+ img = inferenceImage(img, threshold, False)
26
+ except:
27
+ return Response(content="Failed to read image", status_code=400)
28
 
 
29
  ret, jpeg = cv2.imencode(".jpg", img)
30
 
31
  if not ret: