Skip to content

Commit

Permalink
More Webcam
Browse files Browse the repository at this point in the history
  • Loading branch information
ksanjeevan committed Jul 9, 2018
1 parent cac0b00 commit 47e29df
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 5 deletions.
6 changes: 5 additions & 1 deletion dourflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from yolov2 import YoloV2, YoloInferenceModel
import os

from net.neteval import gen_anchors


# Add CPU option
os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID"
Expand All @@ -14,7 +16,9 @@

if YoloParams.WEIGHT_FILE:
generate_model()

elif YoloParams.GEN_ANCHORS_PATH:
pass
#gen_anchors(YoloParams.GEN_ANCHORS_PATH)
else:
YoloV2().run()

Expand Down
36 changes: 34 additions & 2 deletions net/neteval.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,45 @@
from net.netparams import YoloParams
from net.netdecode import YoloOutProcess

from tqdm import tqdm
import matplotlib.pyplot as plt
import numpy as np
import cv2, os
import keras
from net.utils import draw_boxes, compute_iou, mkdir_p, yolo_normalize, mkdir_p, handle_empty_indexing
from net.utils import draw_boxes, compute_iou, mkdir_p, \
yolo_normalize, mkdir_p, handle_empty_indexing, parse_annotation

from tqdm import tqdm



'''
def exrtract_wh(img):
result = []
pixel_height = img['height']
pixel_width = img['width']
fact_pixel_grid_h = YoloParams.GRID_SIZE / pixel_height
fact_pixel_grid_w = YoloParams.GRID_SIZE / pixel_width
for obj in img['object']:
grid_h = (obj['ymax'] - obj['ymin']) * fact_pixel_grid_h
grid_w = (obj['xmax'] - obj['xmin']) * fact_pixel_grid_w
result.append( np.array(grid_h, grid_w) )
return result
def gen_anchors(fname):
imgs, _ = parse_annotation(ann_dir, img_dir)
data_wh = []
for img in imgs:
data_wh += exrtract_wh(img)
c = AgglomerativeClustering(self.num_clusters, affinity='precomputed', linkage=self.c_type)
'''



Expand Down
8 changes: 6 additions & 2 deletions net/netparams.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,19 @@ class YoloParams(object):
PREDICT_IMAGE = ''
WEIGHT_FILE = ''
WEBCAM_OUT = ''
GEN_ANCHORS_PATH = ''

if action == 'gen':
if action in ['genw', 'generate_weights']:
assert args.weight_file, "Need to pass weight file if generating model."
WEIGHT_FILE = args.weight_file
elif action == 'cams':
WEBCAM_OUT = 'cam_out.mp4'
YOLO_MODE = 'cam'
elif action in ['genp', 'generate_priors']:
GEN_ANCHORS_PATH = 'new_anchors.png'
YOLO_MODE = 'genp'
else:
if action == 'validate' or action == 'train' or action == 'cam':
if action in ['validate', 'train', 'cam']:
YOLO_MODE = action
else:
if os.path.isdir(action):
Expand Down
3 changes: 3 additions & 0 deletions net/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ def parse_annotation(ann_dir, img_dir, labels=[]):






def yolo_normalize(image):
return image / 255.

Expand Down

0 comments on commit 47e29df

Please sign in to comment.