Spaces:
Running
Running
Commit
·
86915f5
1
Parent(s):
d545606
Fix: resolved model access methodology
Browse files
app.py
CHANGED
@@ -74,7 +74,12 @@ def process_image(image, yolo_versions=["yolov5"]):
|
|
74 |
for yolo_version in yolo_versions:
|
75 |
# Load the model based on YOLO version
|
76 |
model = load_yolo_model(yolo_version)
|
77 |
-
|
|
|
|
|
|
|
|
|
|
|
78 |
|
79 |
# Run YOLO detection
|
80 |
results = model([rgb_img])
|
|
|
74 |
for yolo_version in yolo_versions:
|
75 |
# Load the model based on YOLO version
|
76 |
model = load_yolo_model(yolo_version)
|
77 |
+
|
78 |
+
# YOLOv8: Extract last layer by model.model[-1] would not work; use the following:
|
79 |
+
if isinstance(model.model, torch.nn.Sequential):
|
80 |
+
target_layers = [model.model[-1]] # This assumes model layers are in a Sequential container
|
81 |
+
else:
|
82 |
+
target_layers = [model.model[-2]] # Use an appropriate layer
|
83 |
|
84 |
# Run YOLO detection
|
85 |
results = model([rgb_img])
|