提取建築-iObjects Python with JupyterHub for K8s
import os
import time
from iobjectspy import open_datasource
from iobjectspy.ai.recognition import extract_region
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-a1944dbfe13b> in <module>()
3
4 from iobjectspy import open_datasource
----> 5 from iobjectspy.ai.recognition import extract_region
/opt/conda/lib/python3.6/site-packages/iobjectspy/ai/recognition.pyc in <module>()
ModuleNotFoundError: No module named 'rasterio'
data_dir = ''
out_dir = os.path.join(data_dir, 'out/')
model_path = os.path.join(curr_dir, 'model')
if not os.path.exists(out_dir):
os.makedirs(out_dir)
def extract_building_file_dom():
"""
基於DOM影像文件進行建築物提取,結果面數據集保存在UDB數據源下
"""
print('使用CPU進行提取約需10分鐘,使用GPU提取約需1分鐘')
dom_path = os.path.join(data_dir, 'dom.tif')
start_time = time.time()
extract_region(dom_path, model_path, model_name='building_extract_with_dom',
output=os.path.join(out_dir, 'out_building.udb'), out_dataset_name='file_dom')
end_time = time.time()
print('提取完成,共耗時{}s,結果數據保存在 {} 數據源下 file_dom 數據集中'.format(
end_time - start_time, out_dir + 'out_building.udb'))
if __name__ == '__main__':
# 基於DOM影像文件進行建築物提取
extract_building_file_dom()
exit()