Spaces:
Running
Running
| // Augmentation feature definitions | |
| export const augmentationFeatures = [ | |
| { id: 'rotation', name: 'Rotation/Tilt', min: 0, max: 30, default: 5 }, | |
| { id: 'skew', name: 'Skew/Perspective', min: 0, max: 20, default: 3 }, | |
| { id: 'gaussian_blur', name: 'Gaussian Blur', min: 0, max: 5, default: 1 }, | |
| { id: 'motion_blur', name: 'Motion Blur', min: 0, max: 10, default: 3 }, | |
| { id: 'gaussian_noise', name: 'Gaussian Noise', min: 0, max: 50, default: 10 }, | |
| { id: 'salt_pepper', name: 'Salt & Pepper', min: 0, max: 10, default: 1 }, | |
| { id: 'brightness', name: 'Brightness Var.', min: 0, max: 50, default: 15 }, | |
| { id: 'contrast', name: 'Contrast Var.', min: 0, max: 100, default: 20 }, | |
| { id: 'jpeg_quality', name: 'JPEG Artifacts', min: 0, max: 100, default: 70 }, | |
| { id: 'resolution', name: 'Resolution Loss', min: 0, max: 80, default: 30 }, | |
| { id: 'paper_texture', name: 'Paper Texture', min: 0, max: 100, default: 50 }, | |
| { id: 'shadow', name: 'Shadow/Lighting', min: 0, max: 100, default: 30 }, | |
| { id: 'ink_bleed', name: 'Ink Bleed', min: 0, max: 100, default: 20 }, | |
| ] | |
| export interface TextFileInfo { | |
| name: string | |
| wordCount: number | |
| lineCount: number | |
| charCount: number | |
| maxSamples: { | |
| character: number | |
| word: number | |
| line: number | |
| sentence: number | |
| ngram: number | |
| } | |
| parsedData: { | |
| characters: string[] | |
| words: string[] | |
| lines: string[] | |
| sentences: string[] | |
| ngrams: string[] | |
| } | |
| } | |
| export interface AppConfig { | |
| dataset: { | |
| size: number | |
| seed: number | |
| } | |
| input: { | |
| segmentation: string | |
| file?: string | |
| } | |
| image: { | |
| width: number | |
| height: number | |
| background: string | |
| backgroundStyle: string | |
| backgroundMode: 'single' | 'mix' | |
| backgroundPercentages: Record<string, number> | |
| customBackgrounds: { name: string; dataUrl: string; percentage: number }[] | |
| textColor: string | |
| direction: string | |
| } | |
| fonts: { | |
| distribution: { family: string; percentage: number; name?: string; dataUrl?: string }[] | |
| } | |
| augmentation: { | |
| enabled: boolean | |
| applyPercentage: number | |
| preset: string | |
| customMode: boolean | |
| values: Record<string, number> | |
| } | |
| output: { | |
| formats: string[] | |
| } | |
| } | |
| export function getDefaultConfig(): AppConfig { | |
| return { | |
| dataset: { | |
| size: 100, | |
| seed: 42, | |
| }, | |
| input: { | |
| segmentation: 'word', | |
| }, | |
| image: { | |
| width: 256, | |
| height: 64, | |
| background: '#FFFFFF', | |
| backgroundStyle: 'clean_white', | |
| backgroundMode: 'single', | |
| backgroundPercentages: { | |
| clean_white: 100, aged_paper: 0, book_page: 0, newspaper: 0, | |
| notebook: 0, parchment: 0, weathered: 0, coffee_stain: 0, | |
| old_book: 0, recycled: 0, cream: 0, ivory: 0 | |
| }, | |
| customBackgrounds: [], | |
| textColor: '#000000', | |
| direction: 'rtl', | |
| }, | |
| fonts: { | |
| distribution: [], | |
| }, | |
| augmentation: { | |
| enabled: true, | |
| applyPercentage: 70, | |
| preset: 'balanced', | |
| customMode: false, | |
| values: Object.fromEntries(augmentationFeatures.map(f => [f.id, f.default])), | |
| }, | |
| output: { | |
| formats: ['crnn', 'trocr'], | |
| }, | |
| } | |
| } | |