Skip to content

Instantly share code, notes, and snippets.

View yoshoku's full-sized avatar
🥷

Atsushi Tatsuma yoshoku

🥷
View GitHub Profile
@yoshoku
yoshoku / foo.cc
Created April 23, 2022 10:54
console.log with node-addon-api
#include <napi.h>
class Foo : public Napi::ObjectWrap<Foo> {
public:
// ...
Napi::Value foo(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::Function consoleLog = env.Global().Get("console").As<Napi::Object>().Get("log").As<Napi::Function>();
consoleLog.Call({ Napi::String::New(env, "Hello, World.") });
@yoshoku
yoshoku / retrieval.rb
Created February 12, 2021 16:21
Content-image retrieval with torch.rb and annoy.rb (ja)
require 'magro'
require 'torch'
require 'torchvision'
require 'annoy'
# @param src [Numo::NArray] (shape: [height, width, channel]) 入力画像
def preprocessing(src)
# 画像の中心を正方形に切り出す.
height, width, = src.shape
img_size = [height, width].min
@yoshoku
yoshoku / classify.rb
Created February 11, 2021 00:26
Image Recognition with VGG-16 Network in Ruby (ja)
require 'magro'
require 'json'
require 'torch'
require 'torchvision'
# 学習済みのVGG-16 Networkを読み込む.
vgg = TorchVision::Models::VGG16.new
vgg.load_state_dict(Torch.load('vgg16_.pth'))
# 画像を読み込む.
@yoshoku
yoshoku / test.md
Last active January 1, 2021 14:28
Wow

t e s t

test1

test2