Skip to content

Instantly share code, notes, and snippets.

View wellflat's full-sized avatar
🐱
cat

ryohei tanaka wellflat

🐱
cat
View GitHub Profile
@wellflat
wellflat / parser.py
Created February 15, 2024 09:23
clearml dataset parser
#!/usr/bin/env python
import argparse
import json
import sys
def parse_args():
parser = argparse.ArgumentParser(description='ClearML dataset parser')
parser.add_argument('--file', '-f', type=str, required=True, help='dataset file name')
parser.add_argument('--output', '-o', type=str, required=True, help='output file name')
@wellflat
wellflat / random_sample.py
Created September 5, 2022 01:37
Random sampling image files for torchvision.datasets.ImageFolder
#!/usr/bin/env python
import glob
import random
import shutil
import math
def random_sample_file(input_dir: str, output_dir: str, sample_ratio: float=0.05):
print(f'copy {input_dir} to {output_dir}')
@wellflat
wellflat / HelloONNX.vue
Last active January 29, 2024 09:01
Image Classification using ONNX Runtime for Web (ORT Web)
<template>
<div class="hello">
<h1>{{ msg }}</h1>
<canvas width="32" height="32" ref="canvas"></canvas>
<button type="button" @click="inference">inference</button>
<span>{{ infoLabel }}</span>
</div>
</template>
<script lang="ts">
@wellflat
wellflat / aws_s3_multipart_client.py
Last active August 12, 2020 06:50
AWS S3 multipart upload sample
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import botocore
from boto3.session import Session
from boto3.s3.transfer import TransferConfig
from pprint import pprint
class S3Client(object):
-- example reporting script which demonstrates a custom
-- done() function that prints results as JSON
done = function(summary, latency, requests)
io.write("\nJSON Output:\n")
io.write("{\n")
io.write(string.format("\t\"requests\": %d,\n", summary.requests))
io.write(string.format("\t\"duration_in_microseconds\": %0.2f,\n", summary.duration))
io.write(string.format("\t\"bytes\": %d,\n", summary.bytes))
io.write(string.format("\t\"requests_per_sec\": %0.2f,\n", (summary.requests/summary.duration)*1e6))
@wellflat
wellflat / pyvips.ipynb
Last active January 22, 2018 14:15
libvipsで高速省メモリな画像処理 part1 http://rest-term.com/archives/3434/
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@wellflat
wellflat / image_loader.js
Created November 27, 2017 13:04
promise image loader
let loadImage = ({ src }) => {
return new Promise((resolve, reject) => {
let img = new Image();
img.onload = () => {
resolve(img);
};
img.src = src;
});
};
#include <iostream>
#include <faiss/IndexFlat.h>
#include <faiss/IndexIVFPQ.h>
#include <faiss/gpu/GpuIndexFlat.h>
#include <faiss/gpu/GpuIndexIVFPQ.h>
#include <faiss/gpu/StandardGpuResources.h>
#include <faiss/index_io.h>
#include <faiss/utils.h>
#include <boost/program_options.hpp>
@wellflat
wellflat / emacs_memo.md
Last active May 28, 2018 02:57
Emacs Memo

色設定

色変更したい箇所にカーソルを合わせて以下のコマンドを実行してface名を確認

M-x describe-face

次に以下のコマンドを実行して、対象のface名を選択する

M-x list-faces-display
@wellflat
wellflat / read_smaps.py
Created August 21, 2016 07:22
read smaps file (Linuxプロセスのメモリ共有率を計算)
#!/usr/bin/env python
import sys
def read_smaps(pidlist):
try:
print("PID\tRSS\tSHARED\t\tNONE_SHARED")
mem = lambda t, f: int(f[1]) if f[0] == '%s:' % t else 0.0
for pid in pidlist:
filename = "/proc/%s/smaps" % pid