nooneshouldtouch commited on
Commit
12b2a05
·
verified ·
1 Parent(s): b2912ac

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -13
app.py CHANGED
@@ -69,8 +69,7 @@ num_anchors = 9
69
  model = None
70
 
71
  def prepare_model(approach: int):
72
- global model, anchor_boxes, input_shape, class_names
73
-
74
  if approach not in [1, 2, 3]:
75
  raise ValueError("Approach must be 1, 2, or 3.")
76
 
@@ -81,24 +80,14 @@ def prepare_model(approach: int):
81
  }
82
 
83
  weight_path = os.path.join("model-data", "weights", weight_files[approach])
84
-
85
  if not os.path.exists(weight_path):
86
  raise FileNotFoundError(f"Weight file not found: {weight_path}")
87
 
88
- # Define anchor boxes for YOLO (you may need to adjust these values)
89
- anchor_boxes = np.array([
90
- np.array([[10, 13], [16, 30], [33, 23]]) / 32,
91
- np.array([[30, 61], [62, 45], [59, 119]]) / 16,
92
- np.array([[116, 90], [156, 198], [373, 326]]) / 8
93
- ], dtype="float64")
94
-
95
  input_tensor = Input(shape=(input_shape[0], input_shape[1], 3))
96
- num_out_filters = (num_anchors // 3) * (5 + len(class_names))
97
  model = yolo_body(input_tensor, num_out_filters)
98
  model.load_weights(weight_path)
99
 
100
- print(f"YOLO model (Approach={approach}) loaded successfully.")
101
-
102
  @app.on_event("startup")
103
  def on_startup():
104
  fix_tf_gpu()
 
69
  model = None
70
 
71
  def prepare_model(approach: int):
72
+ global model
 
73
  if approach not in [1, 2, 3]:
74
  raise ValueError("Approach must be 1, 2, or 3.")
75
 
 
80
  }
81
 
82
  weight_path = os.path.join("model-data", "weights", weight_files[approach])
 
83
  if not os.path.exists(weight_path):
84
  raise FileNotFoundError(f"Weight file not found: {weight_path}")
85
 
 
 
 
 
 
 
 
86
  input_tensor = Input(shape=(input_shape[0], input_shape[1], 3))
87
+ num_out_filters = (num_anchors // 3) * (5 + num_classes)
88
  model = yolo_body(input_tensor, num_out_filters)
89
  model.load_weights(weight_path)
90
 
 
 
91
  @app.on_event("startup")
92
  def on_startup():
93
  fix_tf_gpu()