Skip to content

Instantly share code, notes, and snippets.

View DiTo97's full-sized avatar

Federico Minutoli DiTo97

View GitHub Profile
@DiTo97
DiTo97 / graphcoloring.py
Last active January 10, 2024 04:10
A collection of graph coloring algorithms
"""A collection of graph coloring algorithms
The problem of assigning colors to the vertices of a graph such that no two adjacent vertices have the same color.
"""
import random
import typing
from collections import defaultdict
import networkx
@DiTo97
DiTo97 / negative-prompts.txt
Last active January 9, 2024 23:25
A list of resources for close-up style transfer with stable diffusion XL v1.0
artifacts
bad anatomy
bad proportions
blurry
cloned face
cropped
deformed
dehydrated
disfigured
duplicate
@DiTo97
DiTo97 / calibration.py
Last active August 23, 2023 08:27
A module for operations on camera calibration parameters
import numpy as np
import numpy.typing as np_typing
Vector = np_typing.NDArray[np.float64]
Matrix = np_typing.NDArray[np.float64]
def extrinsics_to_rotmat_and_posvec(E: Matrix) -> tuple[Matrix, Vector]:
R = E[:, :3]
@DiTo97
DiTo97 / imageproc.py
Last active August 23, 2023 08:35
A module for operations on 2-dim point sets (e.g., images)
import numpy as np
import numpy.typing as np_typing
try:
import cv2 as opencv
has_opencv = True
except ModuleNotFoundError:
has_opencv = False
@DiTo97
DiTo97 / keypresses.py
Last active January 10, 2024 00:28
It detects simultaneous keyboard presses
import time
import keyboard
def get_pressed_keys() -> set[str]:
"""It obtains the pressed keyboard keys"""
keyboard._listener.start_if_necessary()
with keyboard._pressed_events_lock: