In [3]:
import cv2
import matplotlib.pyplot as plt
%matplotlib inline
import sys
import pdb
import numpy as np

In [4]:
from inca.models.image import Image

In [5]:
i = Image.get(849555)
mask = i.get_maskjson_asset('ships')
mask.download_asset()
print mask.local_asset_path


pan = i.get_panchromatic_asset()
pan.download_asset()


/tmp/fa75d9df9aa44a929dff60d75ac34e68

In [6]:
mask = i.get_mask_asset

In [7]:
# Get Pan Image
pan_im = cv2.imread(pan.local_asset_path,-1)
plt.imshow(pan_im[500:,0:500],cmap=plt.get_cmap('gray'))

# Get Predicted Heatmap
plt.figure()
probs,_,hm,cm =i.get_prediction_assets(10972)
hm.download_asset()
hm_im = cv2.imread(hm.local_asset_path)
plt.imshow(hm_im,cmap=plt.get_cmap('gray'))

#Get Ground Truth Mask (cant figure out how to get it, so getting from confusion matrix)
plt.figure()
cm.download_asset()
cm_im = cv2.imread(cm.local_asset_path)

#Get Raw probs
probs.download_asset()
print probs.local_asset_path


/tmp/5c9159b5a9a24c69811ef20baf91c8ab.npz
<matplotlib.figure.Figure at 0x7f22332e9bd0>

In [8]:
import cv2

In [91]:
pan_im.shape


Out[91]:
(1024, 1024)

In [92]:
edges = cv2.Canny(np.uint8(pan_im),1000,1100)
plt.imshow(edges)


Out[92]:
<matplotlib.image.AxesImage at 0x7f623c1f3f90>

In [93]:
hog = cv2.HOGDescriptor()
h = hog.compute(np.uint8(pan_im))

In [94]:
h.shape


Out[94]:
(51683940, 1)

In [95]:
plt.imshow(np.uint8(pan_im))


Out[95]:
<matplotlib.image.AxesImage at 0x7f623c25b9d0>

In [96]:
edges = cv2.Canny

In [9]:
test1_im = pan_im#[500:1000,0:500]
test1_hm = hm_im#[500:1000,0:500]
test1_cm = cm_im#[500:1000,0:500]
probs_im = np.load(probs.local_asset_path)['arr_0']
test1_probs = probs_im#[500:1000,0:500]

In [10]:
import pydensecrf.densecrf as dcrf
from pydensecrf.utils import unary_from_labels, create_pairwise_bilateral, create_pairwise_gaussian, unary_from_softmax, softmax_to_unary
from pydensecrf.utils import unary_from_softmax, create_pairwise_bilateral

In [11]:
#unary = -np.log(test1_probs + 0.0000001)

In [17]:
test1_probs.shape


Out[17]:
(1, 1024, 1024)

In [13]:
test_back_score=1 - test1_probs

In [18]:
test_back_score.shape


Out[18]:
(1, 1024, 1024)

In [15]:
test_back_score=np.expand_dims(test_back_score,axis=0)

In [16]:
test1_probs=np.expand_dims(test1_probs,axis=0)

In [ ]:


In [19]:
total_unary=np.vstack((test1_probs,test_back_score))

In [20]:
total_unary.shape


Out[20]:
(2, 1024, 1024)

In [21]:
shape_im=1024

In [22]:
plt.imshow(total_unary[0].reshape((shape_im,shape_im)))


Out[22]:
<matplotlib.image.AxesImage at 0x7f2232e94a50>

In [23]:
plt.imshow(total_unary[1].reshape((shape_im,shape_im)))


Out[23]:
<matplotlib.image.AxesImage at 0x7f2232dd3210>

In [ ]:


In [ ]:


In [24]:
unary=np.copy(total_unary)
n_label = unary.shape[0]
im_height = unary.shape[1]
im_width = unary.shape[2]
print n_label,im_height,im_width
d = dcrf.DenseCRF2D(im_height, im_width, n_label)
U = unary.reshape((n_label,-1))
Up = (U+0.001) / (np.sum(U, axis=0))
print np.max(Up),np.min(Up),Up.shape
# tt=-np.log(Up+0.0000001)
# print np.max(tt),np.min(tt)
unary = softmax_to_unary(Up)
d.setUnaryEnergy(unary)
d.addPairwiseGaussian(3, 1)
from pydensecrf.utils import unary_from_softmax, create_pairwise_bilateral
pairwise_energy = create_pairwise_bilateral(sdims=(30,30), schan=(1,), img=test1_im.reshape((shape_im,shape_im,1)), chdim=2)
d.addPairwiseEnergy(pairwise_energy,compat=1000)

Q = d.inference(1)
Q = np.array(Q).reshape((n_label, im_height,im_width))
out_label = np.argmax(Q, axis=0)
Q.shape
out_label.shape
out_label=out_label[800:,200:400]
plt.imshow(1-out_label,cmap=plt.get_cmap('gray'))
plt.figure()
test1_hm2=test1_hm[800:,200:400]
plt.imshow(test1_hm2,cmap=plt.get_cmap('gray'))
print np.min(out_label),np.max(out_label),out_label.dtype


WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
2 1024 1024
1.001 0.0010004 (2, 1048576)
0 1 int64

In [25]:
out_label.shape


Out[25]:
(224, 200)

In [26]:
np.max(out_label)


Out[26]:
1

In [28]:
cv2.findContours(out_label, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-28-8c43eb24a5cd> in <module>()
----> 1 cv2.findContours(out_label, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)

TypeError: Layout of the output array image is incompatible with cv::Mat (step[ndims-1] != elemsize or step[1] != elemsize*nchannels)

In [29]:
cv2.findContours?

In [30]:
out_label.dtype


Out[30]:
dtype('int64')

In [31]:
out_label_np=np.array(out_label,np.uint8)

In [32]:
cv2.findContours(out_label_np, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)


Out[32]:
(array([[1, 1, 1, ..., 1, 1, 1],
        [1, 1, 1, ..., 1, 1, 1],
        [1, 1, 1, ..., 1, 1, 1],
        ..., 
        [1, 1, 1, ..., 1, 1, 1],
        [1, 1, 1, ..., 1, 1, 1],
        [1, 1, 1, ..., 1, 1, 1]], dtype=uint8), [array([[[  0,   0]],
  
         [[  0, 223]],
  
         [[199, 223]],
  
         [[199,   0]]], dtype=int32), array([[[ 91, 215]],
  
         [[ 92, 214]],
  
         [[ 93, 215]],
  
         [[ 92, 216]]], dtype=int32), array([[[ 90, 214]],
  
         [[ 91, 213]],
  
         [[ 92, 214]],
  
         [[ 91, 215]]], dtype=int32), array([[[ 80, 212]],
  
         [[ 82, 212]],
  
         [[ 83, 213]],
  
         [[ 83, 214]],
  
         [[ 81, 216]],
  
         [[ 78, 216]],
  
         [[ 77, 215]]], dtype=int32), array([[[ 98, 211]],
  
         [[ 99, 212]],
  
         [[ 99, 213]],
  
         [[ 98, 214]],
  
         [[ 97, 214]],
  
         [[ 96, 213]]], dtype=int32), array([[[ 98, 204]],
  
         [[ 99, 203]],
  
         [[101, 205]],
  
         [[101, 208]],
  
         [[100, 209]],
  
         [[ 99, 209]],
  
         [[ 98, 208]],
  
         [[ 99, 207]],
  
         [[ 98, 206]]], dtype=int32), array([[[141, 199]],
  
         [[142, 198]],
  
         [[143, 199]],
  
         [[143, 200]],
  
         [[142, 201]],
  
         [[141, 200]]], dtype=int32), array([[[129, 199]],
  
         [[130, 198]],
  
         [[131, 199]],
  
         [[131, 200]],
  
         [[130, 201]],
  
         [[129, 200]]], dtype=int32), array([[[141, 197]],
  
         [[142, 196]],
  
         [[143, 197]],
  
         [[142, 198]]], dtype=int32), array([[[139, 196]],
  
         [[141, 198]],
  
         [[141, 200]],
  
         [[140, 201]],
  
         [[139, 201]],
  
         [[138, 200]],
  
         [[139, 199]],
  
         [[138, 200]],
  
         [[137, 199]],
  
         [[137, 198]]], dtype=int32), array([[[ 71, 182]],
  
         [[ 72, 181]],
  
         [[ 73, 182]],
  
         [[ 72, 183]]], dtype=int32), array([[[ 95, 177]],
  
         [[ 96, 176]],
  
         [[ 97, 177]],
  
         [[ 96, 178]]], dtype=int32), array([[[118, 176]],
  
         [[119, 175]],
  
         [[120, 175]],
  
         [[121, 176]],
  
         [[121, 177]],
  
         [[125, 177]],
  
         [[126, 176]],
  
         [[131, 176]],
  
         [[132, 175]],
  
         [[133, 175]],
  
         [[134, 176]],
  
         [[133, 177]],
  
         [[134, 176]],
  
         [[135, 177]],
  
         [[136, 177]],
  
         [[137, 176]],
  
         [[138, 177]],
  
         [[141, 177]],
  
         [[143, 179]],
  
         [[143, 184]],
  
         [[144, 185]],
  
         [[144, 189]],
  
         [[143, 190]],
  
         [[143, 192]],
  
         [[144, 193]],
  
         [[144, 195]],
  
         [[143, 196]],
  
         [[142, 195]],
  
         [[140, 197]],
  
         [[139, 196]],
  
         [[138, 197]],
  
         [[136, 197]],
  
         [[135, 198]],
  
         [[138, 201]],
  
         [[137, 202]],
  
         [[137, 204]],
  
         [[136, 205]],
  
         [[134, 203]],
  
         [[133, 203]],
  
         [[132, 202]],
  
         [[132, 200]],
  
         [[131, 199]],
  
         [[132, 198]],
  
         [[132, 197]],
  
         [[131, 198]],
  
         [[130, 197]],
  
         [[130, 196]],
  
         [[129, 195]],
  
         [[130, 194]],
  
         [[129, 195]],
  
         [[129, 199]],
  
         [[128, 200]],
  
         [[127, 200]],
  
         [[126, 201]],
  
         [[125, 200]],
  
         [[124, 201]],
  
         [[122, 201]],
  
         [[121, 200]],
  
         [[123, 198]],
  
         [[122, 197]],
  
         [[123, 196]],
  
         [[122, 197]],
  
         [[121, 196]],
  
         [[121, 197]],
  
         [[122, 198]],
  
         [[122, 199]],
  
         [[121, 200]],
  
         [[122, 201]],
  
         [[121, 202]],
  
         [[118, 202]],
  
         [[116, 200]],
  
         [[116, 201]],
  
         [[115, 202]],
  
         [[114, 202]],
  
         [[113, 201]],
  
         [[111, 201]],
  
         [[112, 201]],
  
         [[113, 202]],
  
         [[112, 203]],
  
         [[107, 203]],
  
         [[106, 204]],
  
         [[105, 203]],
  
         [[104, 204]],
  
         [[100, 204]],
  
         [[ 98, 202]],
  
         [[ 98, 201]],
  
         [[ 97, 200]],
  
         [[ 97, 199]],
  
         [[ 98, 198]],
  
         [[ 97, 197]],
  
         [[ 97, 194]],
  
         [[ 96, 193]],
  
         [[ 96, 190]],
  
         [[ 97, 189]],
  
         [[ 96, 189]],
  
         [[ 95, 188]],
  
         [[ 96, 187]],
  
         [[ 96, 185]],
  
         [[ 95, 184]],
  
         [[ 95, 183]],
  
         [[ 94, 182]],
  
         [[ 96, 180]],
  
         [[ 97, 181]],
  
         [[ 98, 181]],
  
         [[100, 179]],
  
         [[101, 179]],
  
         [[102, 178]],
  
         [[103, 179]],
  
         [[102, 178]],
  
         [[103, 177]],
  
         [[104, 177]],
  
         [[105, 178]],
  
         [[109, 178]],
  
         [[110, 179]],
  
         [[111, 178]],
  
         [[112, 178]],
  
         [[114, 180]],
  
         [[116, 180]],
  
         [[115, 179]],
  
         [[115, 178]],
  
         [[116, 177]],
  
         [[117, 177]],
  
         [[118, 176]],
  
         [[119, 177]]], dtype=int32), array([[[135, 201]]], dtype=int32), array([[[134, 195]],
  
         [[135, 195]]], dtype=int32), array([[[122, 194]]], dtype=int32), array([[[127, 193]],
  
         [[127, 194]],
  
         [[126, 195]],
  
         [[127, 196]],
  
         [[125, 198]],
  
         [[126, 197]],
  
         [[127, 197]],
  
         [[127, 196]],
  
         [[126, 195]],
  
         [[127, 194]]], dtype=int32), array([[[140, 192]]], dtype=int32), array([[[129, 192]]], dtype=int32), array([[[104, 192]]], dtype=int32), array([[[125, 191]],
  
         [[124, 192]],
  
         [[125, 191]],
  
         [[126, 191]]], dtype=int32), array([[[137, 190]],
  
         [[140, 190]]], dtype=int32), array([[[119, 190]],
  
         [[119, 191]],
  
         [[120, 192]],
  
         [[121, 191]],
  
         [[121, 190]]], dtype=int32), array([[[133, 189]],
  
         [[132, 190]],
  
         [[133, 189]],
  
         [[138, 194]],
  
         [[134, 190]],
  
         [[134, 189]]], dtype=int32), array([[[140, 188]]], dtype=int32), array([[[113, 188]],
  
         [[113, 190]],
  
         [[114, 191]],
  
         [[114, 196]],
  
         [[113, 197]],
  
         [[112, 197]],
  
         [[111, 196]],
  
         [[111, 193]],
  
         [[110, 192]],
  
         [[111, 191]],
  
         [[110, 190]],
  
         [[110, 189]],
  
         [[107, 189]],
  
         [[106, 190]],
  
         [[106, 191]],
  
         [[108, 191]],
  
         [[109, 192]],
  
         [[109, 193]],
  
         [[108, 194]],
  
         [[107, 194]],
  
         [[107, 198]],
  
         [[106, 199]],
  
         [[105, 199]],
  
         [[105, 200]],
  
         [[108, 197]],
  
         [[109, 197]],
  
         [[110, 196]],
  
         [[112, 198]],
  
         [[113, 198]],
  
         [[114, 197]],
  
         [[116, 197]],
  
         [[118, 195]],
  
         [[117, 194]],
  
         [[118, 193]],
  
         [[116, 191]],
  
         [[116, 189]],
  
         [[115, 188]]], dtype=int32), array([[[136, 187]]], dtype=int32), array([[[104, 187]]], dtype=int32), array([[[127, 185]]], dtype=int32), array([[[117, 185]]], dtype=int32), array([[[114, 185]]], dtype=int32), array([[[110, 185]]], dtype=int32), array([[[119, 183]],
  
         [[120, 184]],
  
         [[119, 185]],
  
         [[120, 186]],
  
         [[121, 185]],
  
         [[122, 186]],
  
         [[123, 186]],
  
         [[124, 187]],
  
         [[125, 186]],
  
         [[124, 185]],
  
         [[123, 186]],
  
         [[122, 186]]], dtype=int32), array([[[123, 186]],
  
         [[124, 185]],
  
         [[125, 186]],
  
         [[124, 187]]], dtype=int32), array([[[114, 183]]], dtype=int32), array([[[125, 182]]], dtype=int32), array([[[139, 181]]], dtype=int32), array([[[128, 180]],
  
         [[127, 181]]], dtype=int32), array([[[ 96, 176]],
  
         [[ 97, 175]],
  
         [[ 98, 176]],
  
         [[ 97, 177]]], dtype=int32), array([[[ 94, 176]],
  
         [[ 95, 175]],
  
         [[ 96, 176]],
  
         [[ 95, 177]]], dtype=int32), array([[[ 91, 176]],
  
         [[ 92, 175]],
  
         [[ 93, 176]],
  
         [[ 92, 177]]], dtype=int32), array([[[146, 175]],
  
         [[147, 174]],
  
         [[150, 174]],
  
         [[151, 175]],
  
         [[152, 174]],
  
         [[153, 175]],
  
         [[153, 176]],
  
         [[152, 177]],
  
         [[148, 177]],
  
         [[147, 178]],
  
         [[146, 178]],
  
         [[144, 176]],
  
         [[145, 175]]], dtype=int32), array([[[103, 175]],
  
         [[104, 174]],
  
         [[106, 174]],
  
         [[107, 175]],
  
         [[105, 177]],
  
         [[104, 177]],
  
         [[103, 176]]], dtype=int32), array([[[ 95, 173]],
  
         [[ 96, 172]],
  
         [[ 98, 174]],
  
         [[ 96, 176]],
  
         [[ 95, 175]]], dtype=int32), array([[[ 90, 173]],
  
         [[ 91, 172]],
  
         [[ 93, 172]],
  
         [[ 94, 173]],
  
         [[ 94, 174]],
  
         [[ 95, 175]],
  
         [[ 94, 176]],
  
         [[ 93, 176]],
  
         [[ 92, 175]],
  
         [[ 92, 174]],
  
         [[ 92, 175]],
  
         [[ 90, 177]],
  
         [[ 89, 176]],
  
         [[ 90, 177]],
  
         [[ 89, 178]],
  
         [[ 84, 178]],
  
         [[ 83, 179]],
  
         [[ 81, 179]],
  
         [[ 81, 180]],
  
         [[ 80, 181]],
  
         [[ 77, 181]],
  
         [[ 76, 180]],
  
         [[ 76, 178]],
  
         [[ 75, 177]],
  
         [[ 77, 175]],
  
         [[ 78, 175]],
  
         [[ 79, 176]],
  
         [[ 82, 173]]], dtype=int32), array([[[ 85, 176]]], dtype=int32), array([[[108, 170]],
  
         [[109, 171]],
  
         [[109, 173]],
  
         [[107, 175]],
  
         [[105, 173]]], dtype=int32), array([[[132, 170]],
  
         [[133, 169]],
  
         [[134, 169]],
  
         [[135, 170]],
  
         [[134, 171]],
  
         [[133, 171]]], dtype=int32), array([[[142, 166]],
  
         [[143, 165]],
  
         [[147, 165]],
  
         [[150, 168]],
  
         [[148, 170]],
  
         [[147, 170]],
  
         [[146, 171]],
  
         [[143, 171]],
  
         [[142, 172]],
  
         [[137, 172]],
  
         [[136, 171]],
  
         [[136, 170]],
  
         [[135, 169]],
  
         [[138, 166]]], dtype=int32), array([[[ 78, 163]],
  
         [[ 79, 162]],
  
         [[ 80, 163]],
  
         [[ 79, 164]]], dtype=int32), array([[[ 77, 159]],
  
         [[ 78, 158]],
  
         [[ 79, 159]],
  
         [[ 79, 162]],
  
         [[ 78, 163]],
  
         [[ 76, 163]],
  
         [[ 75, 162]],
  
         [[ 75, 160]],
  
         [[ 76, 159]],
  
         [[ 77, 160]]], dtype=int32), array([[[ 89, 152]],
  
         [[ 90, 151]],
  
         [[ 91, 152]],
  
         [[ 90, 153]]], dtype=int32), array([[[ 83, 148]],
  
         [[ 84, 147]],
  
         [[ 85, 148]],
  
         [[ 89, 148]],
  
         [[ 90, 149]],
  
         [[ 90, 150]],
  
         [[ 89, 151]],
  
         [[ 88, 151]],
  
         [[ 88, 152]],
  
         [[ 89, 153]],
  
         [[ 88, 154]],
  
         [[ 85, 154]],
  
         [[ 84, 155]],
  
         [[ 82, 155]],
  
         [[ 82, 156]],
  
         [[ 83, 156]],
  
         [[ 84, 155]],
  
         [[ 90, 155]],
  
         [[ 91, 156]],
  
         [[ 92, 155]],
  
         [[ 93, 156]],
  
         [[ 94, 156]],
  
         [[ 95, 157]],
  
         [[ 95, 159]],
  
         [[ 91, 163]],
  
         [[ 90, 162]],
  
         [[ 89, 163]],
  
         [[ 86, 163]],
  
         [[ 85, 164]],
  
         [[ 89, 164]],
  
         [[ 90, 165]],
  
         [[ 91, 164]],
  
         [[ 92, 165]],
  
         [[ 93, 165]],
  
         [[ 94, 166]],
  
         [[ 93, 167]],
  
         [[ 94, 168]],
  
         [[ 90, 172]],
  
         [[ 89, 172]],
  
         [[ 88, 171]],
  
         [[ 85, 171]],
  
         [[ 84, 172]],
  
         [[ 81, 172]],
  
         [[ 80, 173]],
  
         [[ 78, 173]],
  
         [[ 77, 174]],
  
         [[ 74, 174]],
  
         [[ 73, 173]],
  
         [[ 73, 172]],
  
         [[ 73, 173]],
  
         [[ 74, 174]],
  
         [[ 72, 176]],
  
         [[ 70, 174]],
  
         [[ 70, 171]],
  
         [[ 69, 170]],
  
         [[ 69, 169]],
  
         [[ 70, 168]],
  
         [[ 73, 168]],
  
         [[ 73, 167]],
  
         [[ 71, 167]],
  
         [[ 70, 166]],
  
         [[ 70, 165]],
  
         [[ 69, 164]],
  
         [[ 69, 162]],
  
         [[ 71, 160]],
  
         [[ 73, 160]],
  
         [[ 74, 161]],
  
         [[ 74, 162]],
  
         [[ 75, 162]],
  
         [[ 77, 164]],
  
         [[ 76, 165]],
  
         [[ 76, 166]],
  
         [[ 75, 167]],
  
         [[ 76, 167]],
  
         [[ 77, 166]],
  
         [[ 78, 166]],
  
         [[ 79, 165]],
  
         [[ 82, 165]],
  
         [[ 83, 164]],
  
         [[ 81, 164]],
  
         [[ 80, 163]],
  
         [[ 80, 162]],
  
         [[ 79, 161]],
  
         [[ 79, 159]],
  
         [[ 78, 158]],
  
         [[ 78, 157]],
  
         [[ 79, 156]],
  
         [[ 80, 156]],
  
         [[ 80, 155]],
  
         [[ 79, 156]],
  
         [[ 76, 156]],
  
         [[ 75, 157]],
  
         [[ 73, 157]],
  
         [[ 70, 160]],
  
         [[ 68, 160]],
  
         [[ 67, 159]],
  
         [[ 67, 161]],
  
         [[ 68, 162]],
  
         [[ 68, 166]],
  
         [[ 69, 167]],
  
         [[ 69, 172]],
  
         [[ 70, 173]],
  
         [[ 70, 174]],
  
         [[ 69, 175]],
  
         [[ 69, 177]],
  
         [[ 66, 180]],
  
         [[ 65, 180]],
  
         [[ 64, 179]],
  
         [[ 65, 178]],
  
         [[ 64, 179]],
  
         [[ 63, 178]],
  
         [[ 63, 177]],
  
         [[ 64, 176]],
  
         [[ 65, 176]],
  
         [[ 65, 175]],
  
         [[ 66, 174]],
  
         [[ 64, 172]],
  
         [[ 65, 171]],
  
         [[ 64, 172]],
  
         [[ 63, 172]],
  
         [[ 60, 169]],
  
         [[ 61, 168]],
  
         [[ 63, 168]],
  
         [[ 64, 169]],
  
         [[ 63, 168]],
  
         [[ 62, 168]],
  
         [[ 61, 167]],
  
         [[ 61, 166]],
  
         [[ 59, 164]],
  
         [[ 59, 160]],
  
         [[ 58, 159]],
  
         [[ 58, 158]],
  
         [[ 59, 157]],
  
         [[ 60, 157]],
  
         [[ 59, 157]],
  
         [[ 58, 156]],
  
         [[ 58, 155]],
  
         [[ 59, 154]],
  
         [[ 60, 155]],
  
         [[ 61, 155]],
  
         [[ 61, 154]],
  
         [[ 62, 153]],
  
         [[ 64, 153]],
  
         [[ 65, 154]],
  
         [[ 65, 155]],
  
         [[ 66, 156]],
  
         [[ 66, 157]],
  
         [[ 66, 154]],
  
         [[ 67, 153]],
  
         [[ 68, 153]],
  
         [[ 70, 151]],
  
         [[ 72, 151]],
  
         [[ 73, 150]],
  
         [[ 75, 150]],
  
         [[ 76, 149]],
  
         [[ 79, 149]],
  
         [[ 80, 148]]], dtype=int32), array([[[ 89, 167]],
  
         [[ 90, 167]],
  
         [[ 91, 168]],
  
         [[ 90, 167]]], dtype=int32), array([[[ 63, 163]],
  
         [[ 63, 165]],
  
         [[ 64, 165]],
  
         [[ 63, 164]]], dtype=int32), array([[[ 84, 151]]], dtype=int32), array([[[ 99, 131]],
  
         [[100, 132]],
  
         [[100, 133]],
  
         [[ 99, 134]],
  
         [[ 98, 134]],
  
         [[ 97, 133]]], dtype=int32), array([[[ 96, 132]],
  
         [[ 97, 131]],
  
         [[ 98, 132]],
  
         [[ 97, 133]]], dtype=int32), array([[[ 75, 104]],
  
         [[ 78, 104]],
  
         [[ 80, 106]],
  
         [[ 83, 106]],
  
         [[ 84, 107]],
  
         [[ 85, 107]],
  
         [[ 86, 108]],
  
         [[ 85, 109]],
  
         [[ 85, 110]],
  
         [[ 82, 113]],
  
         [[ 79, 113]],
  
         [[ 78, 114]],
  
         [[ 74, 114]],
  
         [[ 73, 115]],
  
         [[ 71, 115]],
  
         [[ 70, 114]],
  
         [[ 68, 114]],
  
         [[ 67, 113]],
  
         [[ 60, 113]],
  
         [[ 58, 111]],
  
         [[ 58, 107]],
  
         [[ 60, 105]],
  
         [[ 72, 105]],
  
         [[ 73, 106]],
  
         [[ 72, 107]],
  
         [[ 74, 107]],
  
         [[ 76, 109]],
  
         [[ 77, 108]],
  
         [[ 76, 108]],
  
         [[ 75, 107]],
  
         [[ 74, 107]],
  
         [[ 73, 106]]], dtype=int32), array([[[ 80, 108]],
  
         [[ 79, 109]],
  
         [[ 79, 110]],
  
         [[ 80, 110]]], dtype=int32), array([[[102, 100]],
  
         [[103, 101]],
  
         [[104, 101]],
  
         [[105, 100]],
  
         [[106, 101]],
  
         [[107, 101]],
  
         [[108, 102]],
  
         [[108, 103]],
  
         [[109, 104]],
  
         [[109, 105]],
  
         [[108, 106]],
  
         [[107, 106]],
  
         [[107, 107]],
  
         [[106, 108]],
  
         [[105, 108]],
  
         [[107, 108]],
  
         [[108, 107]],
  
         [[109, 108]],
  
         [[111, 108]],
  
         [[113, 110]],
  
         [[113, 111]],
  
         [[110, 114]],
  
         [[110, 115]],
  
         [[109, 116]],
  
         [[108, 116]],
  
         [[107, 115]],
  
         [[106, 115]],
  
         [[106, 116]],
  
         [[105, 117]],
  
         [[103, 117]],
  
         [[101, 119]],
  
         [[ 98, 119]],
  
         [[ 98, 120]],
  
         [[ 99, 121]],
  
         [[ 97, 123]],
  
         [[ 96, 122]],
  
         [[ 95, 122]],
  
         [[ 94, 121]],
  
         [[ 95, 120]],
  
         [[ 94, 120]],
  
         [[ 92, 118]],
  
         [[ 92, 116]],
  
         [[ 93, 115]],
  
         [[ 94, 115]],
  
         [[ 96, 117]],
  
         [[ 94, 115]],
  
         [[ 94, 113]],
  
         [[ 93, 114]],
  
         [[ 90, 111]],
  
         [[ 90, 109]],
  
         [[ 89, 108]],
  
         [[ 91, 106]],
  
         [[ 92, 106]],
  
         [[ 91, 105]],
  
         [[ 92, 104]],
  
         [[ 94, 104]],
  
         [[ 95, 103]],
  
         [[ 96, 103]],
  
         [[ 97, 102]],
  
         [[ 98, 102]],
  
         [[ 99, 101]],
  
         [[100, 102]]], dtype=int32), array([[[102, 114]]], dtype=int32), array([[[105, 113]]], dtype=int32), array([[[100, 109]],
  
         [[ 98, 111]],
  
         [[ 96, 111]],
  
         [[ 96, 112]],
  
         [[ 97, 111]],
  
         [[ 99, 111]],
  
         [[100, 110]]], dtype=int32), array([[[102, 108]],
  
         [[102, 109]],
  
         [[103, 110]],
  
         [[103, 109]]], dtype=int32), array([[[ 93, 108]]], dtype=int32), array([[[ 97, 101]],
  
         [[ 98, 100]],
  
         [[ 99, 101]],
  
         [[ 98, 102]]], dtype=int32), array([[[ 78, 101]],
  
         [[ 79, 100]],
  
         [[ 80, 101]],
  
         [[ 79, 102]]], dtype=int32), array([[[ 70, 101]],
  
         [[ 71, 100]],
  
         [[ 76, 100]],
  
         [[ 77, 101]],
  
         [[ 77, 102]],
  
         [[ 76, 103]],
  
         [[ 74, 103]],
  
         [[ 73, 104]],
  
         [[ 70, 104]],
  
         [[ 68, 102]],
  
         [[ 69, 101]]], dtype=int32), array([[[ 97,  99]],
  
         [[ 98,  98]],
  
         [[100,  98]],
  
         [[101,  99]],
  
         [[101, 100]],
  
         [[100, 101]],
  
         [[ 99, 101]]], dtype=int32), array([[[113,  97]],
  
         [[114,  98]],
  
         [[114,  99]],
  
         [[113, 100]],
  
         [[112, 100]],
  
         [[111,  99]]], dtype=int32), array([[[116,  97]],
  
         [[117,  96]],
  
         [[118,  97]],
  
         [[118,  98]],
  
         [[117,  99]],
  
         [[116,  98]]], dtype=int32), array([[[105,  97]],
  
         [[106,  96]],
  
         [[107,  97]],
  
         [[106,  98]]], dtype=int32), array([[[ 91,  96]],
  
         [[ 92,  96]],
  
         [[ 93,  97]],
  
         [[ 93,  98]],
  
         [[ 91, 100]],
  
         [[ 92, 101]],
  
         [[ 93, 101]],
  
         [[ 93,  99]],
  
         [[ 94,  98]],
  
         [[ 95,  98]],
  
         [[ 96,  99]],
  
         [[ 96, 100]],
  
         [[ 97, 101]],
  
         [[ 95, 103]],
  
         [[ 89, 103]],
  
         [[ 87, 101]],
  
         [[ 87, 100]]], dtype=int32), array([[[118,  96]],
  
         [[119,  95]],
  
         [[120,  96]],
  
         [[119,  97]]], dtype=int32), array([[[109,  96]],
  
         [[110,  95]],
  
         [[111,  96]],
  
         [[110,  97]]], dtype=int32), array([[[92, 96]],
  
         [[93, 95]],
  
         [[94, 96]],
  
         [[93, 97]]], dtype=int32), array([[[117,  95]],
  
         [[118,  94]],
  
         [[119,  95]],
  
         [[118,  96]]], dtype=int32), array([[[103,  95]],
  
         [[104,  94]],
  
         [[105,  94]],
  
         [[106,  95]],
  
         [[106,  96]],
  
         [[105,  97]],
  
         [[104,  97]],
  
         [[103,  96]]], dtype=int32), array([[[71, 95]],
  
         [[72, 94]],
  
         [[73, 95]],
  
         [[72, 96]]], dtype=int32), array([[[ 79,  94]],
  
         [[ 80,  93]],
  
         [[ 81,  93]],
  
         [[ 83,  95]],
  
         [[ 83,  98]],
  
         [[ 84,  99]],
  
         [[ 84, 102]],
  
         [[ 83, 103]],
  
         [[ 80, 103]],
  
         [[ 79, 102]],
  
         [[ 80, 101]],
  
         [[ 80,  98]],
  
         [[ 79,  97]]], dtype=int32), array([[[103,  93]],
  
         [[104,  92]],
  
         [[105,  93]],
  
         [[104,  94]]], dtype=int32), array([[[82, 93]],
  
         [[83, 92]],
  
         [[84, 93]],
  
         [[83, 94]]], dtype=int32), array([[[119,  92]],
  
         [[120,  91]],
  
         [[121,  92]],
  
         [[120,  93]]], dtype=int32), array([[[107,  92]],
  
         [[108,  91]],
  
         [[109,  92]],
  
         [[110,  92]],
  
         [[111,  93]],
  
         [[110,  94]],
  
         [[110,  95]],
  
         [[109,  96]],
  
         [[108,  95]],
  
         [[108,  94]],
  
         [[107,  93]]], dtype=int32), array([[[83, 92]],
  
         [[84, 91]],
  
         [[85, 92]],
  
         [[84, 93]]], dtype=int32), array([[[108,  88]],
  
         [[110,  90]],
  
         [[110,  91]],
  
         [[109,  92]],
  
         [[108,  91]],
  
         [[107,  91]],
  
         [[106,  90]]], dtype=int32), array([[[82, 73]],
  
         [[83, 72]],
  
         [[87, 72]],
  
         [[88, 73]],
  
         [[88, 75]],
  
         [[87, 76]],
  
         [[83, 76]],
  
         [[82, 75]]], dtype=int32), array([[[ 64,  73]],
  
         [[ 65,  72]],
  
         [[ 66,  73]],
  
         [[ 66,  74]],
  
         [[ 67,  74]],
  
         [[ 68,  75]],
  
         [[ 68,  77]],
  
         [[ 69,  77]],
  
         [[ 71,  79]],
  
         [[ 71,  80]],
  
         [[ 72,  81]],
  
         [[ 72,  79]],
  
         [[ 74,  77]],
  
         [[ 75,  77]],
  
         [[ 73,  75]],
  
         [[ 75,  73]],
  
         [[ 76,  73]],
  
         [[ 78,  75]],
  
         [[ 78,  76]],
  
         [[ 79,  76]],
  
         [[ 80,  77]],
  
         [[ 80,  78]],
  
         [[ 83,  81]],
  
         [[ 83,  83]],
  
         [[ 84,  84]],
  
         [[ 84,  87]],
  
         [[ 83,  88]],
  
         [[ 84,  89]],
  
         [[ 83,  90]],
  
         [[ 80,  90]],
  
         [[ 79,  89]],
  
         [[ 78,  90]],
  
         [[ 75,  90]],
  
         [[ 74,  91]],
  
         [[ 75,  91]],
  
         [[ 76,  92]],
  
         [[ 77,  92]],
  
         [[ 78,  93]],
  
         [[ 78,  96]],
  
         [[ 79,  97]],
  
         [[ 79, 100]],
  
         [[ 78, 101]],
  
         [[ 77, 101]],
  
         [[ 75,  99]],
  
         [[ 74, 100]],
  
         [[ 73, 100]],
  
         [[ 72,  99]],
  
         [[ 72,  98]],
  
         [[ 71,  97]],
  
         [[ 73,  95]],
  
         [[ 74,  95]],
  
         [[ 74,  94]],
  
         [[ 73,  95]],
  
         [[ 72,  94]],
  
         [[ 72,  92]],
  
         [[ 71,  91]],
  
         [[ 64,  91]],
  
         [[ 67,  94]],
  
         [[ 67,  95]],
  
         [[ 68,  96]],
  
         [[ 68,  99]],
  
         [[ 69, 100]],
  
         [[ 69, 101]],
  
         [[ 68, 102]],
  
         [[ 67, 102]],
  
         [[ 66, 101]],
  
         [[ 65, 101]],
  
         [[ 64, 102]],
  
         [[ 62, 102]],
  
         [[ 61, 103]],
  
         [[ 59, 103]],
  
         [[ 57, 101]],
  
         [[ 57,  98]],
  
         [[ 56,  97]],
  
         [[ 56,  94]],
  
         [[ 57,  93]],
  
         [[ 58,  93]],
  
         [[ 55,  93]],
  
         [[ 54,  92]],
  
         [[ 54,  91]],
  
         [[ 53,  90]],
  
         [[ 53,  88]],
  
         [[ 52,  87]],
  
         [[ 52,  84]],
  
         [[ 51,  83]],
  
         [[ 51,  82]],
  
         [[ 52,  81]],
  
         [[ 52,  79]],
  
         [[ 53,  78]],
  
         [[ 53,  77]],
  
         [[ 54,  76]],
  
         [[ 55,  76]],
  
         [[ 57,  78]],
  
         [[ 58,  78]],
  
         [[ 59,  79]],
  
         [[ 59,  80]],
  
         [[ 60,  80]],
  
         [[ 61,  81]],
  
         [[ 61,  83]],
  
         [[ 61,  80]],
  
         [[ 62,  79]],
  
         [[ 63,  79]],
  
         [[ 64,  78]],
  
         [[ 64,  77]],
  
         [[ 63,  76]],
  
         [[ 63,  75]],
  
         [[ 64,  74]]], dtype=int32), array([[[56, 86]],
  
         [[56, 87]],
  
         [[57, 87]],
  
         [[57, 86]]], dtype=int32), array([[[62, 85]],
  
         [[62, 86]]], dtype=int32), array([[[56, 83]],
  
         [[56, 84]]], dtype=int32), array([[[ 93,  72]],
  
         [[ 94,  71]],
  
         [[100,  71]],
  
         [[101,  72]],
  
         [[105,  72]],
  
         [[107,  74]],
  
         [[107,  77]],
  
         [[106,  78]],
  
         [[104,  78]],
  
         [[103,  77]],
  
         [[102,  78]],
  
         [[100,  78]],
  
         [[ 99,  79]],
  
         [[ 96,  79]],
  
         [[ 95,  80]],
  
         [[ 94,  80]],
  
         [[ 92,  78]],
  
         [[ 93,  77]],
  
         [[ 93,  76]],
  
         [[ 92,  75]],
  
         [[ 92,  74]],
  
         [[ 91,  73]],
  
         [[ 92,  72]]], dtype=int32), array([[[79, 62]],
  
         [[80, 61]],
  
         [[81, 61]],
  
         [[82, 62]],
  
         [[85, 62]],
  
         [[86, 63]],
  
         [[86, 68]],
  
         [[85, 69]],
  
         [[80, 69]],
  
         [[79, 68]]], dtype=int32)], array([[[-1, -1,  1, -1],
         [ 2, -1, -1,  0],
         [ 3,  1, -1,  0],
         [ 4,  2, -1,  0],
         [ 5,  3, -1,  0],
         [ 6,  4, -1,  0],
         [ 7,  5, -1,  0],
         [ 8,  6, -1,  0],
         [ 9,  7, -1,  0],
         [10,  8, -1,  0],
         [11,  9, -1,  0],
         [12, 10, -1,  0],
         [38, 11, 13,  0],
         [14, -1, -1, 12],
         [15, 13, -1, 12],
         [16, 14, -1, 12],
         [17, 15, -1, 12],
         [18, 16, -1, 12],
         [19, 17, -1, 12],
         [20, 18, -1, 12],
         [21, 19, -1, 12],
         [22, 20, -1, 12],
         [23, 21, -1, 12],
         [24, 22, -1, 12],
         [25, 23, -1, 12],
         [26, 24, -1, 12],
         [27, 25, -1, 12],
         [28, 26, -1, 12],
         [29, 27, -1, 12],
         [30, 28, -1, 12],
         [31, 29, -1, 12],
         [32, 30, -1, 12],
         [34, 31, 33, 12],
         [-1, -1, -1, 32],
         [35, 32, -1, 12],
         [36, 34, -1, 12],
         [37, 35, -1, 12],
         [-1, 36, -1, 12],
         [39, 12, -1,  0],
         [40, 38, -1,  0],
         [41, 39, -1,  0],
         [42, 40, -1,  0],
         [43, 41, -1,  0],
         [44, 42, -1,  0],
         [46, 43, 45,  0],
         [-1, -1, -1, 44],
         [47, 44, -1,  0],
         [48, 46, -1,  0],
         [49, 47, -1,  0],
         [50, 48, -1,  0],
         [51, 49, -1,  0],
         [52, 50, -1,  0],
         [56, 51, 53,  0],
         [54, -1, -1, 52],
         [55, 53, -1, 52],
         [-1, 54, -1, 52],
         [57, 52, -1,  0],
         [58, 56, -1,  0],
         [60, 57, 59,  0],
         [-1, -1, -1, 58],
         [66, 58, 61,  0],
         [62, -1, -1, 60],
         [63, 61, -1, 60],
         [64, 62, -1, 60],
         [65, 63, -1, 60],
         [-1, 64, -1, 60],
         [67, 60, -1,  0],
         [68, 66, -1,  0],
         [69, 67, -1,  0],
         [70, 68, -1,  0],
         [71, 69, -1,  0],
         [72, 70, -1,  0],
         [73, 71, -1,  0],
         [74, 72, -1,  0],
         [75, 73, -1,  0],
         [76, 74, -1,  0],
         [77, 75, -1,  0],
         [78, 76, -1,  0],
         [79, 77, -1,  0],
         [80, 78, -1,  0],
         [81, 79, -1,  0],
         [82, 80, -1,  0],
         [83, 81, -1,  0],
         [84, 82, -1,  0],
         [85, 83, -1,  0],
         [86, 84, -1,  0],
         [87, 85, -1,  0],
         [88, 86, -1,  0],
         [92, 87, 89,  0],
         [90, -1, -1, 88],
         [91, 89, -1, 88],
         [-1, 90, -1, 88],
         [93, 88, -1,  0],
         [-1, 92, -1,  0]]], dtype=int32))

In [ ]:


In [30]:
create_pairwise_bilateral?

In [51]:
import random

In [55]:
for i in xrange(100):
    unary=np.copy(total_unary)
    n_label = unary.shape[0]
    im_height = unary.shape[1]
    im_width = unary.shape[2]
    print n_label,im_height,im_width
    d = dcrf.DenseCRF2D(im_height, im_width, n_label)
    U = unary.reshape((n_label,-1))
    Up = (U+0.001) / (np.sum(U, axis=0))
    print np.max(Up),np.min(Up),Up.shape
    # tt=-np.log(Up+0.0000001)
    # print np.max(tt),np.min(tt)
    unary = softmax_to_unary(Up)
    d.setUnaryEnergy(unary)
    #d.addPairwiseGaussian(3, 1)
    from pydensecrf.utils import unary_from_softmax, create_pairwise_bilateral
    sdims_=random.randint(0,100)
    schan_=random.randint(0,20)
    compat_=random.randint(0,10)
    pairwise_energy = create_pairwise_bilateral(sdims=(40,40), schan=(10,), img=test1_im.reshape((500,500,1)), chdim=2)
    d.addPairwiseEnergy(pairwise_energy,compat=8)
    epoch_=random.randint(0,50)
    Q = d.inference(10)
    Q = np.array(Q).reshape((n_label, im_height,im_width))
    out_label = np.argmax(Q, axis=0)
    Q.shape
    out_label.shape
    out_label_out=out_label[:200,:200]
    ss=" "+str(sdims_)+" "+str(schan_)+" "+str(compat_)+" "+str(epoch_)
    plt.figure()
    plt.suptitle(ss)
    plt.imshow(1-out_label_out,cmap=plt.get_cmap('gray'))
    #plt.figure()
    #plt.imshow(test1_hm,cmap=plt.get_cmap('gray'))
    print np.min(out_label),np.max(out_label),out_label.dtype


WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
WARNING:root:pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.
0 1 int64
2 500 500
1.001 0.0010004 (2, 250000)
0 1 int64

In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [18]:
plt.imshow()


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-18-a2a9f549780d> in <module>()
----> 1 plt.imshow()

TypeError: imshow() takes at least 1 argument (0 given)

In [ ]:


In [ ]:


In [ ]:


In [ ]:
print np.min(unary),np.max(unary),unary.shape

In [ ]:
d2 = dcrf.DenseCRF2D(500, 500,1)

In [ ]:
#create_pairwise_bilateral?

In [ ]:
#pairwise_energy = create_pairwise_bilateral(sdims=(10,10), schan=(0.01,), img=test1_im.reshape((500,500,1)), chdim=2)

In [ ]:
unary = unary_from_softmax(unary)
print np.min(unary),np.max(unary),unary.shape
#unary = np.ascontiguousarray(unary)
d2.setUnaryEnergy(unary)

In [ ]:
d2.addPairwiseGaussian(sxy=3, compat=3)
#d2.addPairwiseEnergy(pairwise_energy,compat=10)

In [ ]:
Q=d2.inference(5)

In [ ]:
proba=np.array(Q)

In [ ]:
plt.imshow(proba.reshape(500,500))

In [ ]:
np.max(proba)

In [ ]:
np.min(proba)

In [ ]:
res = np.argmax(Q, axis=0).reshape((500,500))

In [ ]:
plt.imshow(res)

In [ ]:
print np.min(res),np.max(res)

In [ ]:
Q

In [ ]: