diff --git a/CoreMLConverters/CoreML_Converter_SSDMobileNetV1_From_Saved_Model.ipynb b/CoreMLConverters/CoreML_Converter_SSDMobileNetV1_From_Saved_Model.ipynb index d50b7ab7bf629502c0937eb81fb407687451bdff..e4b69251dd6cab3446a139e4cadae9658ae078fb 100644 --- a/CoreMLConverters/CoreML_Converter_SSDMobileNetV1_From_Saved_Model.ipynb +++ b/CoreMLConverters/CoreML_Converter_SSDMobileNetV1_From_Saved_Model.ipynb @@ -37,8 +37,7 @@ "\n", "path = \"/content/gdrive/My Drive/V1Mobilenet/saved_model\"\n", "\n", - "# Load the protobuf file from the disk and parse it to retrieve the\n", - "# graph_def\n", + "with tf.io.gfile.GFile(path, \"rb\") as f:\n", " graph_def = tf.compat.v1.GraphDef()\n", " graph_def.ParseFromString(f.read())\n", @@ -49,7 +48,6 @@ "\n", "ops = graph.get_operations()\n", "N = len(ops)\n", - "# print all the placeholder ops, these would be the inputs\n", "print(\"Inputs ops: \")\n", "for op in ops:\n", " if op.type == \"Placeholder\":\n", @@ -57,9 +55,6 @@ " format(op.name, op.outputs[0].get_shape()))\n", "\n", "\n", - "# print all the tensors that are the first output of an op\n", - "# and do not feed into any other op\n", - "# these are prospective outputs\n", "print(\"\\nProspective output tensor(s): \", )\n", "sink_ops = []\n", "input_tensors = set()\n", @@ -86,7 +81,7 @@ "mlmodel = ct.convert(graph,\n", " inputs=[ct.TensorType(shape=x.shape)])\n", "\n", - "# Core ML model prediction\n", + "coreml_out_dict = mlmodel.predict({\"input\" : x}, useCPUOnly=True)\n", "coreml_out = list(coreml_out_dict.values())[0]\n", "np.testing.assert_allclose(tf_out, coreml_out, rtol=1e-3, atol=1e-2)" @@ -160,4 +155,4 @@ ] } ] -} \ No newline at end of file +}