Skip to content

Commit

Permalink
check if file exist
Browse files Browse the repository at this point in the history
Signed-off-by: Mpho Mphego <mpho112@gmail.com>
  • Loading branch information
mmphego committed Jul 17, 2020
1 parent 06930a7 commit bb5f13c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 29 deletions.
37 changes: 11 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ tree && du -sh

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

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.
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.
- Run: `docker pull mmphego/intel-openvino`

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

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

```bash
MODEL_NAME=<<name of model to download>>
Expand All @@ -103,15 +103,14 @@ mmphego/intel-openvino \
bash -c "\
/opt/intel/openvino/deployment_tools/open_model_zoo/tools/downloader/downloader.py --name $MODEL_NAME"
```
Models used in this project:
- [Face Detection Model](https://docs.openvinotoolkit.org/latest/_models_intel_face_detection_adas_binary_0001_description_face_detection_adas_binary_0001.html)
- [Facial Landmarks Detection Model](https://docs.openvinotoolkit.org/latest/_models_intel_landmarks_regression_retail_0009_description_landmarks_regression_retail_0009.html)
- [Head Pose Estimation Model](https://docs.openvinotoolkit.org/latest/_models_intel_head_pose_estimation_adas_0001_description_head_pose_estimation_adas_0001.html)
- [Gaze Estimation Model](https://docs.openvinotoolkit.org/latest/_models_intel_gaze_estimation_adas_0002_description_gaze_estimation_adas_0002.html)
## Documentation
### Usage
## Application Usage
```bash
Expand Down Expand Up @@ -154,6 +153,8 @@ optional arguments:
--debug Show output on screen [debugging].
--show-bbox Show bounding box and stats on screen [debugging].
```
### Example
```shell
xvfb-run docker run --rm -ti \
Expand Down Expand Up @@ -181,7 +182,7 @@ bash -c "\
### Packaging the Application
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.
To deploy the application to various devices usinf the Deployment Manager run the steps below.
To deploy the application to various devices using the Deployment Manager run the steps below.
Note: Choose from the devices listed below.
```bash
Expand All @@ -197,33 +198,17 @@ mmphego/intel-openvino bash -c "\
```
## Benchmarks
*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.
## Results
*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.
## Stand Out Suggestions
This is where you can provide information about the stand out suggestions that you have attempted.
### Async Inference
If you have used Async Inference in your code, benchmark the results and explain its effects on power and performance of your project.
## Edge Cases
- 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,
- No Head Detection: it will skip the frame and inform the user
## Area of Improvement:
## Future Improvement
- [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.
- Gaze estimations: We could revisit the logic of detemining and calculating the coordinates as it is a bit flaky.
- Gaze estimations: We could revisit the logic of determining and calculating the coordinates as it is a bit flaky.
- lighting condition: We might use HSV based pre-processing steps to minimize error due to different lighting conditions.
## Reference
- [OpenCV Face Recognition](https://www.pyimagesearch.com/2018/09/24/opencv-face-recognition/)
- [Tracking your eyes with Python](https://medium.com/@stepanfilonov/tracking-your-eyes-with-python-3952e66194a6)
- [Real-time eye tracking using OpenCV and Dlib](https://towardsdatascience.com/real-time-eye-tracking-using-opencv-and-dlib-b504ca724ac6)
- [Deep Head Pose](https://github.com/natanielruiz/deep-head-pose/blob/master/code/utils.py#L86+L117)
- [Deep Head Pose](https://github.com/natanielruiz/deep-head-pose/blob/master/code/utils.py#L86+L117)
18 changes: 15 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import time

from loguru import logger
from pprint import pprint

from src.input_feeder import InputFeeder
from src.model import (
Expand Down Expand Up @@ -100,13 +101,18 @@ def arg_parser():
parser.add_argument(
"--enable-mouse", action="store_true", help="Enable Mouse Movement",
)
parser.add_argument(
"--show-bbox",
action="store_true",
help="Show bounding box and stats on screen [debugging].",
)
parser.add_argument(
"--debug", action="store_true", help="Show output on screen [debugging].",
)
parser.add_argument(
"--show-bbox",
"--stats",
action="store_true",
help="Show bounding box and stats on screen [debugging].",
help="Verbose OpenVINO layer performance stats [debugging].",
)
return parser.parse_args()

Expand Down Expand Up @@ -139,7 +145,7 @@ def main(args):
logger.info(f"Total time taken to load all the models: {model_load_time:.2f} secs.")
count = 0
for frame in video_feed.next_frame():
count +=1
count += 1
predict_end_time, face_bboxes = face_detection.predict(
frame, show_bbox=args.show_bbox
)
Expand Down Expand Up @@ -208,6 +214,12 @@ def main(args):
)
video_feed.show(video_feed.resize(frame))

if args.stats:
pprint(face_detection.perf_stats)
pprint(facial_landmarks.perf_stats)
pprint(head_pose_estimation.perf_stats)
pprint(gaze_estimation.perf_stats)

video_feed.close()


Expand Down
9 changes: 9 additions & 0 deletions src/input_feeder.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def __init__(self, input_file=None):
"""
self.input_file = input_file
assert isinstance(self.input_file, str)
self.check_file_exists(self.input_file)
try:
self._input_type, _ = mimetypes.guess_type(self.input_file)
assert isinstance(self._input_type, str)
Expand All @@ -56,6 +57,14 @@ def load_data(self):
raise FormatNotSupported(msg)
logger.info(f"Loaded input source type: {self._input_type}")

@staticmethod
def check_file_exists(file):
if "cam" in file:
return

if not os.path.exists(os.path.abspath(file)):
raise FileNotFoundError(f"{file} does not exist.")

@property
def source_width(self):
return int(self.cap.get(cv2.CAP_PROP_FRAME_WIDTH))
Expand Down

0 comments on commit bb5f13c

Please sign in to comment.