pragnakalp commited on
Commit
47436d9
1 Parent(s): 061dadf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -79,7 +79,7 @@ def get_grayscale(image):
79
  # Thresholding or Binarization
80
  def thresholding(src):
81
  return cv2.threshold(src,127,255, cv2.THRESH_TOZERO)[1]
82
-
83
  def ocr_with_easy(img):
84
  gray_scale_image=get_grayscale(img)
85
  thresholding(gray_scale_image)
@@ -97,7 +97,7 @@ def generate_ocr(Method,img):
97
 
98
  print("Method___________________",Method)
99
  if Method == 'EasyOCR':
100
- text_output = ocr_with_easy(img)
101
  if Method == 'KerasOCR':
102
  text_output = ocr_with_keras(img)
103
  if Method == 'PaddleOCR':
@@ -127,11 +127,12 @@ def save_details(Method,text_output,img):
127
  if text_output:
128
  splitted_path = os.path.splitext(picture_path)
129
  modified_picture_path = splitted_path[0] + curr_datetime + splitted_path[1]
130
- # cv2.imwrite("/home/user/app/",modified_picture_path, img)
131
- with open('/home/user/app/readme.txt', 'a') as f:
132
  f.write(picture_path)
133
- img = Image.open(r"/home/user/app/")
134
- img.save(modified_picture_path)
 
135
  input_img = modified_picture_path
136
  try:
137
  df = pd.read_csv("AllDetails.csv")
 
79
  # Thresholding or Binarization
80
  def thresholding(src):
81
  return cv2.threshold(src,127,255, cv2.THRESH_TOZERO)[1]
82
+ readme.txt
83
  def ocr_with_easy(img):
84
  gray_scale_image=get_grayscale(img)
85
  thresholding(gray_scale_image)
 
97
 
98
  print("Method___________________",Method)
99
  if Method == 'EasyOCR':
100
+ text_output = ocr_withreadme.txt_easy(img)
101
  if Method == 'KerasOCR':
102
  text_output = ocr_with_keras(img)
103
  if Method == 'PaddleOCR':
 
127
  if text_output:
128
  splitted_path = os.path.splitext(picture_path)
129
  modified_picture_path = splitted_path[0] + curr_datetime + splitted_path[1]
130
+ cv2.imwrite("myimage.jpg", img)
131
+ with open('readme.txt', 'w') as f:
132
  f.write(picture_path)
133
+ print("write Successfully")
134
+ # img = Image.open(r"/home/user/app/")
135
+ # img.save(modified_picture_path)
136
  input_img = modified_picture_path
137
  try:
138
  df = pd.read_csv("AllDetails.csv")