File size: 901 Bytes
77f8d5f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from recognization import TextRecognition
import os
import argparse

# Define the argument parser
parser = argparse.ArgumentParser(description='Process an image.')
parser.add_argument('--image_name', type=str, required=False, default='2.png', help='Path to the image file')
parser.add_argument('--device', type=str, required=False, default='cpu', help='cpu or cuda')

# Parse the arguments
args = parser.parse_args()

# Get the image path from the command line
image_path = args.image_name
device = args.device

# Get current dir
current_dir = os.path.dirname(os.path.abspath(__file__))

# Get model path
model_path = os.path.join(current_dir , 'model/recognization_model.pth' )
recognizer = TextRecognition('model/recognization_model.pth' , device=device)

# Get image path
image_path = os.path.join(current_dir , f'data/{image_path}' )
result = recognizer.recognize_image(image_path)

print(result)