crystalchen commited on
Commit
4a96f2b
·
verified ·
1 Parent(s): 16b2b23

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -10
app.py CHANGED
@@ -1,10 +1,10 @@
1
  ## Set Environment
2
  import os
3
- os.system('python -m venv .env')
4
- os.system('source .env/bin/activate')
5
  ## Install poppler in os
6
- os.system('apt-get update')
7
- os.system('apt-get install poppler-utils')
8
  ##
9
 
10
  from pdf2image import convert_from_path
@@ -65,14 +65,11 @@ def destamp_image(img_path):
65
  upper_black = np.array([180,255,120])
66
  mask = cv2.inRange(hsv_img, lower_black, upper_black)
67
  deRed_img = ~mask # Single channel image
68
- # imshow mask
69
- #print(f"deRed_img shape: {deRed_img.shape}")
70
- #show_image(deRed_img)
71
 
72
  # thresholding -2
73
  ret, threshold_img_2 = cv2.threshold(deRed_img, 120, 255, cv2.THRESH_BINARY | cv2.THRESH_OTSU)
74
- #print(f' threshold-2 shape: {threshold_img_2.shape}')
75
- #show_image(threshold_img_2)
76
 
77
 
78
  # Desired shape: (x, y, 1)
@@ -81,7 +78,7 @@ def destamp_image(img_path):
81
  # Resize using numpy.resize()
82
  result_img = np.resize(threshold_img_2, new_shape)
83
  print(f"result_img.shape: {result_img.shape}")
84
- cv2.imshow(result_img)
85
 
86
  #save result_img
87
  result_filepath="result_img_0.png"
 
1
  ## Set Environment
2
  import os
3
+ #os.system('python -m venv .env')
4
+ #os.system('source .env/bin/activate')
5
  ## Install poppler in os
6
+ #os.system('apt-get update')
7
+ #os.system('apt-get install poppler-utils')
8
  ##
9
 
10
  from pdf2image import convert_from_path
 
65
  upper_black = np.array([180,255,120])
66
  mask = cv2.inRange(hsv_img, lower_black, upper_black)
67
  deRed_img = ~mask # Single channel image
68
+
 
 
69
 
70
  # thresholding -2
71
  ret, threshold_img_2 = cv2.threshold(deRed_img, 120, 255, cv2.THRESH_BINARY | cv2.THRESH_OTSU)
72
+
 
73
 
74
 
75
  # Desired shape: (x, y, 1)
 
78
  # Resize using numpy.resize()
79
  result_img = np.resize(threshold_img_2, new_shape)
80
  print(f"result_img.shape: {result_img.shape}")
81
+ #cv2.imshow(result_img)
82
 
83
  #save result_img
84
  result_filepath="result_img_0.png"