Skip to content

Commit

Permalink
YOLO webcam example - add assert for webcam load (#202) (#204)
Browse files Browse the repository at this point in the history
* YOLO webcam example - add assert for webcam load

* update readme to note other options for annotate

* formatting
  • Loading branch information
bfineran committed Apr 29, 2021
1 parent c47bfb8 commit f7dbd57
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 6 additions & 1 deletion integrations/ultralytics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,14 @@ python annotate.py \
zoo:cv/detection/yolo_v3-spp/pytorch/ultralytics/coco/pruned_quant-aggressive_94 \
--source 0 \
--quantized-inputs \
--image-shape 416 416
--image-shape 416 416 \
--no-save # webcam only
```

In addition to webcam `--source` can take a path to a `.jpg` file, directory or glog pat
of `.jpg` files, or path to a `.mp4` video file. If source is an integer and no
corresponding webcam is available, an exception will be raised.


### Benchmarking
`benchmarking.py` is a script for benchmarking sparsified and quantized YOLOv3
Expand Down
5 changes: 4 additions & 1 deletion integrations/ultralytics/deepsparse/deepsparse_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,10 @@ def __iter__(self) -> Iterator[Tuple[numpy.ndarray, numpy.ndarray]]:
self._stream.release()
cv2.destroyAllWindows()
break
_, frame = self._stream.read()
loaded, frame = self._stream.read()

assert loaded, f"Could not load image from webcam {self._camera}"

frame = cv2.flip(frame, 1) # flip left-right
yield load_image(frame, image_size=self._image_size)

Expand Down

0 comments on commit f7dbd57

Please sign in to comment.