반응형
반응형

pip install pytesseract

 

한글팩 : https://github.com/tesseract-ocr/tessdata/

 
다운 받아야하는 학습된 한글 데이터 파일명: kor.traineddata
파일 위치: tesseract가 설치된 경로 C:\Program Files\Tesseract-OCR\tessdata
 

*** 설치 할때 언어팩 선택 

 

pytesseract 0.3.10

 

Python-tesseract is an optical character recognition (OCR) tool for python. That is, it will recognize and “read” the text embedded in images.

Python-tesseract is a wrapper for Google’s Tesseract-OCR Engine. It is also useful as a stand-alone invocation script to tesseract, as it can read all image types supported by the Pillow and Leptonica imaging libraries, including jpeg, png, gif, bmp, tiff, and others. Additionally, if used as a script, Python-tesseract will print the recognized text instead of writing it to a file.

USAGE

Quickstart

Note: Test images are located in the tests/data folder of the Git repo.

Library usage:

from PIL import Image

import pytesseract

# If you don't have tesseract executable in your PATH, include the following:
pytesseract.pytesseract.tesseract_cmd = r'<full_path_to_your_tesseract_executable>'
# Example tesseract_cmd = r'C:\Program Files (x86)\Tesseract-OCR\tesseract'

# Simple image to string
print(pytesseract.image_to_string(Image.open('test.png')))

# In order to bypass the image conversions of pytesseract, just use relative or absolute image path
# NOTE: In this case you should provide tesseract supported images or tesseract will return error
print(pytesseract.image_to_string('test.png'))

# List of available languages
print(pytesseract.get_languages(config=''))

# French text image to string
print(pytesseract.image_to_string(Image.open('test-european.jpg'), lang='fra'))

# Batch processing with a single file containing the list of multiple image file paths
print(pytesseract.image_to_string('images.txt'))

# Timeout/terminate the tesseract job after a period of time
try:
    print(pytesseract.image_to_string('test.jpg', timeout=2)) # Timeout after 2 seconds
    print(pytesseract.image_to_string('test.jpg', timeout=0.5)) # Timeout after half a second
except RuntimeError as timeout_error:
    # Tesseract processing is terminated
    pass

# Get bounding box estimates
print(pytesseract.image_to_boxes(Image.open('test.png')))

# Get verbose data including boxes, confidences, line and page numbers
print(pytesseract.image_to_data(Image.open('test.png')))

# Get information about orientation and script detection
print(pytesseract.image_to_osd(Image.open('test.png')))

# Get a searchable PDF
pdf = pytesseract.image_to_pdf_or_hocr('test.png', extension='pdf')
with open('test.pdf', 'w+b') as f:
    f.write(pdf) # pdf type is bytes by default

# Get HOCR output
hocr = pytesseract.image_to_pdf_or_hocr('test.png', extension='hocr')

# Get ALTO XML output
xml = pytesseract.image_to_alto_xml('test.png')

Support for OpenCV image/NumPy array objects

import cv2

img_cv = cv2.imread(r'/<path_to_image>/digits.png')

# By default OpenCV stores images in BGR format and since pytesseract assumes RGB format,
# we need to convert from BGR to RGB format/mode:
img_rgb = cv2.cvtColor(img_cv, cv2.COLOR_BGR2RGB)
print(pytesseract.image_to_string(img_rgb))
# OR
img_rgb = Image.frombytes('RGB', img_cv.shape[:2], img_cv, 'raw', 'BGR', 0, 0)
print(pytesseract.image_to_string(img_rgb))

If you need custom configuration like oem/psm, use the config keyword.

# Example of adding any additional options
custom_oem_psm_config = r'--oem 3 --psm 6'
pytesseract.image_to_string(image, config=custom_oem_psm_config)

# Example of using pre-defined tesseract config file with options
cfg_filename = 'words'
pytesseract.run_and_get_output(image, extension='txt', config=cfg_filename)

Add the following config, if you have tessdata error like: “Error opening data file…”

# Example config: r'--tessdata-dir "C:\Program Files (x86)\Tesseract-OCR\tessdata"'
# It's important to add double quotes around the dir path.
tessdata_dir_config = r'--tessdata-dir "<replace_with_your_tessdata_dir_path>"'
pytesseract.image_to_string(image, lang='chi_sim', config=tessdata_dir_config)

Functions

  • get_languages Returns all currently supported languages by Tesseract OCR.
  • get_tesseract_version Returns the Tesseract version installed in the system.
  • image_to_string Returns unmodified output as string from Tesseract OCR processing
  • image_to_boxes Returns result containing recognized characters and their box boundaries
  • image_to_data Returns result containing box boundaries, confidences, and other information. Requires Tesseract 3.05+. For more information, please check the Tesseract TSV documentation
  • image_to_osd Returns result containing information about orientation and script detection.
  • image_to_alto_xml Returns result in the form of Tesseract’s ALTO XML format.
  • run_and_get_output Returns the raw output from Tesseract OCR. Gives a bit more control over the parameters that are sent to tesseract.

Parameters

image_to_data(image, lang=None, config='', nice=0, output_type=Output.STRING, timeout=0, pandas_config=None)

  • image Object or String - PIL Image/NumPy array or file path of the image to be processed by Tesseract. If you pass object instead of file path, pytesseract will implicitly convert the image to RGB mode.
  • lang String - Tesseract language code string. Defaults to eng if not specified! Example for multiple languages: lang='eng+fra'
  • config String - Any additional custom configuration flags that are not available via the pytesseract function. For example: config='--psm 6'
  • nice Integer - modifies the processor priority for the Tesseract run. Not supported on Windows. Nice adjusts the niceness of unix-like processes.
  • output_type Class attribute - specifies the type of the output, defaults to string. For the full list of all supported types, please check the definition of pytesseract.Output class.
  • timeout Integer or Float - duration in seconds for the OCR processing, after which, pytesseract will terminate and raise RuntimeError.
  • pandas_config Dict - only for the Output.DATAFRAME type. Dictionary with custom arguments for pandas.read_csv. Allows you to customize the output of image_to_data.

CLI usage:

pytesseract [-l lang] image_file

INSTALLATION

Prerequisites:

  • Python-tesseract requires Python 3.6+
  • You will need the Python Imaging Library (PIL) (or the Pillow fork). Under Debian/Ubuntu, this is the package python-imaging or python3-imaging.
  • Install Google Tesseract OCR (additional info how to install the engine on Linux, Mac OSX and Windows). You must be able to invoke the tesseract command as tesseract. If this isn’t the case, for example because tesseract isn’t in your PATH, you will have to change the “tesseract_cmd” variable pytesseract.pytesseract.tesseract_cmd. Under Debian/Ubuntu you can use the package tesseract-ocr. For Mac OS users. please install homebrew package tesseract.
  • Note: In some rare cases, you might need to additionally install tessconfigs and configs from tesseract-ocr/tessconfigs if the OS specific package doesn’t include them.
Installing via pip:

Check the pytesseract package page for more information.

pip install pytesseract
Or if you have git installed:
pip install -U git+https://github.com/madmaze/pytesseract.git
Installing from source:
git clone https://github.com/madmaze/pytesseract.git
cd pytesseract && pip install -U .
Install with conda (via conda-forge):
conda install -c conda-forge pytesseract

TESTING

To run this project’s test suite, install and run tox. Ensure that you have tesseract installed and in your PATH.

pip install tox
tox

반응형
반응형

心機一轉

심기일전

어떤 동기가 있어 이제까지 가졌던 마음가짐을 버리고 완전히 달라짐.

반응형
반응형

대부분의 사람들은
자신의 영혼과 직접적인 교류를 하지 않는다.
그래서 이를 가엾이 여긴 자연은, 우리가
다른 사람과 서로 사랑에 빠지게 해
조금이나마 영혼과 교류할 수 있는
기회를 주었다.


-디팩 초프라의《더 젊게 오래 사는 법》중에서-


* 사랑에 빠지면 가슴이 열립니다.
세상에게 부드러워지고 자신에게도 온화해집니다.
하늘에서 지상으로 내려와 갓 깨어난 아가처럼 예뻐지고
선해집니다. 그때 비로소 서로의 영혼을 바라볼 수
있게 됩니다. 물리적 시간이 멈추고 영혼의
시간도 멈춥니다. 다시금 더 젊어집니다.
사랑은 영혼과 영혼의 교류입니다.

반응형

'아침편지' 카테고리의 다른 글

관중석 소리 없는 아우성  (0) 2024.02.05
신비 수련  (0) 2024.02.05
문신을 하기 전에  (0) 2024.01.31
미래의 씨앗  (0) 2024.01.30
괴로운 불면의 밤  (0) 2024.01.29
반응형

자신이 내키지 않는데도
상대방의 취향에 따라 문신이나
피어싱을 해야 한다면 어떨까요?
그 사람이 그렇게까지 하면서 사귈만한
존재인지 곰곰이 생각해 보세요. 상대방을
소중히 여기기 전에 나 자신을 소중히
할 줄 알아야 건강한 관계가
형성됩니다.


- 바쿠@정신건강의의 《기분 좋은 일은 매일 있어》 중에서 -


* 문신은 본질적으로
자신의 생각을 밖으로 드러내는 일입니다.
사랑이 영원히 변치 말라고 바위에 이름 새기듯
몸에 표시를 하는 것입니다. 스스로에 대한 다짐과
결심이면 모를까, 상대방에 보여주기 위한 것이면
후회할 가능성이 높습니다. 진정한 사랑은 몸이
아닌 가슴에 새기는 것입니다. 인간의 행위에
영원한 것은 없습니다.

반응형

'아침편지' 카테고리의 다른 글

신비 수련  (0) 2024.02.05
영혼과 영혼의 교류  (0) 2024.02.01
미래의 씨앗  (0) 2024.01.30
괴로운 불면의 밤  (0) 2024.01.29
오늘 날씨  (0) 2024.01.29
반응형

 

 

https://www.theverge.com/2024/1/29/24055011/meta-llama2-code-generator-generative-ai

 

삽화: Alex Castro / The Verge

코드 생성 AI 모델인 Code Llama 70B 에 대한 Meta의 최신 업데이트는 아직까지 "가장 크고 성능이 뛰어난 모델"입니다. Code Llama 도구는 8월에 출시되었으며 연구 및 상업용 모두 무료입니다. Meta의 AI 블로그 게시물에 따르면 Code Llama 70B는 이전 버전보다 더 많은 쿼리를 처리할 수 있습니다. 이는 개발자가 프로그래밍하는 동안 더 많은 프롬프트를 제공할 수 있고 더 정확할 수 있음을 의미합니다.

Code Llama 70B는 HumanEval 벤치마크에서 정확도 53%를 기록하여 GPT-3.5의 48.1%보다 나은 성능을 보였고 GPT-4에 대해 보고된 OpenAI 문서 (PDF) 의 67%에 더 가깝습니다 .

 

Llama 2를 기반으로 구축된 Code Llama는 개발자가 프롬프트에서 코드 문자열을 생성하고 사람이 작성한 작업을 디버깅하는 데 도움이 됩니다. Meta는 지난 가을에 특정 코딩 언어에 초점을 맞춘 두 가지 다른 Code Llama 도구인 Code Llama - Python과 Code Llama - Instruct를 동시에 출시했습니다.

Code Llama 70B는 세 가지 버전의 코드 생성기에서 사용할 수 있으며 연구 및 상업적 용도로는 여전히 무료입니다. 대규모 모델은 1TB의 코드 및 코드 관련 데이터에 대해 학습되었습니다. AI 모델을 실행하기 위해 GPU에 대한 액세스를 제공하는 코드 저장소 Hugging Face에서 호스팅됩니다.

Meta는 자사의 대형 모델인 34B 및 70B가 "최고의 결과를 반환하고 더 나은 코딩 지원을 제공합니다"라고 말했습니다.

다른 AI 개발자들은 작년에 코드 생성기를 출시했습니다. Amazon의 CodeWhisperer는 4월에 출시되었으며 Microsoft는 OpenAI의 모델을 활용하여 GitHub Copilot을 출시했습니다 

반응형
반응형

비전 프로 출시 D-2

Vision Pro Review: 24 Hours With Apple’s Mixed-Reality Headset | WSJ

 

https://www.youtube.com/watch?v=8xI10SFgzQ8

실리콘밸리 시간으로는 3일, 한국시간으로는 2일 후 애플의 신형 디바이스인 비전 프로가 판매를 드디어 시작하는데요. 미국의 미디어 유튜버들의 제품 리뷰와 영상이 본격적으로 공개되기 시작했어요. 유튜브나 뉴스검색을 통해서 찾아보실 수 있는데요. 리뷰어들의 소감 중에서 재미있는 것을 정리해봤어요. 

 

  • 무겁다 : 실제 무게도 있지만 메타 퀘스트와 달리 무게가 앞에 쏠려있는 점이 문제.
  • 가상 키보드는 별로 : 비전 프로로 일을 하고 싶다면 실물 키보드를 추천.
  • 안경은 못쓴다 : 안경을 쓰고 착용하기 어렵기 때문에 도수가 있는 렌즈를 별도로 구매해서 부착해야해요.  
  • 놀라운 디스플레이 : 디스플레이 성능이 너무 좋은데 이것이 높은 가격의 가장 큰 원인 중 하나. 
  • 패스스루도 완벽 : 비전 프로를 착용해도 카메라를 통해서 외부를 보는 혼합현실(Mixed Reality)기능이 매우 훌륭하다고 해요. 
  • 시리를 많이 사용하게 된다 : 음성 AI 비서인 시리가 비전프로에서도 당연히 작동을 하는데, 비전프로를 쓰고 있는 환경에서는 자연스럽게 시리를 호출해서 명령을 내리는 경우가 많아요. 마치 아이언맨이 자비스를 부르는 것 처럼요.  
  • 3D 영상 촬영이 킬러 서비스 : 아이폰15 프로로 공간동영상(Spatial)을 촬영할 수 있는데, 이걸 비전 프로에서 볼 수 있어요. 많은 리뷰어들이 여기에 만족을 나타냈어요. 2D 영상을 보는 것보다 과거의 경험을 다시 생생하게 느낄 수 있다고 해요. 특히 아이의 영상을 찍은 부모들의 만족도가 높았어요. 과거 캠코더가 아이들의 영상을 찍기 위해 많은 부모들이 샀던 것처럼 비전 프로 수요도 있을 것 같아요.  
  • 침대에 누워서 쓰기 좋다 : 침대에서 스마트폰을 쓰는 분들이 많은데, 비전 프로를 쓰면 무게도 덜 느끼고 좋을 것 같아요.

패스스루란?

패스스루는 VR 화면에서 벗어나 주변의 실제 환경을 볼 수 있게 해주는 기능입니다. 패스스루는 헤드셋의 센서를 사용하여 사용자가 헤드셋 너머의 실제 환경을 본다고 가정했을 때 보게 될 환경을 대략적으로 보여줍니다. 안전 보호 경계를 만들거나 조정할 때 자동으로 패스스루가 작동합니다. 실제 및 가상 환경을 혼합하기 위해 앱에도 패스스루가 표시됩니다.

반응형

+ Recent posts