File size: 3,123 Bytes
0391966 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
{
"cells": [
{
"cell_type": "code",
"execution_count": 4,
"id": "3d72f70e",
"metadata": {},
"outputs": [],
"source": [
"import cv2\n",
"import os\n",
"import numpy as np\n",
"import pickle\n",
"import tensorflow as tf\n",
"from tensorflow.keras import layers\n",
"\n",
"from tensorflow.keras import models,utils\n",
"\n",
"import pandas as pd\n",
"\n",
"from tensorflow.keras.models import load_model\n",
"\n",
"from tensorflow.keras.preprocessing.image import load_img,img_to_array\n",
"\n",
"from tensorflow.python.keras import utils\n",
"current_path = os.getcwd()\n"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "d0655482",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Collecting opencv-python\n",
" Downloading opencv_python-4.7.0.72-cp37-abi3-macosx_11_0_arm64.whl (32.6 MB)\n",
"\u001b[2K \u001b[90mββββββββββββββββββββββββββββββββββββββββ\u001b[0m \u001b[32m32.6/32.6 MB\u001b[0m \u001b[31m1.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n",
"\u001b[?25hRequirement already satisfied: numpy>=1.21.2 in /Users/ujjwalbansal/anaconda3/lib/python3.10/site-packages (from opencv-python) (1.24.3)\n",
"Installing collected packages: opencv-python\n",
"Successfully installed opencv-python-4.7.0.72\n",
"Note: you may need to restart the kernel to use updated packages.\n"
]
}
],
"source": [
"pip install opencv-python"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "867fc892",
"metadata": {},
"outputs": [],
"source": [
"import tensorflow_hub as hub"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "0fb1cb14",
"metadata": {},
"outputs": [],
"source": [
"model_path=\"skimlit_final_model\""
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "20ad6fa1",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"2023-06-14 12:49:03.226973: W tensorflow/tsl/platform/profile_utils/cpu_utils.cc:128] Failed to get CPU frequency: 0 Hz\n"
]
}
],
"source": [
"my_reloaded_model = tf.keras.models.load_model(\n",
" (model_path),\n",
" custom_objects={'KerasLayer':hub.KerasLayer})"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ece84ef9",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.10 (tensorflow)",
"language": "python",
"name": "tensorflow"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.9"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
|