File size: 947 Bytes
608d66a
96c3387
 
50b15ac
7ed7084
7473ed1
50b15ac
 
 
 
 
96c3387
50b15ac
 
 
 
608d66a
96c3387
608d66a
0b64d6e
e195121
96c3387
50b15ac
 
608d66a
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
from paddleocr import PaddleOCR
import gradio as gr

# โหลด OCR โมเดลภาษา Chinese (Simplified) ครั้งเดียว
ocr = PaddleOCR(use_angle_cls=False, lang='ch', use_gpu=True,use_fp16=True)

# ฟังก์ชัน inference
def inference(img):
    result = ocr.ocr(img, cls=False)[0]  # cls=True ถ้าต้องการหมุนภาพอัตโนมัติ
    txts = [line[1][0] for line in result]
    return '\n'.join(txts)

# Gradio Interface
title = 'PaddleOCR Chinese Demo'
description = 'Upload an image and extract Chinese text using PaddleOCR.'
#examples = [['example.jpg']]  # ต้องมีไฟล์ example.jpg ในโฟลเดอร์เดียวกัน

gr.Interface(
    fn=inference,
    inputs=gr.Image(type='filepath', label='Input Image'),
    outputs="text",
    title=title,
    description=description,
  #  examples=examples
).launch(debug=True)