Skip to content

Commit

Permalink
added model file existence check
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan903 committed Aug 24, 2023
1 parent 4469eac commit 58cc30d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion human_detection/yolov7_skeleton/sort.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os
import numpy as np
import matplotlib
matplotlib.use('TkAgg')
# matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
import matplotlib.patches as patches
from skimage import io
Expand Down
4 changes: 4 additions & 0 deletions human_detection/yolov7_skeleton/yolov7.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from utils.general import check_img_size, non_max_suppression, scale_coords, set_logging, increment_path
from utils.torch_utils import select_device, TracedModel
import sort
import os

"""Function to draw bounding boxes"""
def draw_boxes(img, bbox, identities=None, categories=None, confidences=None, names=None, colors=None, thickness=2, hide_bounding_box=False,hide_labels=False):
Expand Down Expand Up @@ -64,6 +65,9 @@ def __init__(self,
self.use_half_precision = self.device.type != 'cpu' # enable half precision if on GPU (only supported on CUDA)

# Load model
if not os.path.exists(weights_file):
raise FileNotFoundError(f"The file '{weights_file}' does not exist.")

self.model = attempt_load(weights_file, map_location=self.device) # load FP32 model
self.stride = int(self.model.stride.max()) # model stride, which is the step size or the number of units the sliding window moves when performing operations like convolution or pooling
self.imgsize = check_img_size(img_size, s=self.stride) # check img_size
Expand Down

0 comments on commit 58cc30d

Please sign in to comment.