Open3

AGLLNetのエクスポート

docker run --rm -it --gpus all \
-v `pwd`:/home/user/workdir \
pinto0309/whenet:latest /bin/bash

git clone https://github.com/yu-li/AGLLNet
cd AGLLNet

python3 run_agllnet.py
import os
import numpy as np
import imageio
import cv2
import math
from glob import glob
from keras.models import load_model
from tqdm import tqdm
import sys

def run(input_path, output_path):
    """Run AGLLNet to enhance the low light image.
    Args:
        input_path (str): path to input folder
        output_path (str): path to output folder
    """

    if not os.path.isdir(output_path):
        os.makedirs(output_path)

    path = glob(os.path.join(input_path, '*.*'))

    model = load_model('model/AgLLNet.h5')
    model.summary()
    model.save('AgLLNet.h5')


    import tensorflow as tf
    #from keras.models import load_model
    from keras import backend as K
    from tensorflow.python.framework import graph_io
    from tensorflow.python.framework import graph_util
    def freeze_graph(session, output, save_pb_dir='.', save_pb_name='frozen_model.pb', save_pb_as_text=False):
        graph = session.graph
        with graph.as_default():
            graphdef_inf = tf.graph_util.remove_training_nodes(graph.as_graph_def())
            graphdef_frozen = graph_util.convert_variables_to_constants(session, graphdef_inf, output)
            graph_io.write_graph(graphdef_frozen, save_pb_dir, save_pb_name, as_text=save_pb_as_text)
            return graphdef_frozen

    K.clear_session()
    K.set_learning_phase(0)
    model = load_model('AgLLNet.h5')
    session = K.get_session()
    freeze_graph(session, [out.op.name for out in model.outputs], save_pb_dir='.')
    sys.exit(0)
docker run --gpus all -it --rm \
-v `pwd`:/home/user/workdir \
ghcr.io/pinto0309/openvino2tensorflow:latest

rm -rf openvino
rm -rf saved_model

$ pb_to_saved_model \
--pb_file_path frozen_model.pb \
--inputs input_1:0 \
--outputs concatenate_22/concat:0

H=256
W=256
python3 $INTEL_OPENVINO_DIR/deployment_tools/model_optimizer/mo_tf.py \
--input_model frozen_model.pb \
--input_shape [1,${H},${W},3] \
--output_dir saved_model_${H}x${W}/openvino/FP32 \
--model_name agllnet

H=256
W=384
python3 $INTEL_OPENVINO_DIR/deployment_tools/model_optimizer/mo_tf.py \
--input_model frozen_model.pb \
--input_shape [1,${H},${W},3] \
--output_dir saved_model_${H}x${W}/openvino/FP32 \
--model_name agllnet

H=384
W=512
python3 $INTEL_OPENVINO_DIR/deployment_tools/model_optimizer/mo_tf.py \
--input_model frozen_model.pb \
--input_shape [1,${H},${W},3] \
--output_dir saved_model_${H}x${W}/openvino/FP32 \
--model_name agllnet

H=512
W=640
python3 $INTEL_OPENVINO_DIR/deployment_tools/model_optimizer/mo_tf.py \
--input_model frozen_model.pb \
--input_shape [1,${H},${W},3] \
--output_dir saved_model_${H}x${W}/openvino/FP32 \
--model_name agllnet

H=768
W=768
python3 $INTEL_OPENVINO_DIR/deployment_tools/model_optimizer/mo_tf.py \
--input_model frozen_model.pb \
--input_shape [1,${H},${W},3] \
--output_dir saved_model_${H}x${W}/openvino/FP32 \
--model_name agllnet

H=768
W=1280
python3 $INTEL_OPENVINO_DIR/deployment_tools/model_optimizer/mo_tf.py \
--input_model frozen_model.pb \
--input_shape [1,${H},${W},3] \
--output_dir saved_model_${H}x${W}/openvino/FP32 \
--model_name agllnet
ログインするとコメントできます