108_scene_classification_infer_lcz

原创
2020/03/19 23:16
阅读数 114

场景分类预测

# !/usr/bin/env python3
# coding=utf-8
# !/usr/bin/env python3
# coding=utf-8
import os
import time

from iobjectspy.ml.vision import Inference
Using TensorFlow backend.

设置输入数据路径

curr_dir = ''
data_dir = os.path.join(curr_dir, '..','..','example_data')
inference_dir = os.path.join(data_dir, 'inference')

设置输出数据路径

out_dir = os.path.join(curr_dir, '..','..','out')
if not os.path.exists(out_dir):
    os.makedirs(out_dir)

设置模型路径

model_path = os.path.join(curr_dir, '..','..','model')
lcz_cls_model = os.path.join(model_path, 'sce_cls_lcz', 'sce_cls_lcz.sdm')

数据模型预测

dom_path = os.path.join(data_dir, 'inference', 'lcz_infer.tif')
out_data = os.path.join(out_dir, 'out_lcz_cls.udb')
out_dataset_name = 'predict_lcz'

start_time = time.time()
result = Inference(input_data=dom_path,
                   model_path=lcz_cls_model,
                   out_data=out_data,
                   out_dataset_name=out_dataset_name).scene_classify_infer(result_type='region')
end_time = time.time()
print('提取完成,共耗时{}s,结果数据保存在 {} 数据源下 {} 数据集中'.format(
    end_time - start_time, out_data, result))
/home/data/hou/workspaces/iobjectspy/venv/lib/python3.6/site-packages/rasterio/__init__.py:216: NotGeoreferencedWarning: Dataset has no geotransform set. The identity matrix may be returned.
  s = DatasetReader(path, driver=driver, sharing=sharing, **kwargs)


java -cp /home/data/hou/workspaces/iobjectspy/venv/lib/python3.6/site-packages/iobjectspy-10.0.0-py3.6.egg/iobjectspy/_jsuperpy/jars/iobjects-py4j.jar com.supermap.jsuperpy.ApplicationExample 127.0.0.1 59829
[iObjectsPy]: Connection gateway-service successful, Python callback port bind 42957

[>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>]100%,2223The scene classification have done!
提取完成,共耗时136.48770475387573s,结果数据保存在 ../../data/out/out_lcz_cls.udb 数据源下 predict_lcz 数据集中

展开阅读全文
加载中
点击引领话题📣 发布并加入讨论🔥
0 评论
0 收藏
0
分享
返回顶部
顶部