Skip to content

Instantly share code, notes, and snippets.

View nagadomi's full-sized avatar
🤖
I am Antigravity

nagadomi

🤖
I am Antigravity
View GitHub Profile
@nagadomi
nagadomi / _sapiens2_model.py
Last active November 6, 2026 11:59
nunif/iw3 extension for Sapiens2
# nunif/iw3 extension for Sapiens2: https://github.com/facebookresearch/sapiens2
#
# Sapiens2 is a suite of human-centric vision models that includes depth estimation and segmentation,
# allowing the creation of passthrough 3D videos with only people extracted from standard video footage.
#
# Save this file as `iw3/depth_models/_sapiens2_model.py`.
# Checkpoint files (pointmap and seg) can be downloaded from: https://huggingface.co/collections/facebook/sapiens2
# Example:
# iw3/pretrained_models/hub/checkpoints/sapiens2_0.4b_pointmap.safetensors
# iw3/pretrained_models/hub/checkpoints/sapiens2_0.4b_seg.safetensors
import ctypes
import os
import sys
import torch
import numpy as np
import torchvision
# NVOF Constants
NV_OF_API_MAJOR_VERSION = 2
NV_OF_API_MINOR_VERSION = 0
import torch
import coremltools as ct
import os
# --- Model Definitions (Primary Models) ---
V2_MODELS = {
# model_name: (entry_point, arg_name, encoder_name)
"Any_S": ("DepthAnything", "encoder", "vits"),
"Any_B": ("DepthAnything", "encoder", "vitb"),
@nagadomi
nagadomi / generate_person_mask_sam3.py
Last active January 21, 2026 02:10
generates human masks with SAM3
# python generate_person_mask_sam3.py -i ./test_images -o output
#
# This script generates human masks from images.
# It works not only with photos but also with anime-style images.
# The latest version of transformers is required.
# `pip install git+https://github.com/huggingface/transformers.git`
# Using SAM3 requires proper license authorization.
import os
from os import path
@nagadomi
nagadomi / 1_1_vertex_shader.glsl
Last active May 6, 2023 20:09
conversion of eeVR shader to MSL using https://github.com/septag/glslcc
#version 450
layout (location = POSITION) in vec3 aVertexPosition;
layout (location = TEXCOORD0) in vec2 aVertexTextureCoord;
layout (location = TEXCOORD0) out vec2 vTexCoord;
void main() {
vTexCoord = aVertexTextureCoord;
gl_Position = vec4(aVertexPosition, 1);
}
@nagadomi
nagadomi / 1_build_wasm.sh
Last active May 21, 2023 07:39
build onnxruntime-web webgpu on Ubuntu
#!/bin/bash
export NODE_OPTIONS=""
git submodule sync --recursive
git submodule update --init --recursive
BUILD_DIR=build_jsep_st
rm -fr ${BUILD_DIR}
cd cmake/external/emsdk
import numpy as np
from timeit import timeit
from collections import deque
# online running meanstd. ref https://github.com/ajcr/rolling/tree/master/rolling
class TimeRunningMeanStd(object):
def __init__(self, shape, ttl):
self.ttl = ttl
self.mean = np.zeros(shape, dtype=np.float64)
self.std = np.ones(shape, dtype=np.float64)
@nagadomi
nagadomi / se_block.lua
Created October 21, 2018 00:50
Torch7 SEBlock (Squeeze and Excitation Networks)
require 'nn'
local ScaleTable, parent = torch.class("nn.ScaleTable", "nn.Module")
function ScaleTable:__init()
parent.__init(self)
self.gradInput = {}
self.grad_tmp = torch.Tensor()
self.scale = torch.Tensor()
end
function ScaleTable:updateOutput(input)
# pip3 install python-dateutil websocket-client
import sys
import time
import json
import websocket
from dateutil.parser import parse as date_parse
from collections import deque
K=100
pack_buf = deque(maxlen=K)
# -*- coding: utf-8 -*-
# pip3 install xlrd python-dateutil
import xlrd
from datetime import datetime
from dateutil.parser import parse as date_parse
from collections import defaultdict
# 入力ファイル