mental diffusion
1.0.0
PEMBERITAHUAN : Eksperimen sudah berakhir dan repositori ini adalah untuk tujuan pembelajaran.
CLI difusi yang stabil cepat
| Mdx | 0.9.5 |
|---|---|
| Python | 3.11 - 3.12 |
| Obor | +CU121 |
| Diffuser | 0.30.2 |
| + Gradio | 4.42.0 |
Skrip mdx.py diuji stabil.
- Paket Python 3,5 GB (diekstraksi 5,5 GB)
- Kompatibel dengan sebagian besar venvs python berbasis diffuser
- Pastikan Anda memiliki partisi swap atau file swap
git clone https://github.com/nimadez/mental-diffusion
cd mental-diffusion
# Automatic installation:
sudo apt install python3-pip python3-venv
sh install-venv.sh
# Manual installation:
python3 -m venv ~/.venv/mdx
source ~/.venv/mdx/bin/activate
pip install torch torchvision --extra-index-url https://download.pytorch.org/whl/cu121
pip install -r ./requirements.txt
deactivate
Instal Gradio dan Zenity untuk antarmuka pengguna:
~/.venv/mdx/bin/python3 -m pip install gradio==4.42.0
sudo apt install zenity
* Zenity: If you don't have a GNOME desktop, you can't use the file dialog to select .safetensors files, you have to enter the Checkpoint, LoRA and VAE path manually.
~/.venv/mdx/bin/python3 mdx.py --help
--type -t str sd, xl (def: custom)
--checkpoint -c str /checkpoint.safetensors (def: custom)
--scheduler -sc str ddim, ddpm, euler, eulera, lcm, lms, pndm (def: custom)
--prompt -p str positive prompt
--negative -n str negative prompt
--width -w int divisible by 8 (def: custom)
--height -h int divisible by 8 (def: custom)
--seed -s int -1 randomize (def: -1)
--steps -st int 1 to 100+ (def: 24)
--guidance -g float 0 - 20.0+ (def: 8.0)
--strength -sr float 0 - 1.0 (def: 1.0)
--lorascale -ls float 0 - 1.0 (def: 1.0)
--image -i str /image.png
--mask -m str /mask.png
--vae -v str /vae.safetensors
--lora -l str /lora.safetensors
--filename -f str filename prefix without .png extension, add {seed} to be replaced (def: img_{seed})
--output -o str image and preview output directory (def: custom)
--number -no int number of images to generate per prompt (def: 1)
--batch -b int number of repeats to run in batch, --seed -1 to randomize
--preview -pv stepping is slower with preview enabled (def: no preview)
--lowvram -lv slower if you have enough VRAM, automatic on 4GB cards (def: no lowvram)
--metadata -meta str /image.png, extract metadata from png
[automatic pipeline]
Txt2Img: no --image and no --mask
Img2Img: --image and no --mask
Inpaint: --image and --mask
ERROR: no --image and --mask
Default: mdx -p "prompt" -st 28 -g 7.5
SD: mdx -t sd -c /checkpoint.safetensors -w 512 -h 512
SDXL: mdx -t xl -c /checkpoint.safetensors -w 768 -h 768
Img2Img: mdx -i /image.png -sr 0.5
Inpaint: mdx -i /image.png -m ./mask.png
VAE: mdx -v /vae.safetensors
LoRA: mdx -l /lora.safetensors -ls 0.5
Filename: mdx -f img_test_{seed}
Output: mdx -o /home/user/.mdx
Number: mdx -no 4
Batch: mdx -b 10
Preview: mdx -pv
Low VRAM: mdx -lv
Metadata: mdx -meta ./image.png
mdx-upscale --help
mdx-upscale -i ./image.png
mdx-upscale -i ./image.png -m x2
mdx-upscale -i ./image.png -m x4 -o ~/Downloads
~/.venv/mdx/bin/python3 src/mdx-ui.py
sh mdx-ui
sh mdx-ui-dev # development mode (auto reload)
open http://localhost:8011

Impor Kelas MDX ke Inferensi dari Data JSON
from mdx import MDX
data = json.loads(data)
data["prompt"] = "new prompt"
parser = argparse.ArgumentParser()
args = parser.parse_args(namespace=argparse.Namespace(**data))
MDX().main(args)
Inferensi dapat terganggu dengan membuat file bernama ". Interrupt" di direktori -output. (misalnya mdx-ui.py)
* Enable OFFLINE if you have already downloaded the huggingface cache
* Enable SAVE_ANIM to save the preview animation to {output}/filename.webp
* Model may be slow to load on first launch, but reloading SDXL with 4GB only takes a second
Preview, cancel, and repeat faster:
mdx -p "prompt" -g 8.0 -st 30 -pv
mdx -p "prompt" -g 8.0 -st 30 -s 827362763262387
Content-aware upscaling: (ImageMagick)
mdx -p "prompt" -st 20 -w 512 -h 512 -f image
magick convert ~/.mdx/image.png -resize 200% ~/.mdx/image_up.png
mdx -p "prompt" -st 20 -i ~/.mdx/image_up.png -sr 0.5
Generate 40 images in less time:
mdx -p "prompt" -b 10 -no 4
Extract images from WebP animation: (ImageMagick)
magick convert image.webp jpg
Explore output directory in a browser across the LAN:
cd ~/.mdx && python3 -m http.server 8000
$ open http://192.168.x.x:8000
Download huggingface cache in a specific path:
mkdir ~/.hfcache && ln -s ~/.hfcache ~/.cache/huggingface

- Antarmuka dan server baris perintah warisan (diffuser)
- Jembatan comfyui untuk ekstensi kode vs
↑ Add Gradio user-interface
↑ Rewritten in 300 lines
↑ Port to Linux
↑ Back to Diffusers
↑ Port to Code (webui)
↑ Change to ComfyUI API (webui)
↑ Created for personal use (diffusers)
"AI will bring us back to the age of terminals."
Kode yang dirilis di bawah lisensi MIT.