Skip to main content

semi-colon is a utility package for CV, data science, Machine Learning and Deep Learning.

Project description

  • semi-colon is a utility module designed for use in Computer Vision, Data Science, Machine Learning, and Deep Learning.
  • This document was written in Korean. If necessary, machine translate it into your preferred language.
  • semi-colon은 컴퓨터 비전, 데이터 과학, 머신러닝, 딥러닝에 사용하기 좋게 만든 유틸리티 모듈입니다.

semi_colon

load_boston()

  • scikit-learn에서 더 이상 제공하지 않는 sklearn.datasets.load_boston()과 동일한 기능입니다.
  • 당연하게도 저는 인종차별에 동의하지 않습니다.

imshows(imgs, rows=1, cols=None, bgr=True, figsize=None, axis=False)

  • matplotlib을 이용해서 imgs에 전달한 이미지를 한 번에 표시합니다.
  • imgs : 표시할 이미지
    • imgs는 다음 중 하나가 될 수 있습니다.
      • 하나의 NumPy Array, 예) img = cv2.imread('tkv.jpg)
      • List 또는 Tuple에 들어 있는 NumPy Array, 예) [img1, img2], (img1, img2)
      • 제목을 key로 하고 NumPy Array를 value로 하는 Dict, 예) {'img1':img1, 'img2':img2}
    • matplotlib은 image의 값을 자동으로 0~255로 정규화해서 표시합니다. 따라서 이미지의 dtype은 uint8은 물론이고 소수점이 있는 float 계열도 표시에 문제가 없지만 warning 메시지가 표시될 수 있습니다.
  • rows : 몇 행으로 표시할 지 정수로 지정합니다.
  • cols : 몇 열로 표시할 지 정수로 지정합니다. 생략하면 imgs의 갯수에 따라 자동으로 결정합니다.
  • bgr : imgs의 컬러 채널 순서를 지정합니다.True이면 BGR, False이면 RGB입니다. gray 컬러(2D) 일때는 무시하고 자동으로 gray 컬러로 출력합니다.
  • figsize : 표시할 영역의 크기를 (width,height) 순으로 지정합니다.
  • axis : 축 눈금 표시 여부
  • example
img = cv2.imread('tkv.jpg')
imshows(img)
imshows((img, img))
imshows({'first':img, 'second':img})

getImage(name, dir=None)

  • https://github.com/dltpdn/download/tree/master/img 에서 name에 해당하는 이미지를 다운로드 합니다.
  • 다운로드 위치는 dir를 지정하지 않으면 ./img/ 로 고정되어 있습니다. ./img 디렉토리가 없으면 자동으로 생성합니다.

download(url, dir=None, file_name=None, extract=False)

  • url로 부터 파일을 dir에 다운로드 합니다.
  • url이 github.com 이라면, url의 master/를 기준으로 자동으로 다운로드 되는 경로와 파일이름이 결정됩니다.
  • extract=True 인 경우 zip, tar 파일은 압축을 해제합니다.

digit_split(image, size=None, flatten=False, border=0, inverse=True)

사용자가 직접 작성한 숫자 손글씨 이미지에서 각 숫자를 원하는 크기로 분할해서 반환합니다.

  • image에 포함된 각각의 숫자를 개별 이미지로 분할해서 리스트에 담아 반환합니다.
  • size는 반환 이미지의 크기를 지정할 수 있습니다.
  • flatten=True은 (1, n) 형태로 변환해서 반환합니다.
  • border는 반환하는 이미지의 테두리 여백을 지정합니다.
  • inverse는 흰색과 검정색을 반전합니다.

draw_bbox(img, x1, y1, x2, y2, text=None, txt_color=(255,255,255), bb_color=None, thickness=2)

  • img에 주어진 x1,y1,x2,y2 좌표로 bounding box를 표시하고 사본을 반환합니다.
  • text : bounding box의 좌상단에 text를 표시합니다. 클래스 이름과 확률 값을 표시하는 용도로 쓰면 좋습니다.
  • txt_color : text를 표시할 때 사용할 컬러 값입니다.
  • bb_color : bounding box 테두리 선 컬러 값입니다. 생략하면 무작위로 선택합니다.
  • thickness : bounding box 테두리 선의 두께 값입니다.

get_iou(pred, gt)

  • pred, gt로 IoU(Intersection of Union)를 계산해서 반환합니다.

semi_colon.colab

Google colab에서만 동작하는 함수들을 포함하는 패키지 입니다. OpenCV headless 버전에서 동작하지 않는 GUI 상호작용 기능을 colab의 notebook 환경에서 유사하게 동작하게 했습니다. 이 패키지는 google.colab 관련 패키지에 종속성이 있어서 colab이외의 환경에서는 동작하지 않으니 코드에 import 구문을 넣는데 유의하세요.

setMouseCallback(img, onmouse=None)

  • 이 함수는 Google Colab에서만 동작합니다.
  • cv2.setMouseCallBack()함수를 Google Colab에서 사용 할 수 있게 수정했습니다.
  • img를 출력으로 표시하고 마우스 이벤트가 발생하면 onmouse 함수를 호출합니다.
  • onmouse에 지정할 함수의 parameter는 cv2.setMouseCallback()callback(event, x, y, flag, param) 함수와 형식이 동일합니다.
  • callback에 전달되는 param은 기능이 없고 언제나 None입니다.

selectROI(img, callback)

  • 이 함수는 Google Colab에서만 동작합니다.
  • cv2.selectROI()함수를 Google Colab에서 사용 할 수 있게 수정했습니다.
  • img를 출력으로 표시하고 마우스로 ROI 영역을 선택하고 나면 callback(x,y,w,h)를 호출 합니다.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

semi_colon-0.2.9.tar.gz (24.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

semi_colon-0.2.9-py3-none-any.whl (22.7 kB view details)

Uploaded Python 3

File details

Details for the file semi_colon-0.2.9.tar.gz.

File metadata

  • Download URL: semi_colon-0.2.9.tar.gz
  • Upload date:
  • Size: 24.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for semi_colon-0.2.9.tar.gz
Algorithm Hash digest
SHA256 313632bd99ce2f3a4656064e77566e3c78f6a73fa580cf2ae51aa91ae340f365
MD5 b996f657e75ef7308903132dbc13d9df
BLAKE2b-256 a0edd7658aea04cefbb91ae8a0f549372c280740d64af16c5a8c3ab034e41a83

See more details on using hashes here.

File details

Details for the file semi_colon-0.2.9-py3-none-any.whl.

File metadata

  • Download URL: semi_colon-0.2.9-py3-none-any.whl
  • Upload date:
  • Size: 22.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for semi_colon-0.2.9-py3-none-any.whl
Algorithm Hash digest
SHA256 b0aa98919fd427b8a66013d97edd0f8a10b2064ed70022e1a8a43e210e044900
MD5 0fa0b374c9889439428c93e7dd5a4d5e
BLAKE2b-256 6f59856b348494027220a03f42b43339a6409028d52bfcffe4be716f2e78d193

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page