-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CPU support, standalone image detection and save results features
- Loading branch information
1 parent
358f333
commit a71c565
Showing
6 changed files
with
201 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
opencv-python | ||
ultralytics | ||
ultralytics | ||
py-cpuinfo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import cv2 | ||
|
||
|
||
def bounding_box(image, cone): | ||
cv2.rectangle( | ||
image, | ||
cone.bounding_box.top_left, | ||
cone.bounding_box.bottom_right, | ||
cone.color, | ||
3, | ||
) | ||
|
||
|
||
def label(image, cone, font): | ||
cv2.putText( | ||
image, | ||
f"{cone.name} {round(cone.conf * 100)}%", | ||
(cone.bounding_box.top_left[0], cone.bounding_box.top_left[1] - 10), | ||
font, | ||
0.5, | ||
cone.color, | ||
1, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,41 @@ | ||
from camera_perception.common import pytorch_info | ||
|
||
|
||
# YOLO check | ||
import ultralytics | ||
|
||
ultralytics.checks() | ||
|
||
# CUDA check | ||
|
||
# CUDA/CPU check | ||
import torch | ||
import torchvision | ||
|
||
|
||
version, engine = pytorch_info(torch.__version__) | ||
version_vision, engine_vision = pytorch_info(torchvision.__version__) | ||
|
||
if engine != engine_vision: | ||
print( | ||
f"torch and torchvision packages are not compatible:\n" | ||
f"torch: {engine} {version}\n" | ||
f"torchvision: {engine_vision} {version_vision}" | ||
) | ||
exit(1) | ||
|
||
if engine == "cu" and not torch.cuda.is_available(): | ||
print( | ||
f"CUDA is not available but PyTorch {engine.upper()} {version} is installed. " | ||
f"Check environment configuration for conflicted packages." | ||
) | ||
exit(1) | ||
|
||
if not torch.cuda.is_available(): | ||
print("CUDA is not available.") | ||
print(f"CUDA is not available. PyTorch {engine.upper()} {version} will be used.") | ||
exit(0) | ||
|
||
if engine == "cpu" and torch.cuda.is_available(): | ||
print( | ||
f"CUDA is available but PyTorch {engine.upper()} {version} is used. " | ||
f"Check environment configuration for better performance." | ||
) |