This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export CPLUS_INCLUDE_PATH=$CONDA_PREFIX/lib/python3.8 | |
export NVIDIA_ARCH_CAPABILITY=8.6 #Change this to your gpu's compute capability | |
# This script requires a directory structure which looks like the following, | |
# with opencv-master from git, opencv_contrib-master from git, and a build directory | |
# with only this script inside. You must execute this shell script from inside the build | |
# directory, with your desired conda environment activated. | |
# The initial setup is copied from here: https://docs.opencv.org/3.4.15/d7/d9f/tutorial_linux_install.html | |
# With steps 2-5 replaced with this shell script. | |
# ├── build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import numpy as np | |
import mediapipe as mp | |
image = cv2.imread("./input.png") | |
mask = np.zeros_like(image) | |
segm = mp.solutions.mediapipe.python.solutions.face_mesh.FaceMesh( | |
True, | |
min_detection_confidence=0.6 | |
) | |
landmarks = segm.process(image).multi_face_landmarks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import List | |
import numpy as np | |
def image_grid(images: List[np.ndarray], nrows: int): | |
""" | |
Creates a grid of images with 'nrows' number of image rows, images must all be the same shape. | |
""" | |
assert len(images) > nrows, "Must have more images than rows" | |
ncols = int(np.ceil(len(images) / nrows)) | |
images_size = images[0].shape[:2] | |
grid_img = np.zeros((nrows * images_size[0], ncols * images_size[1], 3), dtype=np.uint8) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from traceback import format_exception | |
def format_error(e: Exception, limit: int = 3): | |
"""Format exception as a string. | |
Args: | |
e (Exception): Raised exception object. | |
limit (int): limit of error call stack lines to be included in the formatted string. | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { ExifTool, Tags } = require('exiftool-vendored'); | |
/** | |
* Function to write makernote and exif data to a PNG file. | |
* @param {string} filePath - Path to the PNG file. | |
* @param {string} makerNote - Makernote exif key data to write. | |
* @param {string} comment - Comment exif key data to write. | |
* @return {Promise<boolean>} - True if successful, false otherwise. | |
*/ | |
export const writeMetadata = async (filePath, makerNote, comment) => { | |
const tool = new ExifTool(); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import AsyncGenerator, List, Coroutine, Any, Callable, Union | |
import asyncio | |
from loguru import logger | |
async def async_limit_iterator( | |
limit=8, | |
jobs: List[Any] = [], | |
coroutine_fn: Callable[[Any], Coroutine[Any, None, None]] = None, | |
throw_exceptions: bool = False, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
from typing import List, Union | |
import cv2, os, pathlib | |
from PIL import Image | |
from loguru import logger | |
from more_itertools import flatten | |
from mediapipe.python.solutions.face_detection import FaceDetection | |
import numpy as np | |
from traceback import format_exception |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pathlib import Path | |
from argparse import ArgumentParser | |
from typing import Optional | |
from pydantic import BaseModel | |
class Args(BaseModel): | |
input_path: Path | |
recursive: bool = False | |
output_file: Optional[Path] | |
extensions: list[str] = ['jpeg','jpg','png','webp'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
from einops import rearrange | |
_magma_table = [ | |
(0.001462, 0.000466, 0.013866), | |
(0.002258, 0.001295, 0.018331), | |
(0.003279, 0.002305, 0.023708), | |
(0.004512, 0.003490, 0.029965), | |
(0.005950, 0.004843, 0.037130), | |
(0.007588, 0.006356, 0.044973), |
OlderNewer