()
| 48 | |
| 49 | |
| 50 | def main() -> int: |
| 51 | parser = build_parser() |
| 52 | args = parser.parse_args() |
| 53 | if not args.image.exists(): |
| 54 | parser.error(f"文件 {args.image} 不存在") |
| 55 | |
| 56 | ocr = DdddOcr(ocr=True, det=False, beta=args.beta, old=args.old, show_ad=False) |
| 57 | |
| 58 | try: |
| 59 | data = args.image.read_bytes() |
| 60 | if args.probability: |
| 61 | result = ocr.classification( |
| 62 | data, |
| 63 | probability=True, |
| 64 | colors=list(args.colors), |
| 65 | ) |
| 66 | else: |
| 67 | result = ocr.classification( |
| 68 | data, |
| 69 | probability=False, |
| 70 | colors=list(args.colors), |
| 71 | ) |
| 72 | except (DdddOcrInputError, InvalidImageError) as exc: |
| 73 | parser.error(str(exc)) |
| 74 | return 1 |
| 75 | |
| 76 | print("识别结果:") |
| 77 | print(result) |
| 78 | return 0 |
| 79 | |
| 80 | |
| 81 | if __name__ == "__main__": |
no test coverage detected
searching dependent graphs…