Skip to content

Commit bb5f13c

Browse files
committed
check if file exist
Signed-off-by: Mpho Mphego <[email protected]>
1 parent 06930a7 commit bb5f13c

File tree

3 files changed

+35
-29
lines changed

3 files changed

+35
-29
lines changed

README.md

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@ tree && du -sh
8080

8181
### Setup and Installation
8282
There are two (2) ways of running the project.
83-
1) Download and install [Intel OpenVINO Toolkit](https://software.intel.com/content/www/us/en/develop/tools/openvino-toolkit.html) and install.
83+
1. Download and install [Intel OpenVINO Toolkit](https://software.intel.com/content/www/us/en/develop/tools/openvino-toolkit.html) and install.
8484
- After you've cloned the repo, you need to install the dependecies using this command:
8585
`pip3 install -r requirements.txt`
8686

87-
2) Run the project in the [Docker image](https://hub.docker.com/r/mmphego/intel-openvino) that I have baked Intel OpenVINO and dependencies in.
87+
2. Run the project in the [Docker image](https://hub.docker.com/r/mmphego/intel-openvino) that I have baked Intel OpenVINO and dependencies in.
8888
- Run: `docker pull mmphego/intel-openvino`
8989

9090
Not sure what Docker is, [watch this](https://www.youtube.com/watch?v=rOTqprHv1YE)
@@ -93,7 +93,7 @@ For this project I used the latter method.
9393

9494
#### Models Used
9595
I have already downloaded the Models, which are located in `./models/`.
96-
Should you wish to download your own models follow:
96+
Should you wish to download your own models run:
9797

9898
```bash
9999
MODEL_NAME=<<name of model to download>>
@@ -103,15 +103,14 @@ mmphego/intel-openvino \
103103
bash -c "\
104104
/opt/intel/openvino/deployment_tools/open_model_zoo/tools/downloader/downloader.py --name $MODEL_NAME"
105105
```
106+
106107
Models used in this project:
107108
- [Face Detection Model](https://docs.openvinotoolkit.org/latest/_models_intel_face_detection_adas_binary_0001_description_face_detection_adas_binary_0001.html)
108109
- [Facial Landmarks Detection Model](https://docs.openvinotoolkit.org/latest/_models_intel_landmarks_regression_retail_0009_description_landmarks_regression_retail_0009.html)
109110
- [Head Pose Estimation Model](https://docs.openvinotoolkit.org/latest/_models_intel_head_pose_estimation_adas_0001_description_head_pose_estimation_adas_0001.html)
110111
- [Gaze Estimation Model](https://docs.openvinotoolkit.org/latest/_models_intel_gaze_estimation_adas_0002_description_gaze_estimation_adas_0002.html)
111112
112-
## Documentation
113-
114-
### Usage
113+
## Application Usage
115114
116115
```bash
117116
@@ -154,6 +153,8 @@ optional arguments:
154153
--debug Show output on screen [debugging].
155154
--show-bbox Show bounding box and stats on screen [debugging].
156155
```
156+
157+
157158
### Example
158159
```shell
159160
xvfb-run docker run --rm -ti \
@@ -181,7 +182,7 @@ bash -c "\
181182
### Packaging the Application
182183
We can use the [Deployment Manager](https://docs.openvinotoolkit.org/latest/_docs_install_guides_deployment_manager_tool.html) present in OpenVINO to create a runtime package from our application. These packages can be easily sent to other hardware devices to be deployed.
183184
184-
To deploy the application to various devices usinf the Deployment Manager run the steps below.
185+
To deploy the application to various devices using the Deployment Manager run the steps below.
185186
Note: Choose from the devices listed below.
186187
187188
```bash
@@ -197,33 +198,17 @@ mmphego/intel-openvino bash -c "\
197198
198199
```
199200
200-
201-
202-
## Benchmarks
203-
*TODO:* Include the benchmark results of running your model on multiple hardwares and multiple model precisions. Your benchmarks can include: model loading time, input/output processing time, model inference time etc.
204-
205-
## Results
206-
*TODO:* Discuss the benchmark results and explain why you are getting the results you are getting. For instance, explain why there is difference in inference time for FP32, FP16 and INT8 models.
207-
208-
## Stand Out Suggestions
209-
This is where you can provide information about the stand out suggestions that you have attempted.
210-
211-
### Async Inference
212-
If you have used Async Inference in your code, benchmark the results and explain its effects on power and performance of your project.
213-
214201
## Edge Cases
215202
- Multiple People Scenario: If we encounter multiple people in the video frame, it will always use and give results one face even though multiple people detected,
216203
- No Head Detection: it will skip the frame and inform the user
217204
218-
## Area of Improvement:
205+
## Future Improvement
219206
- [Intel® VTune™ Profiler](https://software.intel.com/content/www/us/en/develop/tools/vtune-profiler/choose-download.html): Profile my application and locate any bottlenecks.
220-
- Gaze estimations: We could revisit the logic of detemining and calculating the coordinates as it is a bit flaky.
207+
- Gaze estimations: We could revisit the logic of determining and calculating the coordinates as it is a bit flaky.
221208
- lighting condition: We might use HSV based pre-processing steps to minimize error due to different lighting conditions.
222209
223-
224210
## Reference
225-
226211
- [OpenCV Face Recognition](https://www.pyimagesearch.com/2018/09/24/opencv-face-recognition/)
227212
- [Tracking your eyes with Python](https://medium.com/@stepanfilonov/tracking-your-eyes-with-python-3952e66194a6)
228213
- [Real-time eye tracking using OpenCV and Dlib](https://towardsdatascience.com/real-time-eye-tracking-using-opencv-and-dlib-b504ca724ac6)
229-
- [Deep Head Pose](https://github.com/natanielruiz/deep-head-pose/blob/master/code/utils.py#L86+L117)
214+
- [Deep Head Pose](https://github.com/natanielruiz/deep-head-pose/blob/master/code/utils.py#L86+L117)

main.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import time
55

66
from loguru import logger
7+
from pprint import pprint
78

89
from src.input_feeder import InputFeeder
910
from src.model import (
@@ -100,13 +101,18 @@ def arg_parser():
100101
parser.add_argument(
101102
"--enable-mouse", action="store_true", help="Enable Mouse Movement",
102103
)
104+
parser.add_argument(
105+
"--show-bbox",
106+
action="store_true",
107+
help="Show bounding box and stats on screen [debugging].",
108+
)
103109
parser.add_argument(
104110
"--debug", action="store_true", help="Show output on screen [debugging].",
105111
)
106112
parser.add_argument(
107-
"--show-bbox",
113+
"--stats",
108114
action="store_true",
109-
help="Show bounding box and stats on screen [debugging].",
115+
help="Verbose OpenVINO layer performance stats [debugging].",
110116
)
111117
return parser.parse_args()
112118

@@ -139,7 +145,7 @@ def main(args):
139145
logger.info(f"Total time taken to load all the models: {model_load_time:.2f} secs.")
140146
count = 0
141147
for frame in video_feed.next_frame():
142-
count +=1
148+
count += 1
143149
predict_end_time, face_bboxes = face_detection.predict(
144150
frame, show_bbox=args.show_bbox
145151
)
@@ -208,6 +214,12 @@ def main(args):
208214
)
209215
video_feed.show(video_feed.resize(frame))
210216

217+
if args.stats:
218+
pprint(face_detection.perf_stats)
219+
pprint(facial_landmarks.perf_stats)
220+
pprint(head_pose_estimation.perf_stats)
221+
pprint(gaze_estimation.perf_stats)
222+
211223
video_feed.close()
212224

213225

src/input_feeder.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def __init__(self, input_file=None):
3434
"""
3535
self.input_file = input_file
3636
assert isinstance(self.input_file, str)
37+
self.check_file_exists(self.input_file)
3738
try:
3839
self._input_type, _ = mimetypes.guess_type(self.input_file)
3940
assert isinstance(self._input_type, str)
@@ -56,6 +57,14 @@ def load_data(self):
5657
raise FormatNotSupported(msg)
5758
logger.info(f"Loaded input source type: {self._input_type}")
5859

60+
@staticmethod
61+
def check_file_exists(file):
62+
if "cam" in file:
63+
return
64+
65+
if not os.path.exists(os.path.abspath(file)):
66+
raise FileNotFoundError(f"{file} does not exist.")
67+
5968
@property
6069
def source_width(self):
6170
return int(self.cap.get(cv2.CAP_PROP_FRAME_WIDTH))

0 commit comments

Comments
 (0)