microsoftml.extract_pixels: 이미지에서 픽셀 추출

사용

microsoftml.extract_pixels(cols: [str, dict, list],
    use_alpha: bool = False, use_red: bool = True,
    use_green: bool = True, use_blue: bool = True,
    interleave_argb: bool = False, convert: bool = True,
    offset: float = None, scale: float = None, **kargs)

Description

이미지에서 픽셀 값을 추출합니다.

세부 정보

extract_pixels는 이미지에서 픽셀 값을 추출합니다. 입력 변수는 크기가 같은 이미지이며, 일반적으로 resizeImage 변환의 출력입니다. 출력은 일반적으로 학습자에 대한 기능으로 사용되는 벡터 형식의 픽셀 데이터입니다.

인수

cols

변환할 문자열 또는 변수 이름 목록입니다. dict이면 키는 만들 새 변수의 이름을 나타냅니다.

use_alpha

알파 채널을 사용할지 여부를 지정합니다. 기본값은 False입니다.

use_red

빨간색 채널을 사용할지 여부를 지정합니다. 기본값은 True입니다.

use_green

녹색 채널을 사용할지 여부를 지정합니다. 기본값은 True입니다.

use_blue

파란색 채널을 사용할지 여부를 지정합니다. 기본값은 True입니다.

interleave_argb

각 채널이나 인터리브를 ARGB 순서로 구분할지 여부입니다. 예를 들어 합성곱 신경망을 학습시키는 경우 커널, stride 등의 모양에 영향을 주기 때문에 중요할 수 있습니다.

convert

부동 소수점으로 변환할지 여부입니다. 기본값은 False입니다.

offset

오프셋(프리스케일)을 지정합니다. convert = True여야 합니다. 기본값은 없음입니다.

소수 자릿수

배율을 지정합니다. convert = True여야 합니다. 기본값은 없음입니다.

kargs

컴퓨팅 엔진으로 전송된 추가 인수입니다.

반환

변환을 정의하는 개체입니다.

추가 정보

load_image, resize_image, featurize_image.

'''
Example with images.
'''
import numpy
import pandas
from microsoftml import rx_neural_network, rx_predict, rx_fast_linear
from microsoftml import load_image, resize_image, extract_pixels
from microsoftml.datasets.image import get_RevolutionAnalyticslogo

train = pandas.DataFrame(data=dict(Path=[get_RevolutionAnalyticslogo()], Label=[True]))

# Loads the images from variable Path, resizes the images to 1x1 pixels
# and trains a neural net.
model1 = rx_neural_network("Label ~ Features", data=train, 
            ml_transforms=[            
                    load_image(cols=dict(Features="Path")), 
                    resize_image(cols="Features", width=1, height=1, resizing="Aniso"), 
                    extract_pixels(cols="Features")], 
            ml_transform_vars=["Path"], 
            num_hidden_nodes=1, num_iterations=1)

# Featurizes the images from variable Path using the default model, and trains a linear model on the result.
# If dnnModel == "AlexNet", the image has to be resized to 227x227.
model2 = rx_fast_linear("Label ~ Features ", data=train, 
            ml_transforms=[            
                    load_image(cols=dict(Features="Path")), 
                    resize_image(cols="Features", width=224, height=224), 
                    extract_pixels(cols="Features")], 
            ml_transform_vars=["Path"], max_iterations=1)

# We predict even if it does not make too much sense on this single image.
print("\nrx_neural_network")
prediction1 = rx_predict(model1, data=train)
print(prediction1)

print("\nrx_fast_linear")
prediction2 = rx_predict(model2, data=train)
print(prediction2)

출력:

Automatically adding a MinMax normalization transform, use 'norm=Warn' or 'norm=No' to turn this behavior off.
Beginning processing data.
Rows Read: 1, Read Time: 0, Transform Time: 0
Beginning processing data.
Beginning processing data.
Rows Read: 1, Read Time: 0.001, Transform Time: 0
Beginning processing data.
Beginning processing data.
Rows Read: 1, Read Time: 0, Transform Time: 0
Beginning processing data.
Using: AVX Math

***** Net definition *****
  input Data [3];
  hidden H [1] sigmoid { // Depth 1
    from Data all;
  }
  output Result [1] sigmoid { // Depth 0
    from H all;
  }
***** End net definition *****
Input count: 3
Output count: 1
Output Function: Sigmoid
Loss Function: LogLoss
PreTrainer: NoPreTrainer
___________________________________________________________________
Starting training...
Learning rate: 0.001000
Momentum: 0.000000
InitWtsDiameter: 0.100000
___________________________________________________________________
Initializing 1 Hidden Layers, 6 Weights...
Estimated Pre-training MeanError = 0.707823
Iter:1/1, MeanErr=0.707823(0.00%), 0.00M WeightUpdates/sec
Done!
Estimated Post-training MeanError = 0.707499
___________________________________________________________________
Not training a calibrator because it is not needed.
Elapsed time: 00:00:00.2716496
Elapsed time: 00:00:00.0396484
Automatically adding a MinMax normalization transform, use 'norm=Warn' or 'norm=No' to turn this behavior off.
Beginning processing data.
Rows Read: 1, Read Time: 0, Transform Time: 0
Beginning processing data.
Beginning processing data.
Rows Read: 1, Read Time: 0, Transform Time: 0
Beginning processing data.
Beginning processing data.
Rows Read: 1, Read Time: 0, Transform Time: 0
Beginning processing data.
Using 2 threads to train.
Automatically choosing a check frequency of 2.
Auto-tuning parameters: L2 = 5.
Auto-tuning parameters: L1Threshold (L1/L2) = 1.
Using model from last iteration.
Not training a calibrator because it is not needed.
Elapsed time: 00:00:01.0508885
Elapsed time: 00:00:00.0133784

rx_neural_network
Beginning processing data.
Rows Read: 1, Read Time: 0, Transform Time: 0
Beginning processing data.
Elapsed time: 00:00:00.1339430
Finished writing 1 rows.
Writing completed.
  PredictedLabel     Score  Probability
0          False -0.028504     0.492875

rx_fast_linear
Beginning processing data.
Rows Read: 1, Read Time: 0, Transform Time: 0
Beginning processing data.
Elapsed time: 00:00:00.4977487
Finished writing 1 rows.
Writing completed.
  PredictedLabel  Score  Probability
0          False    0.0          0.5