Skip to content

Instantly share code, notes, and snippets.

View seatedro's full-sized avatar

ro seatedro

  • nether realm
View GitHub Profile
@seatedro
seatedro / InferenceOnTFObjectDetection.py
Created October 5, 2020 15:19
InferenceOnTFObjectDetection
import numpy as np
from PIL import Image
from google.colab.patches import cv2_imshow
def load_image_into_numpy_array(path):
"""Load an image from file into a numpy array.
Puts image into numpy array to feed into tensorflow graph.
Note that by convention we put it into a numpy array with shape
(height, width, channels), where channels=3 for RGB.
@seatedro
seatedro / GetLatestCheckpoint.py
Created October 5, 2020 15:06
Clean-up checkpoints
output_directory = 'exported-models/'
# goes through the model is the training/ dir and gets the last one.
# you could choose a specfic one instead of the last
lst = os.listdir("models/my_mobilenet/")
# print(lst)
lst = [l for l in lst if 'ckpt-' in l and '.index' not in l]
steps=np.array([int(re.findall('\d+', l)[0]) for l in lst])
last_model = lst[steps.argmax()]
last_model_path = os.path.join('models/my_mobilenet', last_model)
@seatedro
seatedro / createTFRecord.py
Created October 4, 2020 13:48
Create TF Record
import pandas as pd
import numpy as np
import csv
import re
import cv2
import os
import glob
import xml.etree.ElementTree as ET
import io