pylearn2 미세먼지 팁 모음

일본 여배우 얼굴들에서 피쳐 뽑기

http://kensuke-mi.xyz/kensuke-mi_diary/2014/11/rbma.html

댓글

  1. 꿀꺽 꿀꺽 쉽게 pylearn2를 사용까지의 단계를 쓰면 이렇게된다

    (전제) python, git, pip를 사용할 수있는 상태. numpy와 scipy가 설치되어있다.
    1 theano 설치
    2 pylearn2를 설치한다. (그렇다고해도 git clone을)
    python, git, pip, numpy, scipy 사용 준비의 설명은 이번 뺀다.

    답글삭제
  2. theano 설치
    pip install theano

    에서 끝장 인 것 (설정이 잘되어 있으면)

    답글삭제
  3. 필요한 라이브러리

    PIL
    PyYAML
    IPython
    Cython
    전부 pip install명령으로 낙승이다.

    그러나 PIL은 pip install PIL는 안되고 pip install pillow으로

    답글삭제
  4. pylearn2 설치

    다음의 두 명령을 실행하면 잘될 (두)

    git clone git://github.com/lisa-lab/pylearn2.git

    python setup.py develop

    답글삭제
  5. pylearn2 테스트

    pylearn2의 사용법은 간단하게 정리하면,

    데이터 세트를 준비한다 ( .plk되고, .csv이든지)
    훈련 데이터의 경로와 훈련 방법의 레시피를 작성 (* .yaml 파일에)
    train 레서피인 yaml 파일 실행

    이 사이트의 아래쪽에 CIFAR10과 MNIST라는 이미지 데이터 세트의 샘플 실행 예가있다.

    http://deeplearning.jp/?p=196
    http://shower.human.waseda.ac.jp/~asaitaku/tool​​sManual/_build/html/python/pylearn2/main.html

    답글삭제
  6. https://github.com/laughing/grbm_sample

    -여배우 목록에서 원하는 여배우의 이미지를 모아 온다.
    -여배우의 사진을 입력하고 Deep learning 모델을 구축 본다.
    -공통적 인 특징 량을 추출한다.

    답글삭제
  7. rgb2gray.py
    ------------------------------------------------------

    #! /usr/bin/python

    from PIL import Image
    from PIL import ImageOps
    import os
    import sys

    if __name__ == "__main__":
    if len(sys.argv)==3:
    input_path = sys.argv[1]
    output_path = sys.argv[2]
    else:
    sys.exit("Need 2 args. Input ans Output path")

    input_image = Image.open(input_path)
    output_image = ImageOps.grayscale(input_image)
    output_image.save(output_path)

    답글삭제
  8. img2hsv,py
    ------------------------------------------------

    import numpy
    import Image
    import ImageOps
    import ImageFilter

    import sys
    import glob

    def usage():
    print "./img2csv.py img csv"

    if len(sys.argv) != 3:
    usage()
    exit(0)

    _, imgPath, csvPath = sys.argv

    def gs(path):
    im = Image.open(path)
    im = ImageOps.grayscale(im)
    im.save("%s_gs.png" % path.split(".")[0])
    return im

    def resize(im, x, y):
    return im.resize((x, y))

    def edge(im):
    return im.filter(ImageFilter.FIND_EDGES)

    def img2text(path):
    im = resize(gs(path), 48, 48)
    # im.save("gs.png")
    l = (numpy.asarray(im).flatten() / 255.0).tolist()
    #l = [1 if e > 0.5 else 0 for e in l]
    l = [str(e) for e in l]
    return " ".join(l)

    def img2csv(imgPath, csvPath):
    import csv
    f = open(csvPath, "w")
    writer = csv.writer(f)
    writer.writerow([1,1])
    for e in glob.glob(imgPath):
    print e
    l = img2text(e)
    writer.writerow([1, l])
    f.close()

    if __name__ == "__main__":
    img2csv(imgPath, csvPath)

    답글삭제
  9. python img2hsv.py gray1.jpg gray2.jpg ... train.csv

    를 실행한다.

    답글삭제

댓글 쓰기

이 블로그의 인기 게시물

파이썬으로 Homomorphic Filtering 하기

파이썬으로 2D FFT/iFFT 하기: numpy 버전