diffusers ライブラリで EasyNegativeV2 みたいな補正を読み込む場合
tag: diffusers
a1111形式のtextual inversionの場合は以下のように記述する模様。
from diffusers import StableDiffusionPipeline import torch model_id = "runwayml/stable-diffusion-v1-5" pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16).to("cuda") pipe.load_textual_inversion("./charturnerv2.pt", token="charturnerv2") prompt = "charturnerv2, multiple views of the same character in the same outfit, a character turnaround of a woman wearing a black jacket and red shirt, best quality, intricate details." image = pipe(prompt, num_inference_steps=50).images[0] image.save("character.png")
EasyNegativeV2.safetensorsの場合は以下。
第1引数にディレクトリ名を指定。 weight_nameには拡張子safetensorsを残してファイル名を指定。 tokenにはプロンプトで使う文字列を指定。
pipe.load_textual_inversion("./embeddings", weight_name="EasyNegativeV2.safetensors", token="EasyNegativeV2")
一応 seed 固定で実験してみると、絵の形が変わるので効いているっぽい雰囲気はある。
Firefoxでキャッシュサイズを変更する方法
tag: firefox
ChatGPTのopenaiライブラリでchatのstreamモードを実装する
tag: chatgpt, openai
openai==0.27.8の話。
以前見た時よりストリームモード実装が簡単になっているような気がする...。
上に載っているサンプルコード。
# Example of an OpenAI ChatCompletion request with stream=True # https://platform.openai.com/docs/guides/chat # a ChatCompletion request response = openai.ChatCompletion.create( model='gpt-3.5-turbo', messages=[ {'role': 'user', 'content': "What's 1+1? Answer in one word."} ], temperature=0, stream=True # this time, we set stream=True ) for chunk in response: print(chunk)
for chunk in response のループにて、続々と到着するストリーミングモードのChatGPTの応答をchunkとして取り出して処理する形になっている。
日本語だとほぼ1文字ずつchunkとして送られてきててちょっとおもしろい。
NVIDIA GeForce Experience のオーバーレイ「alt + Z」のショートカットをオフにする方法
tag: geforce, nvidia, vscode
alt + Z は vscode でよく使うのでこのショートカットをオフにする方法をメモ。
FreeBSD用のvagrant box イメージ(Hyper-V)が無いゾ → freebsd公式boxイメージを使う
tag: vagrant, virtualbox, freebsd, freebsd-13.2, freebsd
genericさんの vagrant 用 box イメージ (Hyper-V) の更新が途絶えてしまったようだ。
久しぶりに FreeBSD 公式の virtualbox イメージを使う。
■環境
普通は Windows 上で VirtualBox を動かす場合は Hyper-V をOFFにしないといけない。
ただ VirtualBox も改良が進んでいて、Hyper-Vを有効にしたままでも一応 Guest OS が起動するくらいはするようになっているようだ。
仮想マシンの動作が遅くなるのでオススメはできないけど。
特に、ssh の X11Forwarding yes を使って Firefox とか Thunderbird を使おうとすると起動中にハングするほど重くなるので注意。 emacsならX11Forwarding経由で起動できるけど。
■Vagrantfile
boxイメージのディスク容量が足りないので追加ディスクを指定している。
Vagrant.configure("2") do |config| config.vm.box = "freebsd/FreeBSD-13.2-RELEASE" config.vm.box_version = "2023.04.07" # Disable automatic box update checking. If you disable this, then # boxes will only be checked for updates when the user runs # `vagrant box outdated`. This is not recommended. config.vm.box_check_update = false config.vm.synced_folder ".", "/vagrant", type: "rsync", rsync__exclude: [ ".git/" ] config.vm.boot_timeout = 800 config.ssh.shell = "sh" # freebsd64 config.vm.define "freebsd64" do |master1| master1.vm.hostname = "freebsd64.area54.local" master1.vm.provider "virtualbox" do |vb| vb.customize ["modifyvm", :id, "--memory", "6000"] vb.customize ["modifyvm", :id, "--cpus", "2"] # add storage /dev/ada1 file_to_disk = "../vagranthdd/64-freebsd-ada1.vdi" unless File.exist?(file_to_disk) vb.customize ['createhd', '--filename', file_to_disk, '--size', 100 * 1024, '--format', 'VDI'] # 100GB end vb.customize ['storageattach', :id, '--storagectl', 'IDE Controller', '--port', 0, '--device', 1, '--type', 'hdd', '--medium', file_to_disk] # add storage /dev/ada2 file_to_disk = "../vagranthdd/64-freebsd-ada2.vdi" unless File.exist?(file_to_disk) vb.customize ['createhd', '--filename', file_to_disk, '--size', 100 * 1024, '--format', 'VDI'] # 100GB end vb.customize ['storageattach', :id, '--storagectl', 'IDE Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', file_to_disk] end # PROXY設定を環境変数PROXY_SERV_PORT,PROXY_USER,PROXY_PASSから読み込んでVM側に持ち込む # https://qiita.com/hakomikan/items/860bb960699889849933 Vagrantfile をコミットするために - Qiita master1.vm.provision "export env", type: "shell", run: "always", privileged: true, inline: <<-SHELL mkdir -p /etc/profile.d echo "# vagrant script for every boot" > /etc/profile.d/vagrant.sh echo export VBOX_HOST_NAME=freebsd64 >> /etc/profile.d/vagrant.sh echo export VBOX_FIXED_IP_ADDR=192.168.54.64 >> /etc/profile.d/vagrant.sh echo export PROXY_SERV_PORT=#{ENV['PROXY_SERV_PORT']} >> /etc/profile.d/vagrant.sh echo export PROXY_USER=#{ENV['PROXY_USER']} >> /etc/profile.d/vagrant.sh echo export PROXY_PASS=#{ENV['PROXY_PASS']} >> /etc/profile.d/vagrant.sh echo export PROXY_SKIP=#{ENV['PROXY_SKIP']} >> /etc/profile.d/vagrant.sh echo export http_proxy=#{ENV['http_proxy']} >> /etc/profile.d/vagrant.sh echo export https_proxy=#{ENV['https_proxy']} >> /etc/profile.d/vagrant.sh echo export no_proxy=#{ENV['no_proxy']} >> /etc/profile.d/vagrant.sh echo "export ADDITIONAL_ETC_HOSTS_1=\\"#{ENV['ADDITIONAL_ETC_HOSTS_1']}\\"" >> /etc/profile.d/vagrant.sh echo "export ADDITIONAL_ETC_HOSTS_2=\\"#{ENV['ADDITIONAL_ETC_HOSTS_2']}\\"" >> /etc/profile.d/vagrant.sh echo "export ADDITIONAL_ETC_HOSTS_3=\\"#{ENV['ADDITIONAL_ETC_HOSTS_3']}\\"" >> /etc/profile.d/vagrant.sh chmod +x /etc/profile.d/vagrant.sh SHELL # shell provisioner master1.vm.provision "shell", path: "setupscripts.sh" end end
■setupscripts.sh
セットアップスクリプトの中では追加ディスクをnewfsしたりzfs作ったりしている。
root(/)の容量が足りないので /usr とか /home とかは追加ディスクの中にコピーして使う。
#!/bin/sh set -e f_log() { echo "■ $(date) $@" } f_cmd_no_err() { if "$@" ; then echo -n "" else echo -n "" fi } f_log "環境変数読み込み" if [ -r /etc/profile.d/vagrant.sh ]; then . /etc/profile.d/vagrant.sh fi # IPアドレスのaliasを追加。 f_log "IPアドレスのaliasを追加" ifconfig em0 inet ${VBOX_FIXED_IP_ADDR}/24 alias # /etc/hosts設定 f_log "/etc/hosts設定" cat /etc/hosts | grep -v ${VBOX_HOST_NAME} > /etc/hosts.2 mv /etc/hosts.2 /etc/hosts echo "${VBOX_FIXED_IP_ADDR} ${VBOX_HOST_NAME}.hyperv.local ${VBOX_HOST_NAME}" >> /etc/hosts if [ ! -z "$ADDITIONAL_ETC_HOSTS_1" ]; then echo "$ADDITIONAL_ETC_HOSTS_1" >> /etc/hosts fi if [ ! -z "$ADDITIONAL_ETC_HOSTS_2" ]; then echo "$ADDITIONAL_ETC_HOSTS_2" >> /etc/hosts fi if [ ! -z "$ADDITIONAL_ETC_HOSTS_3" ]; then echo "$ADDITIONAL_ETC_HOSTS_3" >> /etc/hosts fi f_log "pkg アップデート" pkg update f_log "pkg アップグレード" pkg upgrade -y f_log "bashインストール" pkg install -y bash f_log "ansibleインストール py39-ansible" pkg install -y py39-ansible # ada1をufsでディスクをフォーマットして/newdiskとして使う(ada1) if true ; then if [ ! -d /newdisk ]; then f_log "fpart ada1 チェック" if gpart show ada1 | grep freebsd-ufs ; then f_log "gpart ada1 パーティション設定済み" else f_log "gpartディスク追加 ada1" # GPTを作成 gpart create -s GPT ada1 gpart show ada1 # ada1のほぼ全部をfreebsd-ufsで確保する gpart add -t freebsd-ufs -a 1M ada1 gpart show ada1 # ファイルシステムを作る newfs -U /dev/ada1p1 fi # マウントポイント作成 mkdir /newdisk # fstabに追記 echo "/dev/ada1p1 /newdisk ufs rw 2 2" >> /etc/fstab # マウント実行 mount /newdisk df -h fi fi # newdiskの中に /usr 以下と /home 以下をコピーしてそこを使う if true ; then if [ ! -d /newdisk/usr ] ; then mkdir -p /newdisk/usr OLD_PWD=$PWD cd /newdisk ( cd / ; tar cpf - usr ) | tar xpf - cd / /bin/mv /usr /usr.orig /bin/ln -sf /newdisk/usr /usr cd $OLD_PWD fi if [ ! -d /newdisk/home ] ; then mkdir -p /newdisk/home OLD_PWD=$PWD cd /newdisk ( cd / ; tar cpf - home ) | tar xpf - cd / /bin/mv /home /home.orig /bin/ln -sf /newdisk/home /home cd $OLD_PWD fi fi # ada2全体をzfsとして使用 (ada2) if true ; then if [ ! -d /zpool/rsync ]; then # zfs 有効化 echo 'zfs_enable="YES"' >> /etc/rc.conf # zfs service 開始 service zfs start # zpoolで1台のディスク ada2 全体を使用する echo "zpool create zpool /dev/ada2" zpool create zpool /dev/ada2 df -k zfs create zpool/vm zfs create zpool/rootdisk fi fi f_log "セットアップ完了" exit 0
emacs と wanderlust でメールを表示する
tag: emacs, wanderlust, mail, freebsd-13.2, freebsd
■ WanderLust のマニュアル
■ WanderLust のインストール
(require 'package) (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
■ WanderLust の設定
(autoload 'wl "wl" "Wanderlust" t)
# # Folder definition file # # IMAP folder %INBOX %INBOX.inbox2 %INBOX.trash # end of file.
(setq wl-from "Jun Obama <george@yk.rim.or.jp>") ;; デフォルトの接続先サーバを指定。 (setq elmo-imap4-default-server "localhost") (setq elmo-pop3-default-server "localhost") (setq wl-smtp-posting-server "localhost") (setq elmo-nntp-default-server "localhost") (setq wl-nntp-posting-server elmo-nntp-default-server) ;; 認証時の暗号化を設定。ここでは生パスワードを指定。 (setq elmo-imap4-default-authenticate-type 'clear) ; 生パスワード ;; aliasファイルの指定 (setq wl-alias-file "~/aliases")
■ WanderLust の起動
■ 参考文献
HashiCorp (terraformなど) 今後リリースする全製品のライセンスをBSL 1.1 に変更
tag: terraform, vagrant
MongoDBと同じライセンスにするようだ。
ARMORED CORE VI 購入
tag: game, armored-core-6
10年ぶりの祭りらしいので購入。
この手の難しいゲームはすぐ投げちゃうんだけどw
過去シリーズはやったことないけどゲームパッド(箱コン)でできるのだろうか? → パッドも選択できる様子。
今回はキーボードとマウスで遊んでみる。
チュートリアルのヘリってこれかw 10回近くやられたゾww
本編が始まってからのミッション2個くらいはボスとかでてこなくて普通。 ミッションクリア後、もう1回やってみたら報酬も出た。(無限に金策はできないだろうが...。→できるらしい) これでやっとパーツが買える。
p.s.
まだ1章の壁超えを通過したあたり。