Cyril666 commited on
Commit
e7d36e8
·
1 Parent(s): b49c894

First model version

Browse files
Files changed (2) hide show
  1. app.py +4 -4
  2. det_demo.py +3 -1
app.py CHANGED
@@ -1,8 +1,8 @@
1
  import os
2
- os.system('pip install --upgrade --no-cache-dir gdown')
3
- os.system('gdown -O ./output/ctw/model_ctw.pth 1nhT7yuqJ8V8vfoJdI0Qn6notmoLFRrmm')
4
  os.system('pip install "git+https://github.com/philferriere/cocoapi.git#egg=pycocotools&subdirectory=PythonAPI"')
5
  os.system('python setup.py build develop --user')
 
 
6
  #os.system('pip install git+https://github.com/Cyril-Sterling/ContourNet')
7
 
8
  import cv2
@@ -24,8 +24,8 @@ def infer(filepath):
24
  output_polygon=True
25
  )
26
  image = cv2.imread(filepath)
27
- result_polygons, result_masks = det_demo.run_on_opencv_image(image)
28
- image = det_demo.visualization(image, result_polygons, result_masks)
29
  cv2.imwrite('result.jpg', image)
30
  return 'result.jpg'#, pd.DataFrame(result_words)
31
 
 
1
  import os
 
 
2
  os.system('pip install "git+https://github.com/philferriere/cocoapi.git#egg=pycocotools&subdirectory=PythonAPI"')
3
  os.system('python setup.py build develop --user')
4
+ os.system('pip install --upgrade --no-cache-dir gdown')
5
+ os.system('gdown -O ./output/ctw/model_ctw.pth 1nhT7yuqJ8V8vfoJdI0Qn6notmoLFRrmm')
6
  #os.system('pip install git+https://github.com/Cyril-Sterling/ContourNet')
7
 
8
  import cv2
 
24
  output_polygon=True
25
  )
26
  image = cv2.imread(filepath)
27
+ result_polygons, result_masks, result_boxes = det_demo.run_on_opencv_image(image)
28
+ 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
 
det_demo.py CHANGED
@@ -499,7 +499,7 @@ class DetDemo(object):
499
  cv2.imwrite('./demo/example_results.jpg', im_write[:, :, ::-1])
500
  '''
501
 
502
- return contours, np.array(masks.repeat(1,3,1,1)).astype(np.bool_).transpose(0,2,3,1)
503
 
504
  def process_char_mask(self, char_masks, boxes, threshold=192):
505
  texts, rec_scores = [], []
@@ -580,6 +580,8 @@ class DetDemo(object):
580
  green[...,2] = 0
581
  for mask in masks:
582
  image[mask] = image[mask] * 0.5 + green[mask] * 0.5
 
 
583
  '''
584
  for polygon in polygons:
585
  pts = np.array(polygon, np.int32)
 
499
  cv2.imwrite('./demo/example_results.jpg', im_write[:, :, ::-1])
500
  '''
501
 
502
+ return contours, np.array(masks.repeat(1,3,1,1)).astype(np.bool_).transpose(0,2,3,1), boxes
503
 
504
  def process_char_mask(self, char_masks, boxes, threshold=192):
505
  texts, rec_scores = [], []
 
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,True,(0,0,255))
585
  '''
586
  for polygon in polygons:
587
  pts = np.array(polygon, np.int32)