Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking β€œSign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge develop branch into master #3518

Merged
merged 30 commits into from
Jun 8, 2021
Merged
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
bb13123
update ci-testing.yml (#3322)
SkalskiP May 27, 2021
3fea068
update ci-testing.yml (#3322)
SkalskiP May 27, 2021
b78e30d
Merge remote-tracking branch 'origin/develop' into develop
SkalskiP May 28, 2021
ba6f3f9
Enable direct `--weights URL` definition (#3373)
glenn-jocher May 28, 2021
57f773b
Update tutorial.ipynb (#3368)
pizzaz93 May 29, 2021
21a9607
`cv2.imread(img, -1)` for IMREAD_UNCHANGED (#3379)
tudoulei May 29, 2021
4b52e19
COCO evolution fix (#3388)
glenn-jocher May 29, 2021
d833ab3
Create `is_pip()` function (#3391)
glenn-jocher May 30, 2021
fdbe527
Revert "`cv2.imread(img, -1)` for IMREAD_UNCHANGED (#3379)" (#3395)
glenn-jocher May 31, 2021
3cb9ad4
Update FLOPs description (#3422)
chocosaj Jun 3, 2021
f8651c3
Parse URL authentication (#3424)
glenn-jocher Jun 3, 2021
af2bc3a
Add FLOPs title to table (#3453)
glenn-jocher Jun 4, 2021
4aa2959
Suppress jit trace warning + graph once (#3454)
glenn-jocher Jun 4, 2021
8e3b4a0
Update MixUp augmentation `alpha=beta=32.0` (#3455)
glenn-jocher Jun 4, 2021
d40481a
Add `timeout()` class (#3460)
glenn-jocher Jun 4, 2021
c37f072
Faster HSV augmentation (#3462)
developer0hye Jun 4, 2021
563ea94
Add `check_git_status()` 5 second timeout (#3464)
glenn-jocher Jun 4, 2021
317f2cc
Improved `check_requirements()` offline-handling (#3466)
glenn-jocher Jun 4, 2021
044daaf
Add `output_names` argument for ONNX export with dynamic axes (#3456)
SamSamhuns Jun 4, 2021
b31229a
Revert FP16 `test.py` and `detect.py` inference to FP32 default (#3423)
PresageBoat Jun 4, 2021
739451d
Add additional links/resources to stale.yml message (#3467)
glenn-jocher Jun 4, 2021
3597d28
Update stale.yml HUB URL (#3468)
glenn-jocher Jun 4, 2021
cf4f95b
Stale `github.actor` bug fix (#3483)
glenn-jocher Jun 6, 2021
a1c3572
Explicit `model.eval()` call `if opt.train=False` (#3475)
developer0hye Jun 6, 2021
90b7895
check_requirements() exclude `opencv-python` (#3495)
glenn-jocher Jun 7, 2021
8d1ddc9
Earlier `assert` for cpu and half option (#3508)
developer0hye Jun 7, 2021
eede7dc
Update tutorial.ipynb (#3510)
glenn-jocher Jun 7, 2021
d986145
Reduce test.py results spacing (#3511)
glenn-jocher Jun 7, 2021
abb2a96
Update README.md (#3512)
glenn-jocher Jun 7, 2021
c058a61
Update greetings.yml
glenn-jocher Jun 8, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add timeout() class (#3460)
* Add `timeout()` class

* rearrange order
glenn-jocher authored Jun 4, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit d40481acc5f73a06fa5ced5fd2cfa8fce73a744d
24 changes: 23 additions & 1 deletion utils/general.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# YOLOv5 general utils

import contextlib
import glob
import logging
import math
import os
import platform
import random
import re
import signal
import subprocess
import time
import urllib
@@ -34,6 +36,26 @@
os.environ['NUMEXPR_MAX_THREADS'] = str(min(os.cpu_count(), 8)) # NumExpr max threads


class timeout(contextlib.ContextDecorator):
# Usage: @timeout(seconds) decorator or 'with timeout(seconds):' context manager
def __init__(self, seconds, *, timeout_message="", suppress_timeout_errors=True):
self.seconds = int(seconds)
self.timeout_message = timeout_message
self.suppress = bool(suppress_timeout_errors)

def _timeout_handler(self, signum, frame):
raise TimeoutError(self.timeout_message)

def __enter__(self):
signal.signal(signal.SIGALRM, self._timeout_handler) # Set handler for SIGALRM
signal.alarm(self.seconds) # start countdown for SIGALRM to be raised

def __exit__(self, exc_type, exc_val, exc_tb):
signal.alarm(0) # Cancel SIGALRM if it's scheduled
if self.suppress and exc_type is TimeoutError: # Suppress TimeoutError
return True


def set_logging(rank=-1, verbose=True):
logging.basicConfig(
format="%(message)s",
@@ -86,7 +108,7 @@ def check_online():
# Check internet connectivity
import socket
try:
socket.create_connection(("1.1.1.1", 443), 5) # check host accesability
socket.create_connection(("1.1.1.1", 443), 5) # check host accessibility
return True
except OSError:
return False