9월, 2017의 게시물 표시

faceGAN 156000

이미지
 

dcGAN 300_300epoch

이미지

Discrimi by PyTorch

이미지

이미지 방향비 무시 강제 리사이징

mogrify -resize 128x128! *.jpg

mnistGAN by PyTorch

https://github.com/prcastro/pytorch-gan.git

faceGAN by PyTorch

이미지
https://github.com/yunjey/pytorch-tutorial/tree/master/tutorials/03-advanced/deep_convolutional_gan

Gaussian GAN by PyTorch

https://github.com/devnag/pytorch-generative-adversarial-networks.git

AnoGAN by Torch

https://github.com/aleju/gan-reverser.git

ADD-GAN

https://github.com/zblasingame/ADD-GAN.git

ConvLSTM by Keras, Image Prediction

이미지

jupyter theme

https://github.com/dunovank/jupyter-themes.git

node.js upgrade by nvm

https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-16-04

R: imagemagick

install.packages ( "magick" ) str ( magick : : magick_config ( ) )

R: tesseract OCR

install.packages ( "tesseract" ) img <- image_read ( "http://jeroen.github.io/images/testocr.png" ) print ( img ) # Extract text cat ( image_ocr ( img ) )

R install & Run in Ubuntu Terminal

https://www.digitalocean.com/community/tutorials/how-to-install-r-on-ubuntu-16-04-2

MFCC

이미지
Applications [ edit ] MFCCs are commonly used as  features  in  speech recognition [6]  systems, such as the systems which can automatically recognize numbers spoken into a telephone. MFCCs are also increasingly finding uses in  music information retrieval  applications such as  genre classification, audio similarity measures, etc. [7] Noise sensitivity [ edit ] MFCC values are not very robust in the presence of additive noise, and so it is common to normalise their values in speech recognition systems to lessen the influence of noise. Some researchers propose modifications to the basic MFCC algorithm to improve robustness, such as by raising the log-mel-amplitudes to a suitable power (around 2 or 3) before taking the DCT, which reduces the influence of low-energy components. [8]

FSC vs MFSC vs MFCC

이미지

2d fft by imagemagick

이미지
convert image.png -fft +depth +adjoin fft_image_%d.png   brew reinstall imagemagick --with-fftw    

1D 2D 3D FFT by Pytorch

# Example that does a batch of three 2D transformations of size 4 by 5. import torch import pytorch_fft.fft as fft A, zeros = torch.randn( 3 , 4 , 5 ).cuda(), torch.zeros( 3 , 4 , 5 ).cuda() B_real, B_imag = fft.fft2(A_real, A_imag) fft.ifft2(B_real, B_imag) # equals (A, zeros) B_real, B_imag = fft.rfft2(A) # is a truncated version which omits # redundant entries reverse(torch.arange( 0 , 6 )) # outputs [5,4,3,2,1,0] reverse(torch.arange( 0 , 6 ), 2 ) # outputs [4,5,2,3,0,1] expand(B_real) # is equivalent to fft.fft2(A, zeros)[0] expand(B_imag, imag = True ) # is equivalent to fft.fft2(A, zeros)[1]

ranger for linux

이미지

spectrogram vs scalogram

이미지
  - 기저함수의 선택이 가능하다. - 파형보단 주파수 분포가 중요하다. - 파형 전체를 보여준다. - 속도가 느리다. -저주파로 갈수록 정보가 제한적이다. - - 가로축으로 파형도 어느정도 표현된다. - 파형을 잘라서 스텍트럼을 보여준다. - 기저함수의 선택이 불가능하다. - 속도가 빠르다.    - 웨이블릿 기저 함수들. - 프랙탈 구조를 갖는 놈들도 보인다. - 이걸로 오그먼테이션도 가능할듯 싶다.

deepEye PC control by TF

https://github.com/despoisj/DeepEyeControl.git

ofPushMatrix(), ofPopMatrix()

이미지

ofxTSNE code

// h----------------------------- #pragma once #include "ofMain.h" #include "ofxCcv.h"     // Another OpenCV #include "ofxTSNE.h"    // T-SNE Plot #include "ofxGui.h" class ofApp : public ofBaseApp{     public:         void setup();         void update();         void draw();         void keyPressed(int key);         void keyReleased(int key);         void mouseMoved(int x, int y );         void mouseDragged(int x, int y, int button);         void mousePressed(int x, int y, int button);         void mouseReleased(int x, int y, int button);         void mouseEntered(int x, int y);         voi...

log to csv in terminal

sed 's/ \+/,/g' conn.log > conn.csv

Confusion Matrix Multiclass using R

이미지
  require( ggplot2 ) input <- read.delim( " conf_matrix.csv " , header = TRUE , sep = " , " ) input.matrix <- data.matrix( input ) input.matrix.normalized <- normalize( input.matrix ) colnames( input.matrix.normalized ) = c( " A " , " B " , " C " , " D " , " E " , " F " , " G " , " H " , " I " , " J " , " K " , " L " , " M " , " N " ) rownames( input.matrix.normalized ) = colnames( input.matrix.normalized ) confusion <- as.data.frame(as.table( input.matrix.normalized )) plot <- ggplot( confusion ) plot + geom_tile(aes( x = Var1 , y = Var2 , fill = Freq )) + sc...

Confusion Matrix using R

actual, predicted A, B B, B, C, C B, A   ---------------------   require( caret ) results <- read.delim( " classifier-results.csv " , sep = " , " , header = FALSE ) names( results ) <- c( " actual " , " predicted " ) results.matrix <- confusionMatrix( results $ predicted , results $ actual )  

Accuracy 와 Precision, Recall 의 차이

이미지

랜덤 셔플 파일 이동

$ mv $(ls | gshuf -n30) ../result/ 이미지가 있는 디렉토리에서 .. 30개 만큼 리절트 폴더로  mv $ brew install coreutils

[python] csv file to binary

#!/usr/bin/env python import array with open ( 'input.csv' , 'rt' ) as f : text = f . read () entries = text . split ( ',' ) values = [ int ( x ) for x in entries ] # do a scalar here: if your input goes from [-100, 100] then # you may need to translate/scale into [0, 2^16-1] for # 16-bit PCM # e.g.: # values = [(val * scale) for val in values] with open ( 'output.pcm' , 'wb' ) as out : pcm_vals = array . array ( 'h' , values ) # 16-bit signed pcm_vals . tofile ( out ) You could also use Python's wave module instead of just writing raw PCM. Here's how the example above works: $ echo 1 , 2 , 3 , 4 , 5 , 6 , 7 > input . csv $ ./ so_pcm . py $ xxd output . pcm 0000000 : 0100 0200 0300 0400 0500 0600 0700 ..............

ofx SVM Classification

이미지
// h----------------------------- #pragma once #include "ofMain.h" #include "ofxLearn.h"           // 딥러닝 패키지 class ofApp : public ofBaseApp{ public:     void setup();     void update();     void draw();         void keyPressed(int key);     void keyReleased(int key);     void mouseMoved(int x, int y);     void mouseDragged(int x, int y, int button);     void mousePressed(int x, int y, int button);     void mouseReleased(int x, int y, int button);     void windowResized(int w, int h);     void dragEvent(ofDragInfo dragInfo);     void gotMessage(ofMessage msg);         ofxLearnSVM classifier;         // 써포트 벡터 머신     vector<vector<double> > trainingEx...

makeROCData.py

#!/usr/bin/python import os import re from scipy import ndimage, misc import torch import torch.nn as nn #from __future__ import print_function import argparse from PIL import Image import torchvision.models as models import skimage.io from torch.autograd import Variable as V from torch.nn import functional as f from torchvision import transforms as trn # define image transformation centre_crop = trn.Compose([         trn.ToPILImage(),         trn.Scale(256),         trn.CenterCrop(224),         trn.ToTensor(),         trn.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]) ]) images = [] for root, dirnames, filenames in os.walk("/home/kerb/Documents/data_bm_0913/test/benign/"):     for filename in filenames:      # for all files        ...

ROCR

https://stackoverflow.com/questions/23130259/roc-curve-from-csv-file

GAN cs231n 2017

이미지

pdf 번역 사이트

https://www.onlinedoctranslator.com/

파이썬 조각 코드모음

https://wikidocs.net/3739

무료 Jupyter

https://jupyter.nims.re.kr

[PyTorch] testAccuacy in CPU

import torch import torch.nn as nn #from __future__ import print_function import argparse from PIL import Image import torchvision.models as models import skimage.io from torch.autograd import Variable as V from torch.nn import functional as f from torchvision import transforms as trn # define image transformation centre_crop = trn.Compose([         trn.ToPILImage(),         trn.Scale(256),         trn.CenterCrop(224),         trn.ToTensor(),         trn.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]) ]) filename=r'/Users/dti/Desktop/PyTorch4testAccuracy/hymenoptera_data/test/bees/1.jpg' img = skimage.io.imread(filename) x = V(centre_crop(img).unsqueeze(0), volatile=True) model = models.__dict__['resnet18'] model = torch.load('model5.pth') logit = model(x) print(logit) h_x = f...
def accuracy ( predictions , labels ): return ( 100.0 * np . sum ( np . argmax ( predictions , 2 ) . T == labels ) / predictions . shape [ 1 ] / predictions . shape [ 0 ])

[python] redirecting to file

f = open ( 'out.txt' , 'w' ) print >> f , 'Filename:' , filename # or f.write('...\n') f . close ()