An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:package: Bundle only the Tiny OCR model https://github.com/siyuan-note/siyuan/issues/19984
Danielfd646be4c063
diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.mdindex bb5e755ef8..8ce97215b6 100644--- a/THIRD_PARTY_NOTICES.md+++ b/THIRD_PARTY_NOTICES.md@@ -23,7 +23,7 @@ The component list is informational and does not replace the license terms. Copy| Electron | 42.7.1 | MIT | [upstream](https://github.com/electron/electron) | Desktop runtime; Electron also ships LICENSES.chromium.html for Chromium and its dependencies || ONNX Runtime | 1.24.3 (Windows, Linux, Apple Silicon, Android, HarmonyOS), 1.23.2 (Intel macOS), 1.24.2 (iOS) | MIT | [upstream](https://github.com/microsoft/onnxruntime) | Native CPU OCR runtime; license and dependency notices in app/stage/ocr/ONNXRUNTIME-LICENSE and ONNXRUNTIME-THIRD-PARTY-NOTICES.txt; desktop libraries also include their corresponding notices || Microsoft Visual C++ Runtime | 14.x from the release builder's licensed Visual Studio redist | Microsoft Visual Studio Software License Terms | [redistribution terms](https://learn.microsoft.com/en-us/visualstudio/releases/2022/redistribution#visual-c-runtime-files) | Windows OCR runtime directories include unmodified app-local CRT DLLs, MICROSOFT-VC-RUNTIME-NOTICE.txt, and vc-runtime-files.json with the exact file digests |-| PaddleOCR PP-OCRv6 Tiny and Small ONNX models | Pinned revisions in scripts/ocr-assets.json | Apache-2.0 | [official models](https://huggingface.co/collections/PaddlePaddle/pp-ocrv6) | app/stage/ocr/models/; license text in app/stage/ocr/PADDLEOCR-LICENSE |+| PaddleOCR PP-OCRv6 Tiny ONNX models | Pinned revisions in scripts/ocr-assets.json | Apache-2.0 | [official models](https://huggingface.co/collections/PaddlePaddle/pp-ocrv6) | app/stage/ocr/models/; license text in app/stage/ocr/PADDLEOCR-LICENSE || DOMPurify | 3.3.3 | Apache-2.0 OR MPL-2.0 | [upstream](https://github.com/cure53/DOMPurify) | app/stage/protyle/js/protyle-html.js || html-to-image | 1.11.13 | MIT | [upstream](https://github.com/bubkoo/html-to-image) | app/stage/protyle/js/html-to-image.min.js || modern-screenshot | 4.6.6 | MIT | [upstream](https://github.com/qq15725/modern-screenshot) | app/stage/protyle/js/modern-screenshot.min.js |diff --git a/app/appearance/langs/ar.json b/app/appearance/langs/ar.jsonindex 51775ccf6f..31dcb45f94 100644--- a/app/appearance/langs/ar.json+++ b/app/appearance/langs/ar.json@@ -41,7 +41,7 @@"ocrAuto": "OCR تلقائي","ocrAutoTip": "معالجة صور دفاتر الملاحظات العادية التي ليس لها نتيجة OCR بعد","ocrModel": "نموذج OCR",- "ocrModelTip": "Tiny وSmall مضمّنان؛ يحتفظ التبديل بالنتائج الحالية؛ أعد تشغيل OCR من قائمة الصورة",+ "ocrModelTip": "نموذج Tiny وحده مدمج؛ تبديل النموذج يحافظ على النتائج الحالية؛ أعد تشغيل OCR من قائمة الصورة","ocrImportModels": "استيراد نماذج OCR","ocrImportModelsTip": "اختر ملفات ONNX المتوافقة للكشف والتعرّف في PP-OCRv6 وملفات inference.yml الخاصة بها؛ تتزامن الملفات المستوردة مع مساحة العمل","ocrDetector": "نموذج الكشف",diff --git a/app/appearance/langs/de.json b/app/appearance/langs/de.jsonindex f4c6a5dd45..33ea603cae 100644--- a/app/appearance/langs/de.json+++ b/app/appearance/langs/de.json@@ -41,7 +41,7 @@"ocrAuto": "Automatische OCR","ocrAutoTip": "Bilder normaler Notizbücher ohne vorhandenes OCR-Ergebnis verarbeiten","ocrModel": "OCR-Modell",- "ocrModelTip": "Tiny und Small sind integriert; ein Wechsel behält Ergebnisse bei; OCR im Bildmenü erneut ausführen",+ "ocrModelTip": "Nur Tiny ist integriert; beim Wechsel bleiben vorhandene Ergebnisse erhalten; OCR lässt sich über das Bildmenü erneut ausführen","ocrImportModels": "OCR-Modelle importieren","ocrImportModelsTip": "Kompatible PP-OCRv6-ONNX-Dateien für Erkennung und Texterfassung sowie deren inference.yml auswählen; importierte Dateien werden mit dem Arbeitsbereich synchronisiert","ocrDetector": "Erkennungsmodell",diff --git a/app/appearance/langs/en.json b/app/appearance/langs/en.jsonindex 10ab9085a8..24680273b2 100644--- a/app/appearance/langs/en.json+++ b/app/appearance/langs/en.json@@ -41,7 +41,7 @@"ocrAuto": "Automatic OCR","ocrAutoTip": "Process ordinary notebook images that have no OCR result yet","ocrModel": "OCR model",- "ocrModelTip": "Tiny and Small are built in; switching preserves existing results; rerun OCR from the image menu",+ "ocrModelTip": "Only Tiny is built in; switching preserves existing results; rerun OCR from the image menu","ocrImportModels": "Import OCR models","ocrImportModelsTip": "Select compatible PP-OCRv6 detection and recognition ONNX files and their inference.yml files; imported files sync with the workspace","ocrDetector": "Detection model",diff --git a/app/appearance/langs/es.json b/app/appearance/langs/es.jsonindex 91fe42fc3a..c2f2269cdb 100644--- a/app/appearance/langs/es.json+++ b/app/appearance/langs/es.json@@ -41,7 +41,7 @@"ocrAuto": "OCR automático","ocrAutoTip": "Procesar imágenes de cuadernos normales que aún no tienen resultados de OCR","ocrModel": "Modelo de OCR",- "ocrModelTip": "Tiny y Small están integrados; cambiar conserva los resultados existentes; repita el OCR desde el menú de la imagen",+ "ocrModelTip": "Solo Tiny está integrado; cambiar de modelo conserva los resultados existentes; vuelve a ejecutar OCR desde el menú de la imagen","ocrImportModels": "Importar modelos de OCR","ocrImportModelsTip": "Seleccione archivos ONNX compatibles de detección y reconocimiento PP-OCRv6 y sus archivos inference.yml; los archivos importados se sincronizan con el espacio de trabajo","ocrDetector": "Modelo de detección",diff --git a/app/appearance/langs/fr.json b/app/appearance/langs/fr.jsonindex a093c021fe..4ae5e0fb64 100644--- a/app/appearance/langs/fr.json+++ b/app/appearance/langs/fr.json@@ -41,7 +41,7 @@"ocrAuto": "OCR automatique","ocrAutoTip": "Traiter les images des carnets ordinaires sans résultat OCR existant","ocrModel": "Modèle OCR",- "ocrModelTip": "Tiny et Small sont intégrés ; le changement conserve les résultats existants ; relancez l’OCR depuis le menu de l’image",+ "ocrModelTip": "Seul Tiny est intégré ; changer de modèle conserve les résultats existants ; relancez la reconnaissance depuis le menu de l’image","ocrImportModels": "Importer des modèles OCR","ocrImportModelsTip": "Sélectionnez les fichiers ONNX compatibles de détection et de reconnaissance PP-OCRv6 et leurs fichiers inference.yml ; les fichiers importés sont synchronisés avec l’espace de travail","ocrDetector": "Modèle de détection",diff --git a/app/appearance/langs/he.json b/app/appearance/langs/he.jsonindex 4cfafb4fa9..524285a369 100644--- a/app/appearance/langs/he.json+++ b/app/appearance/langs/he.json@@ -41,7 +41,7 @@"ocrAuto": "OCR אוטומטי","ocrAutoTip": "עיבוד תמונות במחברות רגילות שעדיין אין להן תוצאת OCR","ocrModel": "מודל OCR",- "ocrModelTip": "Tiny ו-Small מובנים; החלפה שומרת על התוצאות הקיימות; אפשר להריץ OCR שוב מתפריט התמונה",+ "ocrModelTip": "רק Tiny מובנה; החלפת מודל שומרת על התוצאות הקיימות; ניתן להפעיל OCR מחדש מתפריט התמונה","ocrImportModels": "ייבוא מודלי OCR","ocrImportModelsTip": "בחרו קובצי ONNX תואמים לזיהוי אזורים וטקסט של PP-OCRv6 ואת קובצי inference.yml שלהם; הקבצים המיובאים מסונכרנים עם סביבת העבודה","ocrDetector": "מודל זיהוי אזורים",diff --git a/app/appearance/langs/hi.json b/app/appearance/langs/hi.jsonindex cf65425b7d..9852b0f76a 100644--- a/app/appearance/langs/hi.json+++ b/app/appearance/langs/hi.json@@ -41,7 +41,7 @@"ocrAuto": "स्वचालित OCR","ocrAutoTip": "सामान्य नोटबुक की उन छवियों को संसाधित करें जिनका OCR परिणाम अभी नहीं है","ocrModel": "OCR मॉडल",- "ocrModelTip": "Tiny और Small अंतर्निहित हैं; बदलने पर मौजूदा परिणाम सुरक्षित रहते हैं; छवि मेनू से OCR दोबारा चलाएँ",+ "ocrModelTip": "केवल Tiny अंतर्निहित है; मॉडल बदलने पर मौजूदा परिणाम बने रहते हैं; चित्र मेनू से OCR फिर चलाएँ","ocrImportModels": "OCR मॉडल आयात करें","ocrImportModelsTip": "संगत PP-OCRv6 पहचान और पाठ-पठन ONNX फ़ाइलें तथा उनकी inference.yml फ़ाइलें चुनें; आयातित फ़ाइलें कार्यक्षेत्र के साथ सिंक होती हैं","ocrDetector": "पहचान मॉडल",diff --git a/app/appearance/langs/id.json b/app/appearance/langs/id.jsonindex b7bf596e54..2cc605da7a 100644--- a/app/appearance/langs/id.json+++ b/app/appearance/langs/id.json@@ -41,7 +41,7 @@"ocrAuto": "OCR otomatis","ocrAutoTip": "Proses gambar buku catatan biasa yang belum memiliki hasil OCR","ocrModel": "Model OCR",- "ocrModelTip": "Tiny dan Small sudah disertakan; pergantian mempertahankan hasil yang ada; ulangi OCR dari menu gambar",+ "ocrModelTip": "Hanya Tiny yang disertakan; pergantian model mempertahankan hasil yang ada; jalankan ulang OCR dari menu gambar","ocrImportModels": "Impor model OCR","ocrImportModelsTip": "Pilih berkas ONNX deteksi dan pengenalan PP-OCRv6 yang kompatibel beserta inference.yml masing-masing; berkas impor disinkronkan dengan ruang kerja","ocrDetector": "Model deteksi",diff --git a/app/appearance/langs/it.json b/app/appearance/langs/it.jsonindex ea8b1c9624..94c73b36d5 100644--- a/app/appearance/langs/it.json+++ b/app/appearance/langs/it.json@@ -41,7 +41,7 @@"ocrAuto": "OCR automatico","ocrAutoTip": "Elabora le immagini dei quaderni normali che non hanno ancora risultati OCR","ocrModel": "Modello OCR",- "ocrModelTip": "Tiny e Small sono integrati; il cambio conserva i risultati esistenti; ripetere l’OCR dal menu dell’immagine",+ "ocrModelTip": "Solo Tiny è integrato; il cambio di modello conserva i risultati esistenti; esegui nuovamente OCR dal menu dell’immagine","ocrImportModels": "Importa modelli OCR","ocrImportModelsTip": "Selezionare i file ONNX compatibili di rilevamento e riconoscimento PP-OCRv6 e i relativi inference.yml; i file importati vengono sincronizzati con lo spazio di lavoro","ocrDetector": "Modello di rilevamento",diff --git a/app/appearance/langs/ja.json b/app/appearance/langs/ja.jsonindex 3b04790395..5cdad8e3af 100644--- a/app/appearance/langs/ja.json+++ b/app/appearance/langs/ja.json@@ -41,7 +41,7 @@"ocrAuto": "自動 OCR","ocrAutoTip": "OCR 結果がまだない通常のノートブックの画像を処理します","ocrModel": "OCR モデル",- "ocrModelTip": "Tiny と Small は内蔵されています。切り替えても既存の結果は保持され、画像メニューから再認識できます",+ "ocrModelTip": "Tiny のみ内蔵されています。切り替えても既存の結果は保持され、画像メニューから再認識できます","ocrImportModels": "OCR モデルをインポート","ocrImportModelsTip": "対応する PP-OCRv6 の検出・認識 ONNX ファイルとそれぞれの inference.yml を選択します。インポートしたファイルはワークスペースと同期されます","ocrDetector": "検出モデル",diff --git a/app/appearance/langs/ko.json b/app/appearance/langs/ko.jsonindex 30477f81bc..f909569303 100644--- a/app/appearance/langs/ko.json+++ b/app/appearance/langs/ko.json@@ -41,7 +41,7 @@"ocrAuto": "자동 OCR","ocrAutoTip": "OCR 결과가 없는 일반 노트북 이미지만 처리합니다","ocrModel": "OCR 모델",- "ocrModelTip": "Tiny와 Small이 내장되어 있습니다. 변경해도 기존 결과는 유지되며 이미지 메뉴에서 다시 인식할 수 있습니다",+ "ocrModelTip": "Tiny만 내장되어 있습니다. 모델을 전환해도 기존 결과는 유지되며 이미지 메뉴에서 OCR을 다시 실행할 수 있습니다","ocrImportModels": "OCR 모델 가져오기","ocrImportModelsTip": "호환되는 PP-OCRv6 감지 및 인식 ONNX 파일과 각각의 inference.yml을 선택하세요. 가져온 파일은 작업 공간과 동기화됩니다","ocrDetector": "감지 모델",diff --git a/app/appearance/langs/nl.json b/app/appearance/langs/nl.jsonindex f1bfebdded..b18b418422 100644--- a/app/appearance/langs/nl.json+++ b/app/appearance/langs/nl.json@@ -41,7 +41,7 @@"ocrAuto": "Automatische OCR","ocrAutoTip": "Afbeeldingen in gewone notitieboeken zonder bestaand OCR-resultaat verwerken","ocrModel": "OCR-model",- "ocrModelTip": "Tiny en Small zijn ingebouwd; wisselen behoudt bestaande resultaten; voer OCR opnieuw uit via het afbeeldingsmenu",+ "ocrModelTip": "Alleen Tiny is ingebouwd; wisselen behoudt bestaande resultaten; voer OCR opnieuw uit via het afbeeldingsmenu","ocrImportModels": "OCR-modellen importeren","ocrImportModelsTip": "Selecteer compatibele PP-OCRv6-ONNX-bestanden voor detectie en herkenning en hun inference.yml-bestanden; geïmporteerde bestanden synchroniseren met de werkruimte","ocrDetector": "Detectiemodel",diff --git a/app/appearance/langs/pl.json b/app/appearance/langs/pl.jsonindex 26d7c039f9..02fcdffd3e 100644--- a/app/appearance/langs/pl.json+++ b/app/appearance/langs/pl.json@@ -41,7 +41,7 @@"ocrAuto": "Automatyczny OCR","ocrAutoTip": "Przetwarzaj obrazy w zwykłych notatnikach, które nie mają jeszcze wyniku OCR","ocrModel": "Model OCR",- "ocrModelTip": "Tiny i Small są wbudowane; zmiana zachowuje istniejące wyniki; ponów OCR z menu obrazu",+ "ocrModelTip": "Tylko Tiny jest wbudowany; zmiana modelu zachowuje istniejące wyniki; uruchom OCR ponownie z menu obrazu","ocrImportModels": "Importuj modele OCR","ocrImportModelsTip": "Wybierz zgodne pliki ONNX wykrywania i rozpoznawania PP-OCRv6 oraz ich pliki inference.yml; importowane pliki są synchronizowane z obszarem roboczym","ocrDetector": "Model wykrywania",diff --git a/app/appearance/langs/pt-BR.json b/app/appearance/langs/pt-BR.jsonindex 6d7e3cb704..e6268546d0 100644--- a/app/appearance/langs/pt-BR.json+++ b/app/appearance/langs/pt-BR.json@@ -41,7 +41,7 @@"ocrAuto": "OCR automático","ocrAutoTip": "Processar imagens de cadernos comuns que ainda não possuem resultado de OCR","ocrModel": "Modelo de OCR",- "ocrModelTip": "Tiny e Small são integrados; a troca preserva os resultados existentes; repita o OCR pelo menu da imagem",+ "ocrModelTip": "Apenas Tiny está integrado; trocar de modelo preserva os resultados existentes; execute o OCR novamente pelo menu da imagem","ocrImportModels": "Importar modelos de OCR","ocrImportModelsTip": "Selecione arquivos ONNX compatíveis de detecção e reconhecimento PP-OCRv6 e seus arquivos inference.yml; os arquivos importados são sincronizados com o espaço de trabalho","ocrDetector": "Modelo de detecção",diff --git a/app/appearance/langs/ru.json b/app/appearance/langs/ru.jsonindex cdfe7390ec..50e86c639e 100644--- a/app/appearance/langs/ru.json+++ b/app/appearance/langs/ru.json@@ -41,7 +41,7 @@"ocrAuto": "Автоматический OCR","ocrAutoTip": "Обрабатывать изображения обычных блокнотов, для которых ещё нет результата OCR","ocrModel": "Модель OCR",- "ocrModelTip": "Tiny и Small встроены; смена сохраняет существующие результаты; повторите OCR из меню изображения",+ "ocrModelTip": "Встроена только модель Tiny; смена модели сохраняет результаты; повторный запуск OCR доступен в меню изображения","ocrImportModels": "Импорт моделей OCR","ocrImportModelsTip": "Выберите совместимые ONNX-файлы обнаружения и распознавания PP-OCRv6 и соответствующие inference.yml; импортированные файлы синхронизируются с рабочим пространством","ocrDetector": "Модель обнаружения",diff --git a/app/appearance/langs/sk.json b/app/appearance/langs/sk.jsonindex b4fd97cd3e..d8beb778ae 100644--- a/app/appearance/langs/sk.json+++ b/app/appearance/langs/sk.json@@ -41,7 +41,7 @@"ocrAuto": "Automatické OCR","ocrAutoTip": "Spracovať obrázky bežných zápisníkov, ktoré ešte nemajú výsledok OCR","ocrModel": "Model OCR",- "ocrModelTip": "Tiny a Small sú vstavané; zmena zachová existujúce výsledky; OCR zopakujte z ponuky obrázka",+ "ocrModelTip": "Zabudovaný je iba Tiny; zmena modelu zachová existujúce výsledky; OCR možno znova spustiť z ponuky obrázka","ocrImportModels": "Importovať modely OCR","ocrImportModelsTip": "Vyberte kompatibilné súbory ONNX detekcie a rozpoznávania PP-OCRv6 a ich súbory inference.yml; importované súbory sa synchronizujú s pracovným priestorom","ocrDetector": "Detekčný model",diff --git a/app/appearance/langs/sr.json b/app/appearance/langs/sr.jsonindex a34faf8e08..edb80836d1 100644--- a/app/appearance/langs/sr.json+++ b/app/appearance/langs/sr.json@@ -41,7 +41,7 @@"ocrAuto": "Аутоматски OCR","ocrAutoTip": "Обрађуј слике обичних бележница које још немају OCR резултат","ocrModel": "OCR модел",- "ocrModelTip": "Tiny и Small су уграђени; промена чува постојеће резултате; поновите OCR из менија слике",+ "ocrModelTip": "Уграђен је само Tiny; промена модела чува постојеће резултате; поново покрените OCR из менија слике","ocrImportModels": "Увези OCR моделе","ocrImportModelsTip": "Изаберите компатибилне PP-OCRv6 ONNX датотеке за детекцију и препознавање и њихове inference.yml датотеке; увезене датотеке се синхронизују са радним простором","ocrDetector": "Модел детекције",diff --git a/app/appearance/langs/th.json b/app/appearance/langs/th.jsonindex c31a4c622a..bf6e7128ea 100644--- a/app/appearance/langs/th.json+++ b/app/appearance/langs/th.json@@ -41,7 +41,7 @@"ocrAuto": "OCR อัตโนมัติ","ocrAutoTip": "ประมวลผลรูปภาพในสมุดบันทึกทั่วไปที่ยังไม่มีผล OCR","ocrModel": "โมเดล OCR",- "ocrModelTip": "มี Tiny และ Small ในตัว การสลับจะเก็บผลเดิมไว้ และสั่ง OCR ใหม่ได้จากเมนูรูปภาพ",+ "ocrModelTip": "มีเฉพาะ Tiny ในตัว การเปลี่ยนโมเดลจะเก็บผลลัพธ์เดิมไว้ สามารถเรียกใช้ OCR อีกครั้งจากเมนูรูปภาพ","ocrImportModels": "นำเข้าโมเดล OCR","ocrImportModelsTip": "เลือกไฟล์ ONNX สำหรับตรวจจับและรู้จำ PP-OCRv6 ที่เข้ากันได้ พร้อม inference.yml ของแต่ละโมเดล ไฟล์ที่นำเข้าจะซิงค์กับพื้นที่ทำงาน","ocrDetector": "โมเดลตรวจจับ",diff --git a/app/appearance/langs/tr.json b/app/appearance/langs/tr.jsonindex 54120f9830..9cb8c77010 100644--- a/app/appearance/langs/tr.json+++ b/app/appearance/langs/tr.json@@ -41,7 +41,7 @@"ocrAuto": "Otomatik OCR","ocrAutoTip": "Henüz OCR sonucu olmayan normal defter görüntülerini işle","ocrModel": "OCR modeli",- "ocrModelTip": "Tiny ve Small yerleşiktir; değiştirmek mevcut sonuçları korur; görüntü menüsünden OCR işlemini tekrarlayın",+ "ocrModelTip": "Yalnızca Tiny yerleşiktir; model değişikliği mevcut sonuçları korur; görsel menüsünden OCR işlemini yeniden çalıştırın","ocrImportModels": "OCR modellerini içe aktar","ocrImportModelsTip": "Uyumlu PP-OCRv6 algılama ve tanıma ONNX dosyalarını ve inference.yml dosyalarını seçin; içe aktarılan dosyalar çalışma alanıyla eşitlenir","ocrDetector": "Algılama modeli",diff --git a/app/appearance/langs/uk.json b/app/appearance/langs/uk.jsonindex d7bd67e091..86ba3d4b8d 100644--- a/app/appearance/langs/uk.json+++ b/app/appearance/langs/uk.json@@ -41,7 +41,7 @@"ocrAuto": "Автоматичний OCR","ocrAutoTip": "Обробляти зображення звичайних блокнотів, які ще не мають результату OCR","ocrModel": "Модель OCR",- "ocrModelTip": "Tiny і Small вбудовані; зміна зберігає наявні результати; повторіть OCR з меню зображення",+ "ocrModelTip": "Вбудовано лише модель Tiny; зміна моделі зберігає результати; повторний запуск OCR доступний у меню зображення","ocrImportModels": "Імпорт моделей OCR","ocrImportModelsTip": "Виберіть сумісні ONNX-файли виявлення та розпізнавання PP-OCRv6 і відповідні inference.yml; імпортовані файли синхронізуються з робочим простором","ocrDetector": "Модель виявлення",diff --git a/app/appearance/langs/zh-CN.json b/app/appearance/langs/zh-CN.jsonindex d9328ba96d..b6610adab8 100644--- a/app/appearance/langs/zh-CN.json+++ b/app/appearance/langs/zh-CN.json@@ -41,7 +41,7 @@"ocrAuto": "自动 OCR","ocrAutoTip": "仅处理尚无 OCR 结果的普通笔记本图片","ocrModel": "OCR 模型",- "ocrModelTip": "Tiny 和 Small 已内置;切换后保留现有结果,可在图片菜单中重新识别",+ "ocrModelTip": "仅内置 Tiny;切换后保留现有结果,可在图片菜单中重新识别","ocrImportModels": "导入 OCR 模型","ocrImportModelsTip": "选择配套的 PP-OCRv6 检测、识别 ONNX 文件及各自的 inference.yml;导入文件随工作空间同步","ocrDetector": "检测模型",diff --git a/app/appearance/langs/zh-TW.json b/app/appearance/langs/zh-TW.jsonindex 90bde73920..6e3d0cc225 100644--- a/app/appearance/langs/zh-TW.json+++ b/app/appearance/langs/zh-TW.json@@ -41,7 +41,7 @@"ocrAuto": "自動 OCR","ocrAutoTip": "僅處理尚無 OCR 結果的一般筆記本圖片","ocrModel": "OCR 模型",- "ocrModelTip": "已內建 Tiny 和 Small;切換後保留現有結果,可在圖片選單中重新辨識",+ "ocrModelTip": "僅內建 Tiny;切換後保留現有結果,可在圖片選單中重新辨識","ocrImportModels": "匯入 OCR 模型","ocrImportModelsTip": "選取配套的 PP-OCRv6 偵測、辨識 ONNX 檔案及各自的 inference.yml;匯入檔案隨工作空間同步","ocrDetector": "偵測模型",diff --git a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20200924100744-br924ar.sy b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20200924100744-br924ar.syindex f97ac0b293..52ca65baaa 100644--- a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20200924100744-br924ar.sy+++ b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20200924100744-br924ar.sy@@ -6,7 +6,7 @@"id": "20200924100744-br924ar","title": "Assets","type": "doc",- "updated": "20261003224949"+ "updated": "20261003234011"},"Children": [{@@ -967,7 +967,7 @@"HeadingLevel": 2,"Properties": {"id": "20230117003636-epvk98g",- "updated": "20261002231520"+ "updated": "20261003234011"},"Children": [{@@ -1022,12 +1022,12 @@"Type": "NodeParagraph","Properties": {"id": "20261001000112-e9wid3h",- "updated": "20261002231520"+ "updated": "20261003234011"},"Children": [{"Type": "NodeText",- "Data": "PaddleOCR includes PP-OCRv6 Tiny and Small models, available offline without downloading. Tiny uses fewer resources; Small offers higher accuracy. To import another compatible PP-OCRv6 model, select its detection and recognition ONNX files and the corresponding inference.yml files. Imported models sync with the workspace; the provider and selected model are saved per device. New users default to PaddleOCR with Small on desktop and Tiny on mobile; automatic OCR is disabled by default. Existing users retain their OCR configuration; upgrading from a version without OCR provider settings keeps Tesseract."+ "Data": "PaddleOCR bundles only PP-OCRv6 Tiny, available offline without downloading and selected by default on desktop and mobile. Other compatible PP-OCRv6 models, such as Small and Medium, can be imported by selecting their detection and recognition ONNX files and corresponding inference.yml files. Imported models sync with the workspace; the provider and selected model are saved per device. New users default to PaddleOCR with automatic OCR disabled. Existing provider, automatic OCR, and threshold settings are preserved. The former built-in Small selection migrates to Tiny; imported models are unaffected. Upgrading from a version without OCR provider settings keeps Tesseract."}]},diff --git a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20200915214115-42b8zma.sy b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20200915214115-42b8zma.syindex d6092cb5ed..594651c42d 100644--- a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20200915214115-42b8zma.sy+++ b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20200915214115-42b8zma.sy@@ -6,7 +6,7 @@"id": "20200915214115-42b8zma","title": "资源文件","type": "doc",- "updated": "20261003224949"+ "updated": "20261003234011"},"Children": [{@@ -979,7 +979,7 @@"HeadingLevel": 2,"Properties": {"id": "20230117002036-vmc0mx4",- "updated": "20261002231520"+ "updated": "20261003234011"},"Children": [{@@ -1034,12 +1034,12 @@"Type": "NodeParagraph","Properties": {"id": "20261001000112-4enj18s",- "updated": "20261002231520"+ "updated": "20261003234011"},"Children": [{"Type": "NodeText",- "Data": "PaddleOCR 内置 PP-OCRv6 Tiny 和 Small 模型,无需下载即可离线使用。Tiny 占用资源更少,Small 识别精度更高。导入其他兼容的 PP-OCRv6 模型时,分别选择检测、识别 ONNX 文件及对应的 inference.yml。导入模型随工作空间同步,提供商和当前模型的选择按设备保存。新用户默认使用 PaddleOCR,桌面端使用 Small,移动端使用 Tiny,自动 OCR 默认关闭。已有用户保留原 OCR 配置;从尚无 OCR 提供商设置的版本升级时,继续使用 Tesseract。"+ "Data": "PaddleOCR 仅内置 PP-OCRv6 Tiny 模型,无需下载即可离线使用,桌面端和移动端均默认选择 Tiny。Small、Medium 等其他兼容的 PP-OCRv6 模型可自行导入:分别选择检测、识别 ONNX 文件及对应的 inference.yml。导入模型随工作空间同步,提供商和当前模型的选择按设备保存。新用户默认使用 PaddleOCR,自动 OCR 默认关闭。已有用户保留原提供商、自动 OCR 和阈值配置;旧的内置 Small 选择迁移为 Tiny,自行导入的模型不受影响。从尚无 OCR 提供商设置的版本升级时,继续使用 Tesseract。"}]},diff --git a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226123038-4umgpxy.sy b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226123038-4umgpxy.syindex 20ddc5f0cb..1ffdd52d48 100644--- a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226123038-4umgpxy.sy+++ b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226123038-4umgpxy.sy@@ -6,7 +6,7 @@"id": "20211226123038-4umgpxy","title": "資料文件","type": "doc",- "updated": "20261003224949"+ "updated": "20261003234011"},"Children": [{@@ -965,7 +965,7 @@"HeadingLevel": 2,"Properties": {"id": "20230117003901-ze4mbzz",- "updated": "20261002231520"+ "updated": "20261003234011"},"Children": [{@@ -1020,12 +1020,12 @@"Type": "NodeParagraph","Properties": {"id": "20261001000112-w0zyvyj",- "updated": "20261002231520"+ "updated": "20261003234011"},"Children": [{"Type": "NodeText",- "Data": "PaddleOCR 內建 PP-OCRv6 Tiny 和 Small 模型,無需下載即可離線使用。Tiny 占用資源較少,Small 辨識精確度較高。匯入其他相容的 PP-OCRv6 模型時,分別選取偵測、辨識 ONNX 檔案及對應的 inference.yml。匯入模型隨工作空間同步,提供者和目前模型的選擇依裝置儲存。新使用者預設使用 PaddleOCR,桌面端使用 Small,行動端使用 Tiny,自動 OCR 預設關閉。既有使用者保留原 OCR 設定;從尚無 OCR 提供者設定的版本升級時,繼續使用 Tesseract。"+ "Data": "PaddleOCR 僅內建 PP-OCRv6 Tiny 模型,無需下載即可離線使用,桌面端和行動端均預設選擇 Tiny。Small、Medium 等其他相容的 PP-OCRv6 模型可自行匯入:分別選取偵測、辨識 ONNX 檔案及對應的 inference.yml。匯入模型隨工作空間同步,提供者和目前模型的選擇依裝置儲存。新使用者預設使用 PaddleOCR,自動 OCR 預設關閉。既有使用者保留原提供者、自動 OCR 和閾值設定;舊的內建 Small 選擇移轉為 Tiny,自行匯入的模型不受影響。從尚無 OCR 提供者設定的版本升級時,繼續使用 Tesseract。"}]},diff --git a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-1m5un7l.sy b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-1m5un7l.syindex 07831c7a0a..81ef0aacaf 100644--- a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-1m5un7l.sy+++ b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-1m5un7l.sy@@ -7,7 +7,7 @@"id": "20240530101000-1m5un7l","title": "アセット","type": "doc",- "updated": "20261003224949"+ "updated": "20261003234011"},"Children": [{@@ -1005,7 +1005,7 @@"Properties": {"ID": "20240530101000-5bix8t1","id": "20240530101000-9evyuhr",- "updated": "20261002231520"+ "updated": "20261003234011"},"Children": [{@@ -1057,12 +1057,12 @@"Type": "NodeParagraph","Properties": {"id": "20261001000112-ooz689o",- "updated": "20261002231520"+ "updated": "20261003234011"},"Children": [{"Type": "NodeText",- "Data": "PaddleOCR には PP-OCRv6 Tiny と Small が内蔵され、ダウンロードせずにオフラインで使用できます。Tiny はリソース消費が少なく、Small は認識精度が高いモデルです。ほかの互換 PP-OCRv6 モデルをインポートする場合は、検出と認識の ONNX ファイルと各 inference.yml を選択します。インポートしたモデルはワークスペースと同期され、プロバイダーと使用モデルの選択は端末ごとに保存されます。新規ユーザーはデフォルトで PaddleOCR を使用し、デスクトップでは Small、モバイルでは Tiny が選択されます。自動 OCR はデフォルトで無効です。既存ユーザーの OCR 設定は保持され、OCR プロバイダー設定のないバージョンからの更新では Tesseract を引き続き使用します。"+ "Data": "PaddleOCR には PP-OCRv6 Tiny のみが内蔵され、ダウンロードせずにオフラインで使用できます。デスクトップとモバイルの両方で Tiny がデフォルトです。Small、Medium などの互換 PP-OCRv6 モデルは、検出と認識の ONNX ファイルと各 inference.yml を選択してインポートできます。インポートしたモデルはワークスペースと同期され、プロバイダーと使用モデルの選択は端末ごとに保存されます。新規ユーザーはデフォルトで PaddleOCR を使用し、自動 OCR は無効です。既存のプロバイダー、自動 OCR、しきい値の設定は保持されます。旧内蔵モデル Small の選択は Tiny に移行し、インポートしたモデルには影響しません。OCR プロバイダー設定のないバージョンからの更新では Tesseract を引き続き使用します。"}]},diff --git a/app/src/config/ocr.test.ts b/app/src/config/ocr.test.tsindex 56ccbbe877..809f4e6e4c 100644--- a/app/src/config/ocr.test.ts+++ b/app/src/config/ocr.test.ts@@ -9,9 +9,9 @@ const createOCRPanel = async () => {const compiled = transpileModule(readFileSync("src/config/ocr.ts", "utf8"), {compilerOptions: {module: ModuleKind.CommonJS, target: ScriptTarget.ES2021},}).outputText;- const config: {ocr: SettingOCR} = {ocr: {provider: "paddleocr", model: "small", auto: false}};+ const config: {ocr: SettingOCR} = {ocr: {provider: "paddleocr", model: "tiny", auto: false}};let serverConfig = {...config.ocr};- let models = [{id: "small", name: "Small", builtIn: true}];+ let models = [{id: "tiny", name: "Tiny", builtIn: true}];let reads = 0;let deferredRead = false;const readRequests: Array<(response: unknown) => void> = [];@@ -22,7 +22,7 @@ const createOCRPanel = async () => {"detector", "detectorConfig", "recognizer", "recognizerConfig","ocrAdvanced",].map(id => [id, {- id, value: id === "ocrProvider" ? "paddleocr" : "small", checked: false, disabled: false, innerHTML: "",+ id, value: id === "ocrProvider" ? "paddleocr" : "tiny", checked: false, disabled: false, innerHTML: "",files: [{name: `${id}.onnx`}],tagName: id === "ocrImport" || id === "ocrAdvanced" ? "BUTTON" : "INPUT",closest: () => ({classList: {toggle() {}}}),@@ -140,7 +140,7 @@ for (const networkFailure of [false, true]) {test("advanced OCR settings receive the latest thresholds and use the panel save queue", async () => {const panel = await createOCRPanel();- panel.updateServer({provider: "paddleocr", model: "small", auto: false,+ panel.updateServer({provider: "paddleocr", model: "tiny", auto: false,thresholds: {detection: 0.4, box: 0.7, recognition: 0.8}});panel.notify();await new Promise(setImmediate);@@ -206,7 +206,7 @@ test("a notification read received during a save cannot overwrite the pending swpanel.readRequests[0](stale);await new Promise(setImmediate);assert.equal(panel.controls.ocrAuto.checked, true);- panel.updateServer({provider: "paddleocr", model: "small", auto: true});+ panel.updateServer({provider: "paddleocr", model: "tiny", auto: true});panel.requests[0].resolve({code: 0, data: panel.requests[0].config});await pending;await new Promise(setImmediate);@@ -222,7 +222,7 @@ test("OCR notifications coalesce and discard a superseded response", async () =>panel.deferRead();panel.notify();await new Promise(setImmediate);- panel.updateServer({provider: "paddleocr", model: "small", auto: true});+ panel.updateServer({provider: "paddleocr", model: "tiny", auto: true});panel.notify();panel.notify();panel.readRequests[0](stale);@@ -240,7 +240,7 @@ test("a read started before a save cannot overwrite the completed save", async (await new Promise(setImmediate);const pending = panel.changeAuto(true);await new Promise(setImmediate);- panel.updateServer({provider: "paddleocr", model: "small", auto: true});+ panel.updateServer({provider: "paddleocr", model: "tiny", auto: true});panel.requests[0].resolve({code: 0, data: panel.requests[0].config});await pending;panel.readRequests[0](stale);@@ -257,7 +257,7 @@ test("closing the panel ignores a late notification response", async () => {panel.deferRead();panel.notify();await new Promise(setImmediate);- panel.updateServer({provider: "paddleocr", model: "small", auto: true});+ panel.updateServer({provider: "paddleocr", model: "tiny", auto: true});panel.close();panel.readRequests[0](panel.snapshot());await new Promise(setImmediate);diff --git a/app/src/config/ocr.ts b/app/src/config/ocr.tsindex c7c6b9ca84..e127d96455 100644--- a/app/src/config/ocr.ts+++ b/app/src/config/ocr.ts@@ -10,7 +10,7 @@ import {objEquals} from "../util/functions";import {openOCRThresholds} from "./ocrThresholds";export const ocrSearchStrings = (): string[] => [- "OCR", "Tesseract", "PaddleOCR", "Tiny", "Small",+ "OCR", "Tesseract", "PaddleOCR", "Tiny",window.siyuan.languages.ocrProvider,window.siyuan.languages.ocrModel,window.siyuan.languages.ocrAuto,diff --git a/app/src/config/setting/sync.test.ts b/app/src/config/setting/sync.test.tsindex 8b174ec2ee..a8c17383f9 100644--- a/app/src/config/setting/sync.test.ts+++ b/app/src/config/setting/sync.test.ts@@ -146,7 +146,7 @@ for (const mobile of [false, true]) {}).outputText;const editor = {fontSize: 16};const appearance = {theme: "dark"};- const config = {ocr: {provider: "paddleocr", model: "small", auto: false}, editor, appearance, keymap: {}};+ const config = {ocr: {provider: "paddleocr", model: "tiny", auto: false}, editor, appearance, keymap: {}};let next = {...config.ocr, auto: true};let notifications = 0;const remounted: string[] = [];diff --git a/kernel/api/contract_ocr_test.go b/kernel/api/contract_ocr_test.goindex d9317fd7f9..aa8bd33b2d 100644--- a/kernel/api/contract_ocr_test.go+++ b/kernel/api/contract_ocr_test.go@@ -284,7 +284,7 @@ func TestAPIContractOCRSettings(t *testing.T) {if err := json.Unmarshal(get.Body.Bytes(), &result); err != nil {t.Fatal(err)}- if result.Data.Config.Provider != "paddleocr" || result.Data.Config.Auto || len(result.Data.Models) != 2 || len(result.Data.Providers) != 2 {+ if result.Data.Config.Provider != "paddleocr" || result.Data.Config.Model != "tiny" || result.Data.Config.Auto || len(result.Data.Models) != 1 || result.Data.Models[0].ID != "tiny" || !result.Data.Models[0].BuiltIn || len(result.Data.Providers) != 2 {t.Fatalf("unexpected defaults: %+v", result.Data)}path := "assets/preserved.png"@@ -295,6 +295,7 @@ func TestAPIContractOCRSettings(t *testing.T) {success bool}{{`{"provider":"tesseract","model":"tiny","auto":false}`, true},+ {`{"provider":"tesseract","model":"small","auto":false}`, true},{`{"provider":"unknown","model":"tiny","auto":true}`, false},{`{"provider":"paddleocr","model":"../../outside","auto":true}`, false},{`{"provider":"tesseract","model":"tiny","auto":"false"}`, false},@@ -304,13 +305,19 @@ func TestAPIContractOCRSettings(t *testing.T) {recorder := httptest.NewRecorder()engine.ServeHTTP(recorder, httptest.NewRequest("POST", "/api/asset/setOCRConfig", strings.NewReader(test.body)))requireAPIContract(t, "POST", "/api/asset/setOCRConfig", recorder)- var response struct{ Code int }+ var response struct {+ Code int+ Data *apicontract.SettingOCR+ }if err := json.Unmarshal(recorder.Body.Bytes(), &response); err != nil {t.Fatal(err)}if (response.Code == 0) != test.success {t.Fatalf("body=%s response=%s", test.body, recorder.Body.String())}+ if test.success && (response.Data == nil || response.Data.Model != "tiny" || model.Conf.GetOCR().Model != "tiny") {+ t.Fatalf("legacy model was not normalized in response and configuration: %s", recorder.Body.String())+ }expectedRevision := previousRevisionif test.success {expectedRevision++@@ -473,7 +480,7 @@ func TestAPIContractOCRFailurePreservesText(t *testing.T) {if err := os.WriteFile(filepath.Join(assets, "failure.png"), []byte("invalid image"), 0644); err != nil {t.Fatal(err)}- model.Conf.OCR = &conf.OCR{Provider: "paddleocr", Model: "small"}+ model.Conf.OCR = &conf.OCR{Provider: "paddleocr", Model: "tiny"}util.SetAssetText(path, "previous result")t.Cleanup(func() { util.RemoveAssetText(path) })engine := gin.New()diff --git a/kernel/api/ocr.go b/kernel/api/ocr.goindex 8fdf7cc06f..11c2b43888 100644--- a/kernel/api/ocr.go+++ b/kernel/api/ocr.go@@ -44,12 +44,10 @@ func ocrModelPayload(id string) apicontract.OCRModel {name := idif id == "tiny" {name = "PP-OCRv6 Tiny"- } else if id == "small" {- name = "PP-OCRv6 Small"} else {name = "PP-OCRv6 " + strings.ToUpper(id[:8])}- return apicontract.OCRModel{ID: id, Name: name, BuiltIn: id == "tiny" || id == "small"}+ return apicontract.OCRModel{ID: id, Name: name, BuiltIn: id == "tiny"}}var setOCRConfig = contractHandler(apicontract.SetOCRConfig, serializeSetting("ocr", func(c *gin.Context, request apicontract.SettingOCR) apicontract.Response[apicontract.SettingOCR] {@@ -61,7 +59,7 @@ var setOCRConfig = contractHandler(apicontract.SetOCRConfig, serializeSetting("oif err := model.Conf.SetOCR(value); err != nil {return apicontract.Failure[apicontract.SettingOCR](-1, err.Error())}- return apicontract.Success(ocrConfigPayload(value))+ return apicontract.Success(ocrConfigPayload(model.Conf.GetOCR()))}))var importOCRModels = contractHandler(apicontract.ImportOCRModels, func(c *gin.Context, request apicontract.ImportOCRModelsRequest) apicontract.Response[apicontract.OCRModel] {diff --git a/kernel/apicontract/ocr.go b/kernel/apicontract/ocr.goindex 3149fd5449..2c8a858722 100644--- a/kernel/apicontract/ocr.go+++ b/kernel/apicontract/ocr.go@@ -6,6 +6,7 @@ import "mime/multipart"// auto 仅控制内核后台识别,手动识别继续使用 /api/asset/ocr 的既有输入和输出。// thresholds 省略或为 null 时保留设备已保存的阈值;传入对象时整体替换。// 修改阈值只影响后续识别,不修改模型文件或已有结果,Tesseract 不使用这些参数。+// 仅内置 tiny;旧内置模型标识 small 会归一化为 tiny,自行导入的模型仍使用内容摘要标识。type SettingOCR struct {Provider string `json:"provider"`Model string `json:"model"`@@ -40,7 +41,7 @@ type OCRConfigData struct {// ImportOCRModelsRequest 导入配套的 PP-OCRv6 ONNX 模型和 YAML 配置。// 两个模型各不超过 256 MiB,两个配置各不超过 1 MiB;成功后文件存放于 data/ocr/models/<内容摘要>/。-// 导入不自动切换当前模型,失败不覆盖已有模型。内置 Tiny、Small 不写入工作空间。+// 导入不自动切换当前模型,失败不覆盖已有模型。内置 Tiny 不写入工作空间。type ImportOCRModelsRequest struct {Detector *multipart.FileHeader `json:"detector"`DetectorConfig *multipart.FileHeader `json:"detectorConfig"`diff --git a/kernel/conf/ocr.go b/kernel/conf/ocr.goindex fd834fa366..e00034d971 100644--- a/kernel/conf/ocr.go+++ b/kernel/conf/ocr.go@@ -15,10 +15,6 @@ type OCRThresholds struct {Recognition *float64 `json:"recognition"`}-func NewOCR(mobile bool) *OCR {- model := "small"- if mobile {- model = "tiny"- }- return &OCR{Provider: "paddleocr", Model: model, Auto: false}+func NewOCR() *OCR {+ return &OCR{Provider: "paddleocr", Model: "tiny", Auto: false}}diff --git a/kernel/conf/ocr_test.go b/kernel/conf/ocr_test.goindex 4e47a5a8ac..4960ab4ba1 100644--- a/kernel/conf/ocr_test.go+++ b/kernel/conf/ocr_test.go@@ -3,10 +3,7 @@ package confimport "testing"func TestOCRDeviceDefaults(t *testing.T) {- if desktop := NewOCR(false); desktop.Provider != "paddleocr" || desktop.Model != "small" || desktop.Auto {- t.Fatalf("desktop defaults: %+v", desktop)- }- if mobile := NewOCR(true); mobile.Provider != "paddleocr" || mobile.Model != "tiny" || mobile.Auto {- t.Fatalf("mobile defaults: %+v", mobile)+ if config := NewOCR(); config.Provider != "paddleocr" || config.Model != "tiny" || config.Auto {+ t.Fatalf("device defaults: %+v", config)}}diff --git a/kernel/model/conf.go b/kernel/model/conf.goindex 1e56700d84..aae34eacbe 100644--- a/kernel/model/conf.go+++ b/kernel/model/conf.go@@ -786,7 +786,7 @@ func InitConf() {}()}- Conf.OCR = normalizeOCRConfig(Conf.OCR, confFileExists, util.IsMobileContainer())+ Conf.OCR = normalizeOCRConfig(Conf.OCR, confFileExists)if nil == Conf.AI {Conf.AI = conf.NewAI()} else {diff --git a/kernel/model/ocr.go b/kernel/model/ocr.goindex fca53c0ac6..fe37ad40bc 100644--- a/kernel/model/ocr.go+++ b/kernel/model/ocr.go@@ -44,11 +44,15 @@ func ocrModelFilesChanged(changes ...[]string) bool {}// 新设备使用内置 PaddleOCR 并关闭自动识别,已有设备缺少 OCR 配置时保留 Tesseract 自动识别。-func normalizeOCRConfig(value *conf.OCR, confFileExists, mobile bool) *conf.OCR {+func normalizeOCRConfig(value *conf.OCR, confFileExists bool) *conf.OCR {if value != nil {+ // 内置模型统一为 Tiny,自行导入的模型仍保留内容摘要标识。+ if value.Model == "small" {+ value.Model = "tiny"+ }return value}- value = conf.NewOCR(mobile)+ value = conf.NewOCR()if confFileExists {value.Provider = string(ocr.Tesseract)value.Auto = true@@ -71,19 +75,23 @@ func (config *AppConf) GetOCR() conf.OCR {config.m.RLock()defer config.m.RUnlock()if config.OCR == nil {- return *conf.NewOCR(util.IsMobileContainer())+ return *conf.NewOCR()}return *config.OCR}func (config *AppConf) SetOCR(value conf.OCR) error {+ // 兼容旧客户端提交的内置 Small 标识,响应和持久化配置均使用 Tiny。+ if value.Model == "small" {+ value.Model = "tiny"+ }if err := (ocr.Thresholds(value.Thresholds)).Validate(); err != nil {return err}if value.Provider != string(ocr.Tesseract) && value.Provider != string(ocr.PaddleOCR) {return errors.New("unknown OCR provider")}- if value.Model != "tiny" && value.Model != "small" {+ if value.Model != "tiny" {if len(value.Model) != 64 || strings.Trim(value.Model, "0123456789abcdef") != "" {return errors.New("invalid OCR model ID")}@@ -105,7 +113,7 @@ func (config *AppConf) SetOCR(value conf.OCR) error {}func ocrModelDirectory(id string) string {- if id == "tiny" || id == "small" {+ if id == "tiny" {return filepath.Join(util.WorkingDir, "stage", "ocr", "models", id)}return filepath.Join(util.DataDir, "ocr", "models", id)@@ -285,7 +293,7 @@ func autoOCRAssets() {}func OCRModels() []string {- result := []string{"tiny", "small"}+ result := []string{"tiny"}entries, _ := os.ReadDir(filepath.Join(util.DataDir, "ocr", "models"))for _, entry := range entries {id := entry.Name()diff --git a/kernel/model/ocr_conf_test.go b/kernel/model/ocr_conf_test.goindex 8665991c70..77d12aeba0 100644--- a/kernel/model/ocr_conf_test.go+++ b/kernel/model/ocr_conf_test.go@@ -1,28 +1,48 @@package modelimport (+ "encoding/json""testing""github.com/siyuan-note/siyuan/kernel/conf")+func TestOCRSmallMigrationPreservesPreferences(t *testing.T) {+ for _, provider := range []string{"paddleocr", "tesseract"} {+ for _, model := range []string{"small", "tiny", "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"} {+ var value conf.OCR+ if err := json.Unmarshal([]byte(`{"provider":"`+provider+`","model":"`+model+`","auto":true,"thresholds":{"detection":0.4,"box":0.7,"recognition":0.8}}`), &value); err != nil {+ t.Fatal(err)+ }+ original := value+ if original.Model == "small" {+ original.Model = "tiny"+ }+ got := normalizeOCRConfig(&value, true)+ if *got != original {+ t.Fatalf("migration changed preferences: %+v", got)+ }+ if again := normalizeOCRConfig(got, true); *again != original {+ t.Fatal("migration is not idempotent")+ }+ }+ }+}+func TestNormalizeOCRConfig(t *testing.T) {for _, test := range []struct {name stringvalue *conf.OCRconfFileExists bool- mobile boolwant conf.OCR}{- {name: "new desktop", want: conf.OCR{Provider: "paddleocr", Model: "small", Auto: false}},- {name: "new mobile", mobile: true, want: conf.OCR{Provider: "paddleocr", Model: "tiny", Auto: false}},- {name: "legacy desktop", confFileExists: true, want: conf.OCR{Provider: "tesseract", Model: "small", Auto: true}},- {name: "legacy mobile", confFileExists: true, mobile: true, want: conf.OCR{Provider: "tesseract", Model: "tiny", Auto: true}},+ {name: "new device", want: conf.OCR{Provider: "paddleocr", Model: "tiny", Auto: false}},+ {name: "legacy device", confFileExists: true, want: conf.OCR{Provider: "tesseract", Model: "tiny", Auto: true}},{name: "saved PaddleOCR with auto enabled",value: &conf.OCR{Provider: "paddleocr", Model: "small", Auto: true},confFileExists: true,- want: conf.OCR{Provider: "paddleocr", Model: "small", Auto: true},+ want: conf.OCR{Provider: "paddleocr", Model: "tiny", Auto: true},},{name: "saved Tesseract with auto disabled",@@ -34,12 +54,11 @@ func TestNormalizeOCRConfig(t *testing.T) {name: "saved PaddleOCR with imported model",value: &conf.OCR{Provider: "paddleocr", Model: "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef", Auto: false},confFileExists: true,- mobile: true,want: conf.OCR{Provider: "paddleocr", Model: "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef", Auto: false},},} {t.Run(test.name, func(t *testing.T) {- got := normalizeOCRConfig(test.value, test.confFileExists, test.mobile)+ got := normalizeOCRConfig(test.value, test.confFileExists)if *got != test.want {t.Fatalf("OCR config: got %+v, want %+v", *got, test.want)}diff --git a/kernel/model/settings_reset.go b/kernel/model/settings_reset.goindex eaf5ed188f..9c3bf6dbac 100644--- a/kernel/model/settings_reset.go+++ b/kernel/model/settings_reset.go@@ -41,7 +41,7 @@ func defaultWorkspaceSettings(current *AppConf) *AppConf {next.Search = conf.NewSearch()next.Graph = conf.NewGraph()next.Flashcard = conf.NewFlashcard()- next.OCR = conf.NewOCR(util.IsMobileContainer())+ next.OCR = conf.NewOCR()next.Appearance = conf.NewAppearance()next.Appearance.Lang = current.Langif current.Appearance != nil {diff --git a/kernel/ocr/paddle_test.go b/kernel/ocr/paddle_test.goindex 58ddf48f84..dadd2900cc 100644--- a/kernel/ocr/paddle_test.go+++ b/kernel/ocr/paddle_test.go@@ -71,7 +71,7 @@ func TestNativePaddleOCR(t *testing.T) {}expected = "SiYuan OCR 123"}- for _, size := range []string{"tiny", "small"} {+ for _, size := range []string{"tiny"} {t.Run(size, func(t *testing.T) {config := PaddleConfig{Library: library, Directory: filepath.Join(assets, size)}provider := &PaddleProvider{Config: func() PaddleConfig { return config }}diff --git a/scripts/generate-third-party-notices.py b/scripts/generate-third-party-notices.pyindex 99d7f66157..692f86fc95 100644--- a/scripts/generate-third-party-notices.py+++ b/scripts/generate-third-party-notices.py@@ -57,7 +57,7 @@ BUNDLED_COMPONENTS = ["Windows OCR runtime directories include unmodified app-local CRT DLLs, MICROSOFT-VC-RUNTIME-NOTICE.txt, and vc-runtime-files.json with the exact file digests",),(- "PaddleOCR PP-OCRv6 Tiny and Small ONNX models",+ "PaddleOCR PP-OCRv6 Tiny ONNX models","Pinned revisions in scripts/ocr-assets.json","Apache-2.0","https://huggingface.co/collections/PaddlePaddle/pp-ocrv6",diff --git a/scripts/ocr-assets.json b/scripts/ocr-assets.jsonindex d3ef134099..f41da518f1 100644--- a/scripts/ocr-assets.json+++ b/scripts/ocr-assets.json@@ -23,30 +23,6 @@"url": "https://huggingface.co/PaddlePaddle/PP-OCRv6_tiny_rec_onnx/resolve/2612ab37152ae0a677521bae4e1e3d4fb4cf7c30/inference.yml","sha256": "66170210bad538e83fff3c4a3867e547d6bf20b50d64b20347c4b913f3034ea1","size": 55571- },- {- "path": "small/det/inference.onnx",- "url": "https://huggingface.co/PaddlePaddle/PP-OCRv6_small_det_onnx/resolve/28fe5895c24fd108c19eb3e8479f4ab385fbfc62/inference.onnx",- "sha256": "d73e0058b7a8086bbd57f3d10b8bcd4ff95363f67e06e2762b5e814fe9c9410e",- "size": 9880512- },- {- "path": "small/det/inference.yml",- "url": "https://huggingface.co/PaddlePaddle/PP-OCRv6_small_det_onnx/resolve/28fe5895c24fd108c19eb3e8479f4ab385fbfc62/inference.yml",- "sha256": "193f435274bf9f0b5f71a929bbfbcf148282df7e633b34e7c373e8f44741b516",- "size": 885- },- {- "path": "small/rec/inference.onnx",- "url": "https://huggingface.co/PaddlePaddle/PP-OCRv6_small_rec_onnx/resolve/b8f84f0b80c529de40b4fbb3544b84fa7233a513/inference.onnx",- "sha256": "5435fd747c9e0efe15a96d0b378d5bd157e9492ed8fd80edf08f30d02fa24634",- "size": 21159378- },- {- "path": "small/rec/inference.yml",- "url": "https://huggingface.co/PaddlePaddle/PP-OCRv6_small_rec_onnx/resolve/b8f84f0b80c529de40b4fbb3544b84fa7233a513/inference.yml",- "sha256": "ab078671bb49f06228eadccd34f1bb501e157f7a047095ffb943ba81512c77d1",- "size": 150579}],"runtime": {diff --git a/scripts/prepare-ocr.py b/scripts/prepare-ocr.pyindex e92f0e6640..9dcf2787b7 100644--- a/scripts/prepare-ocr.py+++ b/scripts/prepare-ocr.py@@ -297,6 +297,17 @@ def prepare_runtime(target, build_worker, prerequisites=None):subprocess.run(["go", "build", "-trimpath", "-ldflags=-s -w", "-o", str(directory / "siyuan-ocr"), "./ocr/cmd/ocr-worker"], cwd=ROOT / "kernel", env=prerequisites, check=True)+def remove_obsolete_models():+ # 清理构建目录中已取消内置的模型,避免增量打包继续携带 Small。+ models = STAGE / "models"+ obsolete = models / "small"+ if not obsolete.exists() and not obsolete.is_symlink():+ return+ if models.resolve().parent != STAGE.resolve() or obsolete.is_symlink() or obsolete.resolve().parent != models.resolve():+ raise ValueError("Obsolete OCR model directory escapes the packaging directory")+ shutil.rmtree(obsolete)++def main():parser = argparse.ArgumentParser(description=__doc__)parser.add_argument("--runtime", choices=["none", *MANIFEST.get("runtime", {})], default="none")@@ -313,6 +324,7 @@ def main():futures = [pool.submit(download, entry, STAGE / "models" / entry["path"]) for entry in MANIFEST["models"]]for future in futures:future.result()+ remove_obsolete_models()if args.runtime != "none":prepare_runtime(args.runtime, args.build_worker, prerequisites)print(f"OCR resources ready: {args.runtime}")diff --git a/scripts/test_prepare_ocr.py b/scripts/test_prepare_ocr.pyindex 332f783b83..38b0b60e78 100644--- a/scripts/test_prepare_ocr.py+++ b/scripts/test_prepare_ocr.py@@ -68,6 +68,45 @@ class ResourceTests(unittest.TestCase):def entry(self, file):return {"url": file.as_uri(), "sha256": hashlib.sha256(file.read_bytes()).hexdigest(), "size": file.stat().st_size}+ def test_preparation_keeps_only_tiny_bundled_and_removes_stale_small(self):+ stage = self.root / "stage"+ obsolete = stage / "models/small/det/inference.onnx"+ obsolete.parent.mkdir(parents=True)+ obsolete.write_bytes(b"old bundled model")+ runtime = stage / "runtime/library"+ runtime.parent.mkdir()+ runtime.write_bytes(b"runtime")+ downloaded = []++ def download(entry, destination):+ downloaded.append(entry["path"])+ destination.parent.mkdir(parents=True, exist_ok=True)+ destination.write_bytes(b"tiny model")++ with patch.object(prepare, "STAGE", stage), patch.object(prepare, "download", side_effect=download), \+ patch.object(sys, "argv", ["prepare-ocr.py"]):+ prepare.main()+ self.assertEqual(set(downloaded), {"tiny/det/inference.onnx", "tiny/det/inference.yml",+ "tiny/rec/inference.onnx", "tiny/rec/inference.yml"})+ self.assertEqual({path.name for path in (stage / "models").iterdir()}, {"tiny"})+ self.assertEqual(runtime.read_bytes(), b"runtime")++ def test_obsolete_model_cleanup_rejects_paths_outside_stage(self):+ stage = self.root / "stage"+ obsolete = stage / "models/small"+ obsolete.mkdir(parents=True)+ outside = self.root / "outside"+ outside.mkdir()+ original_resolve = Path.resolve+ def resolve(path, *args, **kwargs):+ return outside if path == obsolete else original_resolve(path, *args, **kwargs)+ with patch.object(prepare, "STAGE", stage), patch.object(Path, "resolve", resolve), \+ patch.object(prepare.shutil, "rmtree") as remove:+ with self.assertRaisesRegex(ValueError, "escapes"):+ prepare.remove_obsolete_models()+ remove.assert_not_called()+ self.assertTrue(outside.exists())+def test_checksum_failure_preserves_previous_resource(self):source = self.root / "source"source.write_bytes(b"invalid replacement")