Posts

Showing posts with the label python

python with CUDA/GPU support on Windows

Image
  Setting up Windows for Python CUDA/GPU support step by step.

Flask: Drag & Drop + Click & Select example | single page app

Image
Flask: Drag & Drop + Click & Select | example single page app I needed to create a simple web page that takes the MS Excel file as input, reads it, and shows the result.

OCR pdf file in python on the fly

With   PyMuPDF and tesserocr you can OCR image pdf easily

Visualize Tesseract Box File

 Simply python (only PIL) tesseract box file visualisation.

python: log crash (exception) to file

If you create app for windows you know that user do now like console running on background. But if your app crash you have problem: you d no see error message. Solution is to log it to file.   Here is snippet how to implement it: import os import getpass import logging # log exception to file => for frozen app logging.basicConfig( format="%(asctime)s %(levelname)-8s %(message)s", datefmt="%Y-%m-%d %H:%M:%S", filename=os.path.basename(sys.argv[0]) + ".log", ) if hasattr(sys, "frozen"): sys.excepthook = exception_hook def exception_hook(exc_type, exc_value, exc_traceback): """Hook for standard exception hook.""" logging.error("Uncaught exception", exc_info=(exc_type, exc_value, exc_traceback)) logging.info("User: {}, file: '{}'".format(getpass.getuser())) def main():     # log information about user who run app logging.getLogger()....

pdf to image/multipage (in python)

Many people love pdf format as such files are readable on all common devices and it provide stable representation of document. But somehow also scanner started to support it but with one feature: they just encapsulate images to it without OCRing it, so such pdf are not reachable.