提取建筑-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()