Skip to content

Instantly share code, notes, and snippets.

View THEFASHIONGEEK's full-sized avatar
❣️
open source

DayDreamer THEFASHIONGEEK

❣️
open source
View GitHub Profile
from infer_detector import Infer
gtf = Infer()
gtf.Model(model_name="mobilenet", weights="weights/Final_RFB_mobile_COCO.pth", use_gpu=True)
gtf.Image_Params(class_file, input_size=300)
gtf.Setup()
output = gtf.Predict(img_path, thresh=0.195, font_size=1, line_size=3)
from train_detector import Detector
gtf = Detector()
gtf.Train_Dataset(root_dir, coco_dir, img_dir, batch_size=32,image_size=300, num_workers=3)
gtf.Model(model_name="mobilenet", use_gpu=True, ngpu=1)
gtf.Set_HyperParams(lr=0.0001, momentum=0.9, weight_decay=0.0005, gamma=0.1, jaccard_threshold=0.5)
gtf.Train(epochs=10, log_iters=True, output_weights_dir="weights", saved_epoch_interval=10)
import numpy as np
import cv2
from matplotlib import pyplot as plt
img = cv2.imread("imgs/chapter5/sudoku.png", 0);
kernel = [
[1, 0, -1],
[1, 0, -1],
[1, 0, -1]
]
import numpy as np
import cv2
from matplotlib import pyplot as plt
img = cv2.imread("imgs/chapter5/sudoku.png", 0);
kernel = [
[1, 1, 1],
[0, 0, 0],
[-1, -1, -1]
]
# Gabor filter in x direction - Black to white gradient
#Theta - 0 degree
%matplotlib inline
import numpy as np
import cv2
from matplotlib import pyplot as plt
img = cv2.imread("imgs/chapter5/chess_slant.jpg", 0);
pi = 3.14;
import numpy as np
import cv2
import skimage
from matplotlib import pyplot as plt
img = cv2.imread("imgs/chapter5/sudoku.png", 0);
img = cv2.blur(img, (3, 3));
###################################FOCUS#######################################
robert_filter = skimage.filters.hessian(img, sigmas=range(1, 2, 1)) # Image binarization
import numpy as np
import cv2
from matplotlib import pyplot as plt
img = cv2.imread("imgs/chapter5/sudoku.png", 0);
img = cv2.blur(img, (3, 3));
laplacian = cv2.Laplacian(img,cv2.CV_8UC1) #Binarized
f = plt.figure(figsize=(15,15))
f.add_subplot(1, 2, 1).set_title('Original Image');
plt.imshow(img, cmap = "gray")
f.add_subplot(1, 2, 2).set_title('Filtered Image');
import numpy as np
import cv2
from matplotlib import pyplot as plt
img = cv2.imread("imgs/chapter5/text2.png", 0);
#img = cv2.blur(img, (3, 3));
# global thresholding
ret1,th1 = cv2.threshold(img,127,255,cv2.THRESH_BINARY)
import numpy as np
import cv2
from matplotlib import pyplot as plt
img = cv2.imread("imgs/chapter5/text.png", 0);
#img = cv2.blur(img, (3, 3))
# threshold -> 127
# maxval -> 255
# Output:
import numpy as np
import cv2
from matplotlib import pyplot as plt
img = cv2.imread("imgs/chapter5/text2.png", 0);
#img = cv2.blur(img, (3, 3))
# threshold -> 127
# maxval -> 255
# Output: