This file contains hidden or 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
# Civitaiのinfoファイルを使ってLoraを分類するコード | |
# プレビュー画像は取り直しなので注意 | |
require 'json' | |
require 'fileutils' | |
# === 設定 === | |
TARGET_DIR = 'C:\SD\webui\models\Lora\nofolder' # 対象のフォルダに書き換えてください | |
DEST_BASE_DIR = 'C:\SD\webui\models\Lora\copied' # 分類結果を保存するフォルダ |
This file contains hidden or 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 os | |
from glob import glob | |
from skimage.metrics import structural_similarity as ssim | |
import cv2 | |
import sys | |
from pathlib import Path | |
def calculate_ssim(image_path1, image_path2): | |
"""2つの画像間のSSIM(構造的類似性)を計算する""" | |
img1 = cv2.imread(image_path1, cv2.IMREAD_GRAYSCALE) |
This file contains hidden or 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
# 渡ってきた複数ファイルのうち、拡張子がsafetensorsのファイルを探し、 | |
# それ以外の画像ファイルをすべて同じファイル名に変える。 | |
# CivitaiからダウンロードしてきたLoRAに対して使う。 | |
require 'fileutils' | |
def rename_files_to_same_name | |
imagefiles = [] | |
safefilename = "" | |
ARGV.each do |file| |
This file contains hidden or 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
# | |
# PNGファイルのメタデータを全部読み込んでメモ帳に表示 | |
# | |
require 'chunky_png' | |
require 'securerandom' | |
tempdir = 'C:\SD\pnglog' | |
if (ARGV.count < 1) | |
puts "please set parameter for file" | |
exit |
This file contains hidden or 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
# | |
# フォルダ以下のPNGファイルのメタデータを全部読み込んでHTMLに書き出す | |
# Stable Diffusion で参考になるプロンプトを探すために作成 | |
# | |
require 'chunky_png' | |
def template_html | |
return <<'EOS' | |
<!DOCTYPE html> |
This file contains hidden or 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
double grayScaleFromPixel(img.Pixel px) { | |
return (px.r + px.g + px.b) / 3; | |
} | |
bool _hitTest(img.Image? clipImage, int x1, int y1, int x2, int y2, int width, | |
int height) { | |
// 切り抜き画像がnullかどうか | |
if (clipImage == null) { | |
return false; | |
} |
This file contains hidden or 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
ご飯を炊く = Ractor.new do | |
"ご飯を炊く" | |
end | |
盛り付け = Ractor.new do |data| | |
Ractor.recv.join('/') + "/盛り付け" | |
end | |
カレー = Ractor.new do | |
野菜を切る = Ractor.new do | |
"野菜を切る" |
This file contains hidden or 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
<script> | |
function 野菜を切る() { | |
return new Promise(function(callback) { | |
callback("野菜を切る"); | |
}); | |
} | |
function じっくり炒める(data) { | |
return new Promise(function(callback) { | |
callback(data + "/じっくり炒める"); | |
}); |
This file contains hidden or 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
require "csv" | |
# 各レコードは、改行を区切りとする | |
csv_text = <<~CSV_TEXT | |
aaa,bbb,ccc | |
zzz,yyy,xxx | |
CSV_TEXT | |
CSV.parse(csv_text) do |row| | |
p row |
This file contains hidden or 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
public static AnimationClip CreateAnimationClip(VMDFormat format, int interpolationQuality) | |
{ | |
VMDVRoidConverter converter = new VMDVRoidConverter(); | |
//アニメーションクリップを作成 | |
AnimationClip clip = new AnimationClip(); | |
clip.name = "output_test"; | |
//キーフレーム作成 | |
AnimationCurve retCurve = new AnimationCurve(new Keyframe(0, 0), new Keyframe(1, 1)); | |
//カーブ作成 |
NewerOlder