Skip to content

Instantly share code, notes, and snippets.

View FrancescoSaverioZuppichini's full-sized avatar
🧸
Focusing

Francesco Saverio Zuppichini FrancescoSaverioZuppichini

🧸
Focusing
  • roboflow
  • Lugano, Switzerland
View GitHub Profile
version: '3.8'
services:
caddy:
container_name: caddy
image: caddy
ports:
# - '80:80'
- '443:443'
restart: unless-stopped
volumes:
@FrancescoSaverioZuppichini
FrancescoSaverioZuppichini / git-ssh-error-fix.sh
Created June 12, 2023 14:24 — forked from Tamal/git-ssh-error-fix.sh
Solution for 'ssh: connect to host github.com port 22: Connection timed out' error
$ git clone git@github.com:xxxxx/xxxx.git my-awesome-proj
Cloning into 'my-awesome-proj'...
ssh: connect to host github.com port 22: Connection timed out
fatal: Could not read from remote repository.
$ # This should also timeout
$ ssh -T git@github.com
ssh: connect to host github.com port 22: Connection timed out
$ # but this might work
(bboxes[...] * keep[...][...,None])
iou = box_iou(bbox[None,...], (bboxes[order[i + 1:]]) * keep[i + 1:][...,None])
from torchvision.ops.boxes import box_iou
def nms(bboxes: torch.Tensor, scores: torch.Tensor, iou_threshold: float) -> torch.Tensor:
order = torch.argsort(-scores)
indices = torch.arange(bboxes.shape[0])
keep = torch.ones_like(indices, dtype=torch.bool)
for i in indices:
if keep[i]:
bbox = bboxes[order[i]]
iou = box_iou(bbox[None,...],(bboxes[order[i + 1:]]) * keep[i + 1:][...,None])
%%timeit
torch_nms(bboxes + labels[..., None], scores, .45)
%%timeit
nms(bboxes + labels[..., None], scores, .45)
from torchvision.ops.boxes import nms as torch_nms
nms_indices = torch_nms(bboxes + labels[..., None], scores, .45)
plot_bboxes(img,
bboxes[nms_indices],
colors=["yellow" if el.item() == 0 else "blue" for el in labels[nms_indices]],
labels=["head" if el.item() == 0 else "mic" for el in labels[nms_indices]]
)
from ipywidgets import interact
def _interact(threshold: float):
print(threshold)
nms_indices = nms(bboxes + labels[..., None], scores, threshold)
plot_bboxes(img,
bboxes[nms_indices],
colors=["yellow" if el.item() == 0 else "blue" for el in labels[nms_indices]],
labels=["head" if el.item() == 0 else "mic" for el in labels[nms_indices]]
)