Cyril666 commited on
Commit
0fdb9e6
·
1 Parent(s): 682a278

First model version

Browse files
Files changed (2) hide show
  1. app.py +5 -2
  2. det_demo.py +3 -1
app.py CHANGED
@@ -25,8 +25,11 @@ def infer(filepath):
25
  )
26
  image = cv2.imread(filepath)
27
  result_polygons, result_masks, result_boxes = det_demo.run_on_opencv_image(image)
28
- visual_image = det_demo.visualization(image, result_polygons, result_masks, result_boxes)
29
- cv2.imwrite('result.jpg', image)
 
 
 
30
  return 'result.jpg'#, pd.DataFrame(result_words)
31
 
32
 
 
25
  )
26
  image = cv2.imread(filepath)
27
  result_polygons, result_masks, result_boxes = det_demo.run_on_opencv_image(image)
28
+ patchs = [image[box[1]:box[3], box[0]:box[2], :] for box in result_boxes]
29
+ patchs = [cv2.resize(patch, (128,32)) for patch in patchs]
30
+ patchs = np.stack(patchs, axis=0).transpose(0,3,1,2)
31
+ visual_image = det_demo.visualization(image.copy(), result_polygons, result_masks, result_boxes)
32
+ cv2.imwrite('result.jpg', visual_image)
33
  return 'result.jpg'#, pd.DataFrame(result_words)
34
 
35
 
det_demo.py CHANGED
@@ -580,8 +580,10 @@ class DetDemo(object):
580
  green[...,2] = 0
581
  for mask in masks:
582
  image[mask] = image[mask] * 0.5 + green[mask] * 0.5
 
583
  for box in boxes:
584
- cv2.rectangle(image,(box[0], box[1]), (box[2], box[3]), (0,0,255), 5)
 
585
  '''
586
  for polygon in polygons:
587
  pts = np.array(polygon, np.int32)
 
580
  green[...,2] = 0
581
  for mask in masks:
582
  image[mask] = image[mask] * 0.5 + green[mask] * 0.5
583
+ '''
584
  for box in boxes:
585
+ cv2.rectangle(image,(box[0], box[1]), (box[2], box[3]), (0,0,255), 2)
586
+ '''
587
  '''
588
  for polygon in polygons:
589
  pts = np.array(polygon, np.int32)