
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Ocr_tools is a Python library that generates synthetic images containing Khmer text and other important toolbox
Collection of functions to work with ocr and synthetic data generater
You can install the Khmer Text Image Generator using pip:
pip install ocr_toolkits
from ocr_toolkits import move_files_ext
# Move all files from 'src' directory to 'dst' directory
move_files_ext(
src_dir = 'src',
dst_dir = 'dst1',
)
# Move only .jpg files from 'src' directory to 'dst' directory
move_files_ext(
src_dir = 'src',
dst_dir = 'dst1',
ext = '.jpg'
)
from ocr_toolkits import change_files_ext
# Example usage
change_files_ext(
src_dir ='src',
dst_dir = 'dst',
ext = '.png'
)
from ocr_toolkits import delete_files_ext
delete_files_ext(
dir = 'dst',
ext = '.jpg',
)
from ocr_toolkits.postprocess import autocorrect_gender
corrected_gender_eng = autocorrect_gender("ប្រុ", return_eng=False)
print(corrected_gender_eng) # Output: Male
# Example usage with return_eng=False (Cambodian output)
corrected_gender_kh = autocorrect_gender("ស្រ", return_eng=False)
print(corrected_gender_kh) # Output: ស្រី
from ocr_toolkits import resize_image
resized_image = resize_image(
image_path='./images/img.jpg',
width=555,
height=555,
save=True,
save_path='save.jpg'
)
create text file to words list eg. dict.txt and put all khmer words you want to gnerate or download sample data here
create a folder call font and download all font from this link : font
create python script to generate data eg. test.py
from khmerocr_tools import synthetic_data
# Set parameters
image_height = 128
output_folder = 'output'
output_labels_file = 'output/labels.txt'
text_file_path = "dict.txt"
font_option = [1, 2]
# Generate images and labels
synthetic_data(
text_file_path,
image_height,
output_folder,
output_labels_file,
font_option=font_option,
random_blur=True
)
image_height
: Height of the generated images in pixels.output_folder
: Path to the folder where generated images will be saved.output_labels_file
: Path to the file where labels will be saved.text_file_path
: Path to the text file containing Khmer text for generation.font_option
: List of integers representing font options.
random_blur
: Boolean flag indicating whether to apply random blur effect to images.This project is licensed under the MIT License - see the LICENSE file for details.
FAQs
Ocr_tools is a Python library that generates synthetic images containing Khmer text and other important toolbox
We found that ocr-toolkits demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.