m7mdal7aj commited on
Commit
ddf7cf5
1 Parent(s): b40d522

Update my_model/object_detection.py

Browse files
Files changed (1) hide show
  1. my_model/object_detection.py +3 -3
my_model/object_detection.py CHANGED
@@ -66,7 +66,7 @@ class ObjectDetector:
66
  try:
67
  model_path = get_model_path('deformable-detr-detic')
68
  self.processor = AutoImageProcessor.from_pretrained(model_path)
69
- self.model = AutoModelForObjectDetection.from_pretrained(model_path)
70
  except Exception as e:
71
  print(f"Error loading Detic model: {e}")
72
  raise
@@ -84,9 +84,9 @@ class ObjectDetector:
84
  try:
85
  model_path = get_model_path ('yolov5')
86
  if model_path and os.path.exists(model_path):
87
- self.model = torch.hub.load(model_path, model_version, pretrained=pretrained, source='local', device_map = self.device)
88
  else:
89
- self.model = torch.hub.load('ultralytics/yolov5', model_version, pretrained=pretrained, device_map = self.device)
90
  except Exception as e:
91
  print(f"Error loading YOLOv5 model: {e}")
92
  raise
 
66
  try:
67
  model_path = get_model_path('deformable-detr-detic')
68
  self.processor = AutoImageProcessor.from_pretrained(model_path)
69
+ self.model = AutoModelForObjectDetection.from_pretrained(model_path, device_map = self.device)
70
  except Exception as e:
71
  print(f"Error loading Detic model: {e}")
72
  raise
 
84
  try:
85
  model_path = get_model_path ('yolov5')
86
  if model_path and os.path.exists(model_path):
87
+ self.model = torch.hub.load(model_path, model_version, pretrained=pretrained, source='local')
88
  else:
89
+ self.model = torch.hub.load('ultralytics/yolov5', model_version, pretrained=pretrained)
90
  except Exception as e:
91
  print(f"Error loading YOLOv5 model: {e}")
92
  raise