biodatlab / ocr-skooldio

OCR Notebooks and Lectures for Skooldio
MIT License
0 stars 3 forks source link

OCR Skooldio

ยินดีต้อนรับสู่บทเรียน Optical Character Recognition (OCR) สอนโดย Skooldio! บทเรียนนี้ออกแบบมาเพื่อช่วยให้ผู้เริ่มต้นทดลองใช้เทคนิคการรู้จำอักขระด้วยแสง (OCR) เหมาะสำหรับผู้เริ่มต้นทำ OCR หรือกำลังมองหาวิธีทำความเข้าใจว่าเครื่องมือและโมเดลต่างๆ ทำงานอย่างไร ที่เก็บข้อมูลนี้ให้บทนำที่ครอบคลุมเกี่ยวกับการตรวจจับและรู้จำข้อความ

OCR เป็นเทคโนโลยีที่สำคัญสำหรับการแปลงเอกสารประเภทต่างๆ เช่น เอกสารกระดาษที่สแกน ไฟล์ PDF หรือภาพที่ถ่ายด้วยกล้องดิจิทัล ให้เป็นข้อมูลที่สามารถแก้ไขและค้นหาได้ ที่เก็บข้อมูลนี้นำเสนอชุดเครื่องมือและทรัพยากรเพื่อช่วยให้คุณสำรวจและทำความเข้าใจเทคนิค OCR ต่างๆ

เทคนิคที่ครอบคลุม

ในบทเรียน เราจะได้ทดลองเทคนิค OCR ที่หลากหลายโดยใช้เครื่องมือและโมเดลต่อไปนี้:

จริงๆแล้วยังมีไลบรารี่เกี่ยวกับ OCR อีกมากมาย สามารถทดลองดูเพิ่มเติมได้ที่ Github zacharywhitley/awesome-ocr

ข้อมูลเพิ่มเติม

วิธีสร้าง API Key จาก OpenAI

หลังจากได้ API key แล้วเราสามารถเรียกใช้ ChatGPT ผ่าน Python ได้ด้วยคำสั่ง

from openai import OpenAI
from IPython.display import display

OPENAI_API_KEY = "<api-key>" # ใส่ API key ที่นี่
client = OpenAI(api_key=OPENAI_API_KEY)

def get_completion(prompt: str):
    response = client.chat.completions.create(
        model="gpt-3.5-turbo",
        messages=[{"role": "user", "content": prompt}]
    )
    return response.choices[0].message.content.strip()

get_completion("Why is sky blue?")

วิธีสร้าง JSON Credential จาก Google Cloud Platform

from google.oauth2 import service_account
from google.cloud import aiplatform
from vertexai.generative_models import GenerativeModel

project_name = "<project-name>"
credentials = service_account.Credentials.from_service_account_file("<path-to-json>")
aiplatform.init(project=project_name, credentials=credentials)

model = GenerativeModel("gemini-1.5-flash-001")
print(model.generate_content("Why is sky blue?"))