Skip to content

Instantly share code, notes, and snippets.

@moodoki
moodoki / exportgraph.py
Last active February 14, 2023 05:58
Freeze and export Tensorflow graph from checkpoint files
import os, argparse
import tensorflow as tf
from tensorflow.python.framework import graph_util
dir = os.path.dirname(os.path.realpath(__file__))
def freeze_graph(model_folder, output_nodes='y_hat',
output_filename='frozen-graph.pb',
rename_outputs=None):
# -*- coding: utf-8 -*-
import h5py
import os
import numpy as np
from random import shuffle
import shutil
from PIL import Image
SIZE = 227