In the middle of the desert you can say anything you want
Detectron’s Instances object gets created like this, creating attributes with names unknown initially:
def __init__(self, image_size: Tuple[int, int], **kwargs: Any):
"""
Args:
image_size (height, width): the spatial size of the image.
kwargs: fields to add to this `Instances`.
"""
self._image_size = image_size
self._fields: Dict[str, Any] = {}
for k, v in kwargs.items():
self.set(k, v)
Which is neat.
To create an Instances object for unit tests I did:
pred_boxes = Boxes(tensor(
[
[ 143.8892, 1166.6632, 1358.7292, 1411.6588],
[ 131.3727, 864.3126, 1355.7804, 1144.3668],
[ 585.6373, 747.7184, 922.6433, 815.9998]
]))
scores = tensor(
[0.9971, 0.9967, 0.9938]
)
pred_classes = tensor([3, 3, 3])
instances = Instances(
image_size=(2122, 1500),
scores=scores,
pred_classes=pred_classes,
pred_boxes=pred_boxes
)
Found this in old markdown code from my old blog, I guess I forgot about this:
<what@ever.com>
<https://example.com>
When opening a lot of files as vim -p *.md*
only 10 kept being opened, finally googled it.
Solution: adding set tabpagemax=50
to ~/.vimrc
From SO1:
find . -name '*.php' -exec sed -i -e 's/www.fubar.com/www.fubar.ftw.com/g' {} \;
title: “211121-2123 Undoing git add / unstaging files” tags:
Two different questions here! Both options are: 1
If you add a file for the first time, git rm --cached .
or git -rm -r --cached .
will reverse that.
If you want to un-add changes to a file that’s already in the repo, git reset <file>
/ git reset
will undo that.
(heard at work)
The basic concept of mob programming is simple: the entire team works as a team together on one task at the time. That is: one team – one (active) keyboard – one screen (projector of course).
— Marcus Hammarberg, Mob programming – Full Team, Full Throttle1
“”Mob programming is a software development approach where the whole team works on the same thing, at the same time, in the same space, and at the same computer. “Mob code review is a software development approach where the whole team reviews on the same thing, at the same time, in the same space, and at the same computer.”2
Python’s NamedTuple is really cool!
Python’s Instance, Class, and Static Methods Demystified – Real Python is an excellent guide, as is the entire website.
NamedTuple VS Dataclass, copying from SO answer:[^1]
When your data structure needs to/can be immutable, hashable, iterable, unpackable, comparable then you can use NamedTuple
. If you need something more complicated, for example, a possibility of inheritance for your data structure then use Dataclass
.
The immutable part is important - can’t do named_tuple.value = 3
after creating it.
Can be created also through colections.namedtuple
, copied directly from :
>>> from collections import namedtuple
>>> Person = namedtuple("Person", "name children")
>>> john = Person("John Doe", ["Timmy", "Jimmy"])
>>> john
Person(name='John Doe', children=['Timmy', 'Jimmy'])
>>> id(john.children)
139695902374144
whatever: List[str,str,str]
can’t be done, because lists inherently change sizeTIL df -h filename
(or more likely df -h .
) returns the info about the filesystem that file is in. Will save me a lot of time, since usually that’s exactly teh one I need.
Story behind this:
Mistyped df -h
as df -
, it returned:
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/ubuntu--vg-root 488960032 463006852 1045612 100% /
Wanted to find out what happened. Likely this:
-
in zsh is the last directory you were in (since cd -
does gets you there)man df
says that:
df displays the amount of disk space
available on the file system containing each file name argument. If no file name is given,
the space available on all currently mounted file systems is shown.
Added this to ~/.zshrc
, since I seem to type it so often to have memorized it:
alias dus="du -hd1 | sort -h"
Returns the sizes of dirs sorted by size:
32K ./configs
5,2M ./small_dataset
24M ./conversion
630M ./model
792M .