20_提取目標-iObjects Python with JupyterHub for K8s

20_提取目標-iObjects Python with JupyterHub for K8s

從影像數據中檢測並提取符合特徵的地物,結果信息輸出到GeoJSON文件中。json

 
在JupyterLab中調用iObjects Python實現,過程與代碼以下:
 
In [6]:
import os
import time

from iobjectspy import open_datasource
from iobjectspy.ai.recognition import detection
In [7]:
#data_dir = ''
data_dir = '/home/jovyan/data/smdata/'
out_dir = os.path.join(data_dir, 'out/')

model_path = os.path.join(data_dir, 'model/det/1')
print(model_path)

category_name = ['plane']
輸出:
/home/jovyan/data/smdata/model/det/1
In [8]:
if not os.path.exists(out_dir):
    os.makedirs(out_dir)
    
def extract_plane_file():
    """
    影像文件格式支持 ‘tif’、‘img’(Erdas Image)、'jpg'、'png' 等
    目標檢測結果爲GeoJSON文件,包含目標位置、類型等信息
    """
    start_time = time.time()
    detection(data_dir + 'plane.tif', category_name, model_path,
              out_data=out_dir, out_name='out_plane.json')
    end_time = time.time()
    print('耗時{}s'.format(end_time-start_time))
In [9]:
if __name__ == '__main__':
    # 基於影像文件進行飛機目標檢測
    extract_plane_file()
輸出信息:
INFO:tensorflow:Saver not created because there are no variables in the graph to restore
INFO:tensorflow:The specified SavedModel has no variables; no checkpoints were restored.
耗時5.122027635574341s
相關文章
相關標籤/搜索