2016-11-11 1 views
0

내가 원하는 것은 간단한 픽셀 단위 분류 또는 회귀 작업을 수행하는 것입니다. 그러므로 나는 입력 이미지와 ground_truth를 가지고있다. 내가 원하고 싶은 것은 내가 원과 직사각형을 가진 쉬운 세분화 작업을하는 것입니다. 그리고 원이나 사각형이있는 곳을 훈련하고 싶습니다. 즉, 원이있는 모든 위치에서 값이 "1"이고 사각형이있는 모든 위치에서 값이 "2"인 ground_truth 이미지가 있음을 의미합니다. 그런 다음 이미지와 ground_truth 이미지를 .png 이미지 형태로 입력합니다.caffe 픽셀 단위 분류/회귀

layer { 
    name: "upscore" 
    type: "Deconvolution" 
    bottom: "score_fr" 
    top: "upscore" 
    param { 
    lr_mult: 0 
    } 
    convolution_param { 
    num_output: 3 ## <<---- 0 = backgrund 1 = circle 2 = rectangle 
    bias_term: false 
    kernel_size: 63 
    stride: 32 
    } 
} 
layer { 
    name: "score" 
    type: "Crop" 
    bottom: "upscore" 
    bottom: "data" 
    top: "score" 
    crop_param { 
    axis: 2 
    offset: 18 
    } 
} 
layer { 
    name: "loss" 
    type: "SoftmaxWithLoss" ## <<---- 
    bottom: "score" 
    bottom: "ground_truth" 
    top: "loss" 
    loss_param { 
    ignore_label: 0 
    } 
} 
: 나는 fcn alexnet

분류에서 완전히 길쌈 AlexNet을 사용하고 있습니다 : enter image description here

circle는 그럼 나도 내 손실 층에 따라 회귀 또는 분류 작업을 할 수 있다고 생각

회귀 :

layer { 
    name: "upscore" 
    type: "Deconvolution" 
    bottom: "score_fr" 
    top: "upscore" 
    param { 
    lr_mult: 0 
    } 
    convolution_param { 
    num_output: 1 ## <<---- 1 x height x width 
    bias_term: false 
    kernel_size: 63 
    stride: 32 
    } 
} 
layer { 
    name: "score" 
    type: "Crop" 
    bottom: "upscore" 
    bottom: "data" 
    top: "score" 
    crop_param { 
    axis: 2 
    offset: 18 
    } 
} 
layer { 
    name: "loss" 
    type: "EuclideanLoss" ## <<---- 
    bottom: "score" 
    bottom: "ground_truth" 
    top: "loss" 
} 

그러나 이것은 내가 원하는 결과조차 만들어 내지 않습니다. 나는 픽셀 단위 분류/회귀에 대한 나의 이해가 잘못되었다고 생각한다. 제 실수가 어디 있는지 말씀해 주시겠습니까? 출력 검 같을 것이다 회귀

EDIT 1

:

output_blob = pred['result'].data 

predicated_image_array = np.array(output_blob) 
predicated_image_array = predicated_image_array.squeeze() 
print predicated_image_array.shape 
#print predicated_image_array.shape 

#print mean_array 
range_value = np.ptp(predicated_image_array) 
min_value = predicated_image_array.min() 
max_value = predicated_image_array.max() 

# make positive 
predicated_image_array[:] -= min_value 

if not range_value == 0: 
    predicated_image_array /= range_value 

predicated_image_array *= 255 
predicated_image_array = predicated_image_array.astype(np.int64) 
print predicated_image_array.shape 

cv2.imwrite('predicted_output.jpg', predicated_image_array) 

출력이 1 × 높이 X 폭이고, 값은 실제 출력하기 때문에 이것은 용이 값. 그러나 출력이 3 (num 레이블) x 높이 x 너비이므로 분류/SotMaxLayer의 출력을 어떻게 검색 할 수 있습니까? 그러나 나는이 형태의 내용의 의미를 모른다.

답변

0

우선 문제는 regression이 아니라 classification입니다.

그물을 인식하려면 원형과 직사각형을 다른 데이터 세트 (예 : circle - 0 and rectangle - 1)와 같이 이미지와 라벨을 만들어야합니다. 이미지 경로와 이미지 레이블을 포함하는 텍스트 파일을 만들면됩니다 (예 : /path/circle1.png 0 /path/circle2.png 0 /path/rectangle1.png 1 /path/rectangle1.png 1). 너 같은 문제에 대한 좋은 tutorial입니다. 행운을 빕니다.

+0

아니요! 나는 픽셀 단위의 분류 또는 회귀 작업을 원한다. 그냥 쉬운 것. 나는 당신이 정상적인 분류 작업으로 그것을 할 수 있다는 것을 알고 있지만, 나는 픽셀 단위의 분류를하고 싶다. 내 생각은 세분화/분류를하는 것이 었습니다. 내가 뭐라는지 알 겠어? – thigi

+0

다음과 같이 생각할 수도 있습니다. 하나의 이미지에 원과 사각형이 있으며 세그먼트를 만들고 싶습니다! 표준 분류를 수행하는 방법을 알고 있기 때문에 픽셀 단위의 예측 작업을 정말 쉽게 수행 할 수 있기를 원하지만, 나중에 픽셀 단위의 예측을 수행하고 더 어려운 작업을 수행하고 싶습니다. – thigi

+0

그래서'segmentation'으로 할 수 있습니다. 각 이미지 (원/직사각형)에 대해 GT 이미지 (0-255)를 만들어야합니다. 각 이미지의 클래스 수는 2 (배경 및 기하학적 모양)이므로 'num_output : 2'입니다. 배경을 0으로 설정하고 모양을 1. 행운을 비네. –

관련 문제