Giter VIP home page Giter VIP logo

Comments (3)

Balearica avatar Balearica commented on May 25, 2024

Was this a one-time thing that was resolved once you deleted/refreshed the cache data, or can it be replicated? If it can be replicated, please provide a reproducible example.

from tesseract.js.

laurent22 avatar laurent22 commented on May 25, 2024

I couldn't find where it stores the cache and setting langPath didn't seem to have any effect. Where can I find the cache data? For now I have disabled the cache but if I enable it again I think it will happen again, and then I can share these cached files so that the bug can be replicated

from tesseract.js.

Balearica avatar Balearica commented on May 25, 2024

Files are cached at ${cachePath}/${lang}.traineddata, where cachePath is determined by the cachePath argument (. by default). For the browser version of Tesseract.js the file is cached in IndexDB, and for the Node.js version of Tesseract.js the file is cached on the local file system.

For example, the following snippet will download eng.traineddata from IndexDB on browser. It must be run from the devtools console on a website that has previously saved eng.traineddata to the cache.

(async () => {
        // Open a connection to the database
        const openRequest = indexedDB.open('keyval-store');
        
        const db = await new Promise((resolve, reject) => {
            openRequest.onerror = () => reject(openRequest.error);
            openRequest.onsuccess = () => resolve(openRequest.result);
        });
        
        // Start a transaction and get the object store
        const transaction = db.transaction(['keyval'], 'readonly');
        const store = transaction.objectStore('keyval');
        
        // Use the key to get the file as a Blob
        const getRequest = store.get('./eng.traineddata');
        
        const data = await new Promise((resolve, reject) => {
            getRequest.onerror = () => reject(getRequest.error);
            getRequest.onsuccess = () => resolve(getRequest.result);
        });
        
        const blob = new Blob([data], {type: 'application/octet-stream'});
        
        // Create a URL for the blob
        const url = URL.createObjectURL(blob);
        
        // Create a temporary anchor element to trigger download
        const a = document.createElement('a');
        a.href = url;
        a.download = 'eng.traineddata'; 
        document.body.appendChild(a);
        a.click();
        document.body.removeChild(a);
        
        // Revoke the blob URL after download
        URL.revokeObjectURL(url);
        
})();

from tesseract.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.