pv-vision
pv-vision copied to clipboard
extract_crack_features.ipynb tutorial is not working
I am playing with the repo, I managed to run some tutorials locally but was not able to run extract_crack_features.ipynb, it gives an error at inactive_area, inactive_prop = crackcell.extract_inactive_area()
Full stack trace is
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
[/var/folders/fs/xvl6y9652qgb_t8nfv9bxfvh0000gn/T/ipykernel_21232/2558548168.py](https://file+.vscode-resource.vscode-cdn.net/var/folders/fs/xvl6y9652qgb_t8nfv9bxfvh0000gn/T/ipykernel_21232/2558548168.py) in <module>
1 # extract inactive area
----> 2 inactive_area, inactive_prop = crackcell.extract_inactive_area()
3 plt.imshow(inactive_area, "gray")
4 print("{}%".format(inactive_prop*100))
[/usr/local/lib/python3.9/site-packages/pv_vision/crack_analysis/crackcell.py](https://file+.vscode-resource.vscode-cdn.net/usr/local/lib/python3.9/site-packages/pv_vision/crack_analysis/crackcell.py) in extract_inactive_area(self)
67 def extract_inactive_area(self):
68 """Extract inactive area"""
---> 69 self.inactive_area, self.features["inactive_prop"] = isolate.detect_inactive(self.crack, self.busbar)
70 return self.inactive_area, self.features["inactive_prop"]
71
[/usr/local/lib/python3.9/site-packages/pv_vision/crack_analysis/_feature_extraction.py](https://file+.vscode-resource.vscode-cdn.net/usr/local/lib/python3.9/site-packages/pv_vision/crack_analysis/_feature_extraction.py) in detect_inactive(mask_crack, mask_busbar, extend_kernel)
223 ske_crack = skeleton_crack(mask_crack)
224 ske_busbar = extend_busbar(mask_busbar, kernel_size=extend_kernel)
--> 225 pos_busbar = locate_busbar(ske_busbar)
226 ske_cell = skeleton_cell(ske_crack, pos_busbar)
227 cell_diff = diffuse(ske_cell, pos_busbar)
[/usr/local/lib/python3.9/site-packages/pv_vision/crack_analysis/_feature_extraction.py](https://file+.vscode-resource.vscode-cdn.net/usr/local/lib/python3.9/site-packages/pv_vision/crack_analysis/_feature_extraction.py) in locate_busbar(ske_busbar)
63 numlist_busbar.append(len(np.argwhere(ske_busbar[:, i] == 1)))
64
---> 65 num_busbar = stats.mode(numlist_busbar).mode[0]
66
67 pos_busbar = np.zeros((num_busbar, 1))
IndexError: invalid index to scalar variable.
I ran the tutorial as is but no luck so far.
P.S.I tried on 2 different laptops (macOS intel and M2) and multiple Python versions.
Hello! Could you please share the cell image and annotation image you used for this tutorial? If you used my example images, there shouldn't be problems. Thanks!
I used the code as is (with your sample images)
img_path='../examples/crack_segmentation/img_for_crack_analysis/sample_raw.jpg', ann_path='../examples/crack_segmentation/img_for_crack_analysis/sample_ann.png',
Once I ran below section
inactive_area, inactive_prop = crackcell.extract_inactive_area()
plt.imshow(inactive_area, "gray")
print("{}%".format(inactive_prop*100))
I am getting errors as mentioned in the previous message.
fixed! Thank you for the comment