Skip to main content

· 4 min read
wen

Background

在 civitai 上看到 DivineEleganceMix 模型 生成的图片,感觉很美,

就想尝试用 Stable Diffusion WebUI 重现一下。(为了方便描述,以下用 WebUI 代替 Stable Diffusion WebUI )

img

过程

1. 获取 prompt 和参数

Prompts 等参数可以在 这个页面 点击 Copy Generation data 复制得到。

(masterpiece, best quality:1.2), (face focus:1.4), back focus, from behind, blonde hair, long hair, high ponytail, long ponytail, red eyes, long eyelashes, thick eyelashes, looking at viewer, red dress, backless dress, gold trim dress, puffy sleeves, juliet sleeves, long sleeves, red sleeves, (black background:1.2), light particles, blurry, bloom, shiny hair, <lora:Add Detail:0.5>
Negative prompt: (EasyNegative:0.8), (worst quality, low quality:1.2),
(from below:1.2), (ass:1.2), collar, tight, skin tight, impossible clothes, bangs, off shoulder, frills, white sleeves, red background, yellow sleeves,
Steps: 30, VAE: kl-f8-anime2.vae.pt, Size: 512x768, Seed: 3842746991, Model: DivineEleganceMix8, "Module: canny, Sampler: Euler a, VAE hash: df3c506e51, CFG scale: 8, Clip skip: 2, Model hash: 4dbe20030f, ADetailer model: face_yolov8n.pt, ADetailer steps: 30, ADetailer sampler: Euler a, ADetailer version: 23.10.1, Denoising strength: 0.3, ADetailer CFG scale: 8.0, ADetailer CLIP skip: 2, ADetailer mask blur: 16, ADetailer confidence: 0.3, ADetailer dilate/erode: 32, ADetailer inpaint width: 768, ADetailer inpaint height: 768, ADetailer inpaint padding: 32, ADetailer mask merge/invert: Merge, ADetailer denoising strength: 0.3, ADetailer use separate steps: True, ADetailer inpaint only masked: True, ADetailer use separate sampler: True, ADetailer use separate CFG scale: True, ADetailer use separate CLIP skip: True, ADetailer use inpaint width/height: True

2. 安装插件

Generation data 中提到了 VAE: kl-f8-anime2.vae.ptAdetailer 插件,需要先安装。

2.1 安装 VAE:kl-f8-anime2.vae.pt

在 HuggingFace 上找到了 kl-f8-anime2.vae.pt , 下载到本地放到 stable-diffusion-webui/models/VAE/ 里面。

stable-diffusion-webui 默认没有启用 VAE,需要手动启用。

如下图所示,在 stable-diffusion-webui 的 Settings 页面,点击 1️⃣ → 2️⃣ , 添加 sd_vae 后,

点击 Apply settingsReload UI

img

如下图所示,刷新界面后就出现了 1️⃣ SD VAE 选项, 选择我们之前下载的 kl-f8-anime2.ckpt

img

2.2 安装 Adetailer

到 stable-diffusion-webui 的 Extensions 页面,

按照 [Adetailer](https://github.com/Bing-su/adetailer) 的说明安装。

3. 导入参数

如下图所示,在 WebUItxt2img 页面,点击 1️⃣ 的箭头按钮,粘贴 prompt。

然后点击 2️⃣ 的箭头按钮,在弹出窗口中点击 3️⃣ 按钮粘贴参数。

img img

有些参数好像不能直接粘贴,需要手动修改一下。

比如 Height, ADetailerEnable 选项等。

4. 生成图片

还不错,不过和模型作者的图片好像还是有差距,可能有些设置没改好,有时间再看看。 img

  • 修改了下眼睛部分的 prompt,效果好了点。 img

Appendix

  • ADetailer 的作用是什么?

    • ADetailer 是一个插件,对模型生成的图片中的手部(比如 6 手指问题)、脸部的变形等问题进行处理,使得生成的图片更加真实。
  • 为什么要用 VAE?

Reference

WebUI の拡張機能で 手軽に CivitAI のモデルを利用する

· 3 min read
wen

Background

之前试了 Diffusers 等软件,生成的图片都不太理想(甚至难看 😸 ),

有些甚至不能选择模型,UI 也不太好用。

所以这次试试 Stable Diffusion WebUI,据说他的 UI 很好用。

我的环境

我的环境是 MacBook Pro M2 Pro。

$ system_profiler SPHardwareDataType

Hardware Overview:
Model Name: MacBook Pro
Chip: Apple M2 Pro
Total Number of Cores: 12 (8 performance and 4 efficiency)
Memory: 16 GB

安装方法&运行

安装方法很简单,具体看Github 的 readme

brew install cmake protobuf rust [email protected] git wget # install dependencies
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui # clone the repo
cd stable-diffusion-webui # enter the directory
./weiui.sh # start the app

脚本运行后,会自动打开一个网页。

如果没有自动打开,可以手动打开 http://127.0.0.1:7860/ , 就可以看到界面了。

使用方法

下载模型

tip

默认提供一个模型 Stable Diffusion v1-5-pruned-emaonly.safetensors,效果惨不忍睹。

建议直接从 Hugging Face 或者 Civitai 下载。

不相信我提示的可以点击这里看看😄
  • 例 1: Prompts: a little boy playing with a puppy img

  • 例 2: Prompts: 1girl,face,white background img

  • 例 3: Prompts: 1girl,face,white background

  • Negative Prompts: (worst quality:2),(low quality:2),(normal quality:2),lowres,watermark img

我从 Civitai 下载了一个比较有人气的模型 majicMIX realistic, 再用之前的 prompt 试了试,效果比默认的模型好太多了 😄。

生成结果

  • Prompts: 1girl,face,white background img

  • Prompts: 1girl,face,white background

    Negative Prompts: (worst quality:2),(low quality:2),(normal quality:2),lowres,watermark img

tip

Negative Prompts : 用来指定不想要的图片特征,比如 lowres 代表不想要低分辨率的图片。

Reference

Stable Diffusion モデルの探し方

Stable Diffusion WebUI のおすすめモデル 10 選をご紹介!導入方法も解説

· One min read
wen

背景

刚加入新公司,接手了一个项目,什么资料也没有。 🥲

想要了解这个项目,一个比较直接的办法就是先看看数据库的 ER 图,手动画图太麻烦,

Google 了下, 发现可以用 JetBrainsDataGrip 来导出 ER 图。

步骤

1. Connect to database

1️⃣. Click + button in the left panel

2️⃣. Select Data Source -> MySQL(or other database)

3️⃣. Fill in the your database information

img

2. Show diagram

1️⃣. Right click the database you want to show

2️⃣ 3️⃣. Select Diagram -> Show Diagram

4️⃣. Then you will see the ER diagram

img

扩展

DataGrip 还有很多功能,比如可以直接在里面写 SQL,还可以直接导出 SQL Script,等等。

点击这里查看更多功能。

· One min read
wen

背景

Diffuses Apphuggingface 推出的一个 App。

结论

以下基于 Version 1.1 (20230222.140932) 进行介绍.

先说结论,让它画猫画狗可能还行,画人就惨不忍睹了。😄

而且除了默认提供的 5 个模型(选择后会自动下载),不能加载其他模型。

一些生成结果

画狗

  • Prompt: Labrador in the style of Vermeer
  • Model: stabilityai/stable-diffusion-2-base

img

画人

danger

下面的图片有点恐怖哦。。。 😨 而且我都是我重复多次,选相对好的结果。

  • Prompt: Japanese beauty
  • Model: stabilityai/stable-diffusion-2-base

img

  • Prompt: Chinese beauty
  • Model: stabilityai/stable-diffusion-2-base

img

  • Prompt: Korean beauty
  • Model: stabilityai/stable-diffusion-2-base

img

  • Prompt: American beauty
  • Model: stabilityai/stable-diffusion-2-base

img

· 2 min read
wen

Update Docusaurus to v3

Docuaurus v3 has been released, here is the migration guide provided by the official.

I record the upgrade process here that may help you save some time. 😄

Upgrade dependencies

  • docusaurus.config.js
docusaurus.config.js

-const lightCodeTheme = require('prism-react-renderer/themes/github');
-const darkCodeTheme = require('prism-react-renderer/themes/dracula');
+const { themes } = require('prism-react-renderer');
+const lightTheme = themes.github;
+const darkTheme = themes.dracula;

prism: {
- theme: lightCodeTheme,
- darkTheme: darkCodeTheme,
+ theme: lightTheme,
+ darkTheme: darkTheme,
},

  • package.json
package.json
   "dependencies": {
- "@docusaurus/core": "2.4.3",
- "@docusaurus/preset-classic": "2.4.3",
- "@docusaurus/theme-mermaid": "^2.4.3",
- "@mdx-js/react": "^1.6.22",
+ "@docusaurus/core": "3.0.0",
+ "@docusaurus/preset-classic": "3.0.0",
+ "@docusaurus/theme-mermaid": "^3.0.0",
+ "@mdx-js/react": "^3.0.0",
"clsx": "^1.2.1",
- "prism-react-renderer": "^1.3.5",
- "react": "^17.0.2",
- "react-dom": "^17.0.2"
+ "prism-react-renderer": "^2.1.0",
+ "react": "^18.2.0",
+ "react-dom": "^18.2.0"
},
"devDependencies": {
- "@docusaurus/module-type-aliases": "2.4.3"
+ "@docusaurus/module-type-aliases": "3.0.0",
+ "@docusaurus/types": "3.0.0"
},


"engines": {
- "node": ">=16.14"
+ "node": ">=18.0"
}

Reinstall dependencies

Remove the node_modules directory and package-lock.json file, then reinstall the dependencies.

npm install

Check if mx/mdx files compiles under MDX v3

Use the following command to check if mx/mdx files compiles under MDX v3.

npx docusaurus-mdx-checker

For example, I got a check error after upgrated to v3:

  • Before Modified
<details><summary>xxx</summary>
...
</details>
  • After Modified
<details>
<summary>xxx</summary>
...
</details>

· One min read
wen

git commit --amend --no-edit

When you think you have fixed an issue, but you were not able to fix it completely in one go (perhaps there were just some typos);

OR

When you really have fixed an issue, but you forgot to add some files,

You can use this:

git add .
git commit --amend --no-edit # --no-edit 选项表示不修改 commit message。
git push -f # 如果你已经 push 过了,需要添加 -f 来强制 push。
note

Maybe I just wrote this article to experience the gitGraph feature of mermaidjs 😄.

And BTW the commit message of gitGraph is rotated by default.

If you want to change it to horizontal, you need to add the following configuration in docusaurus.config.js:

+      mermaid: {
+ options: {
+ gitGraph: { rotateCommitLabel: false },
+ },
+ },

· 5 min read
wen

刚过了不惑之年,有点感伤,碰巧听到这首歌,很有感触。

是不是该写封信给 10 年后的自己呢?😀

LRC 歌词:

曲名 : letter song (10年後の私へ)
作词 : doriko
作曲 : doriko
好きな人と歩いた場所も (曾和喜欢的人一起走过的地方)
その時見た景色も (那时曾看到的景色)
振り返らず 今を駆け抜け (统统抛掉 不再回头 向前飞奔)
私は何と出会うの (我将会遇见些什么呢)
立ち止まるほど (驻足不前)
意味を問うほど (探索意义)
きっとまだ大人ではなくて (一定是我还不够成熟)
今見てるもの (现在看到的事物)
今出会う人 (现在遇见的人)
その中でただ前だけを見てる (在这片纷繁喧嚣之中 我只会看向前方)
10年後の私へ (致十年以后的我)
今は幸せでしょうか (现在的你感到幸福么?)
それとも悲しみで (还是正沉浸在悲伤中)
泣いているのでしょうか (默默地流着泪?)
けどあなたの傍に (不过在你的身旁)
変わらないものがあり (依然会有不变的存在)
気付いていないだけで (未能察觉的你)
守られていませんか (依然在被守护着吧)
過ぎし日々に 想いを預け (把思念寄托于流逝的日子里)
時間だけ ただ追いかけてく (只有时间在不停的追赶)
背に寄り添った 誰かの夢に (托付在我肩上的 是谁的梦想)
振り向ける日がいつか来るのかな (总有一天必须要面对的吧)
10年後の私へ (致十年以后的我)
今は誰を好きですか (现在的你喜欢着谁呢?)
それとも変わらずに (还是和以前一样)
あの人が好きですか (继续喜欢着那个人呢?)
けどいつか (不过 现在的你)
知らない誰かを愛する前に (在爱上某个人之前)
自分のことを好きと (“喜欢自己”这句话)
言えるようになりましたか (能否先说出来呢)
大切な人たちは (我所珍爱的朋友们)
今も変わらずいますか (依然在反复平凡地生活吗?)
それとも遠く離れ (还是已经远去)
それぞれ歩んでますか (踏上了各自的旅途)
けど そんな出会いを (但是在重复了无数次的相遇)
别れを 缲り返して (和离别之后)
今の私よりも (是否比现在的我)
すてきになっていますか (更有魅力呢?)
10年後の私へ (致十年后的我)
今がもし幸せなら (如果现在的你是幸福的)
あの日の私のこと (从前的我)
思い出してくれますか (能否请你想起来呢)
そこにはつらいことに (回忆中的我)
泣いた私がいるけど (一定在伤心的哭泣吧)
その涙を優しく (请将这眼泪温柔地)
思い出に変えてください (融入记忆的海洋)

· 3 min read
wen

0. Background

When changing computers, you need to migrate some configuration files from the old computer to the new one, such as .zshrc, .vimrc, .gitconfig, and so on.

Some files may not necessarily be located in the home directory, such as .ssh/config, .config/.starship.yaml. It's a bit of a hassle to migrate these files manually.

Therefore, you need a tool to manage these configuration files.

1. Requirements

  • Support multiple platforms, such as macOS, Linux, Windows.
  • Support version management, such as git.
  • Support templates.

I did a little research and found that there are several tools that can manage dotfiles:

  • chezmoi
    • Golang written
    • Github Star 10.2k
  • dotbot
    • Python written
    • Github Star 6.5k

chezmoi meets my requirements, and it's written in Golang without any dependencies, so I decided to use chezmoi.

2. Install

sh -c "$(curl -fsLS get.chezmoi.io)"

You could find more installation methods here

3. Usage

3.1 Initialize

tip

After initialization, a ~/.local/share/chezmoi directory (local repository) will be generated in the home directory to store chezmoi configuration files. You can enter the directory with the chezmoi cd command.

3.2 Add files

3.3 Update files

tip

After updating the file, remember to commit to the remote repository. You can refer to the previous section.

3.4 Fetch files from remote repository

Fetch files from remote repository and apply them.

chezmoi update

It's equivalent to

chezmoi git pull origin main
chezmoi apply

3.5 Extend usage

3.5.1 Templating

chezmoi supports templates,which can generate different configuration files for different hosts and so on.

For example, I want to configure different account names for different computers, I can do this:

  • Create ~/.account.json file, the content is as follows:
~/.account.json
{
"name": "thewang"
}
  • Configure the data field in ~/.config/chezmoi/chezmoi.toml.
~/.config/chezmoi/chezmoi.toml
[data]
name = "thewang"
  • Add file with --autotemplate flag.
chezmoi add --autotemplate ~/.account.json

{
"name": "{{ .name }}"
}

· 3 min read
wen

0. Background

I have been using the snippet feature of Alfred 3, but the Alfred snippet feature is paid.

Recently, I discovered Raycast, where the Raycast snippet feature is free and open-source, allowing for personal customization.

Therefore, I plan to migrate my Alfred snippets to Raycast.

1. Migrate Alfred Snippets to Raycast

The format of Alfred's snippet files differs from that of Raycast's snippet files. Hence, it is necessary to first convert Alfred's snippet files to Raycast's snippet files.

1.1 Get Alfred Snippets Files

Open the Snippets feature in Alfred, click the Export button to export the Alfred snippets. Since collections in Alfred 3 do not support bulk export, they need to be exported one by one. 🐶

img

1.2 Convert Alfred Snippets to Raycast Snippets

Create a new folder and place the exported Alfred snippet files in it.

Then, create a file named convert-alfred-snippets-to-raycast-snippets.sh in this folder, with the following content:

convert-alfred-snippets-to-raycast-snippets.sh
#!/bin/sh -e
# Script for converting Alfred snippets to Raycast snippets
# Usage: chmod +x convert-alfred-snippets-to-raycast-snippets.sh; ./convert-alfred-snippets-to-raycast-snippets.sh
# NOTE: Install jq before running this script

# List up all *.alfredsnippets files and rename them to *.zip
for file in *.alfredsnippets; do
mv "$file" "${file%.alfredsnippets}.zip"
done

# Unzip all *.zip files and get the folders name
for file in *.zip; do
unzip -o "$file" # -o: overwrite existing files without prompting
done


# Merge all *.json files to one file for Raycast snippets
jq -s 'map(.alfredsnippet | {name, keyword, text: .snippet})' *.json > ./output.json

# Clean up all files except output.json
for file in *.json; do
if [ "$file" = "output.json" ]; then
continue
fi
rm "$file"
done

for file in *.zip; do
rm "$file"
done

for file in *.plist; do
rm "$file"
done

# You can now import the output.json file to Raycast

echo "Done! 🎉 You can now import the output.json file to Raycast -> Import Snippets"

OR download from Github gist: convert-alfred-snippets-to-raycast-snippets.sh

note

To execute this script, you need to install jq, which is a command-line JSON processor tool.

For Mac, you can install jq using Homebrew with the command: brew install jq. You can also refer to the official website for more installation options.

Run the following command:

chmod +x convert-alfred-snippets-to-raycast-snippets.sh
./convert-alfred-snippets-to-raycast-snippets.sh

An output.json file will be generated in the current directory.

1.3 Import Raycast Snippets

Open Raycast, then click on Import Snippets. Choose the output.json file generated in the previous step to import the snippets into Raycast.

Reference

Migrating Alfred Snippets to Raycast