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)