What's new

Stable Diffusion AI: Options to run using CPU-only to Low GPU specs, Android, etc. Part2

alist1986

Forum Veteran
Elite
Joined
Oct 20, 2014
Posts
3,229
Solutions
5
Reaction
3,474
Points
984
Note: This is just a continuation of You do not have permission to view the full content of this post. Log in or register now. for my AI ART Generator for cpu and portable device (and as part of req't for being "Established" he he). These apps require knowledge in running them using provided code and guides on Github. If installers are provided, then its the responsibility of the user to find other resources connected to the software. run at your own risks and read carefully the instructions.
I'm more concentrated on testing Stable Diffusion since it's opensource and have a lot of branches and developments using different modes of use
to try on CPU-mode and portable devices. I'll just provide those that worked for me for others to try on their end. For guides to use Stable diffusion, please refer You do not have permission to view the full content of this post. Log in or register now..

No silly questions please. This is for those who know how to follow instructions and use them for FREE.
======================================================================================================================

1.
1692782662735.png

Multimodal Advanced, Generative, and Intelligent Creation (MMagic [em'mædʒɪk]) : You do not have permission to view the full content of this post. Log in or register now.

What's New You do not have permission to view the full content of this post. Log in or register now.

New release You do not have permission to view the full content of this post. Log in or register now. [26/05/2023]:​

  • Support tomesd for StableDiffusion speed-up.
  • Support all inpainting/matting/image restoration models inferencer.
  • Support animated drawings.
  • Support Style-Based Global Appearance Flow for Virtual Try-On.
  • Fix inferencer in pip-install.
We are excited to announce the release of MMagic v1.0.0 that inherits from MMEditing and MMGeneration.

After iterative updates with OpenMMLab 2.0 framework and merged with MMGeneration, MMEditing has become a powerful tool that supports low-level algorithms based on both GAN and CNN. Today, MMEditing embraces Generative AI and transforms into a more advanced and comprehensive AIGC toolkit: MMagic (Multimodal Advanced, Generative, and Intelligent Creation). MMagic will provide more agile and flexible experimental support for researchers and AIGC enthusiasts, and help you on your AIGC exploration journey.

We highlight the following new features.

1. New Models

We support 11 new models in 4 new tasks.

  • Text2Image / Diffusion
    • ControlNet
    • DreamBooth
    • Stable Diffusion
    • Disco Diffusion
    • GLIDE
    • Guided Diffusion
  • 3D-aware Generation
    • EG3D
  • Image Restoration
    • NAFNet
    • Restormer
    • SwinIR
  • Image Colorization
    • InstColorization
2. Magic Diffusion Model

For the Diffusion Model, we provide the following "magic" :

  • Support image generation based on Stable Diffusion and Disco Diffusion.
  • Support Finetune methods such as Dreambooth and DreamBooth LoRA.
  • Support controllability in text-to-image generation using ControlNet.
  • Support acceleration and optimization strategies based on xFormers to improve training and inference efficiency.
  • Support video generation based on MultiFrame Render.
  • Support calling basic models and sampling strategies through DiffuserWrapper.
3. Upgraded Framework

By using MMEngine and MMCV of OpenMMLab 2.0 framework, MMagic has upgraded in the following new features:

  • Refactor DataSample to support the combination and splitting of batch dimensions.
  • Refactor DataPreprocessor and unify the data format for various tasks during training and inference.
  • Refactor MultiValLoop and MultiTestLoop, supporting the evaluation of both generation-type metrics (e.g. FID) and reconstruction-type metrics (e.g. SSIM), and supporting the evaluation of multiple datasets at once.
  • Support visualization on local files or using tensorboard and wandb.
  • Support for 33+ algorithms accelerated by Pytorch 2.0.
MMagic has supported all the tasks, models, metrics, and losses in MMEditing and MMGeneration and unifies interfaces of all components based on MMEngine.
Please refer to changelog.md for details and release history.

Please refer to migration documents to migrate from old version MMEditing 0.x to new version MMagic 1.x .

📖 Introduction​

MMagic (Multimodal Advanced, Generative, and Intelligent Creation) is an advanced and comprehensive AIGC toolkit that inherits from MMEditing and MMGeneration. It is an open-source image and video editing&generating toolbox based on PyTorch. It is a part of the OpenMMLab project.

Currently, MMagic support multiple image and video generation/editing tasks.

mmagic_introduction.mp4
The best practice on our main branch works with Python 3.8+ and PyTorch 1.9+.

Major features​

  • State of the Art Models
    MMagic provides state-of-the-art generative models to process, edit and synthesize images and videos.
  • Powerful and Popular Applications
    MMagic supports popular and contemporary image restoration, text-to-image, 3D-aware generation, inpainting, matting, super-resolution and generation applications. Specifically, MMagic supports fine-tuning for stable diffusion and many exciting diffusion's application such as ControlNet Animation with SAM. MMagic also supports GAN interpolation, GAN projection, GAN manipulations and many other popular GAN’s applications. It’s time to begin your AIGC exploration journey!
  • Efficient Framework
    By using MMEngine and MMCV of OpenMMLab 2.0 framework, MMagic decompose the editing framework into different modules and one can easily construct a customized editor framework by combining different modules. We can define the training process just like playing with Legos and provide rich components and strategies. In MMagic, you can complete controls on the training process with different levels of APIs. With the support of MMSeparateDistributedDataParallel, distributed training for dynamic architectures can be easily implemented

Contributing​

More and more community contributors are joining us to make our repo better. Some recent projects are contributed by the community including:

  • GLIDE is contributed by @Taited.
  • Restormer is contributed by @AlexZou14.
  • SwinIR is contributed by @Zdafeng.
Projects is opened to make it easier for everyone to add projects to MMagic.

We appreciate all contributions to improve MMagic. Please refer to CONTRIBUTING.md in MMCV and CONTRIBUTING.md in MMEngine for more details about the contributing guideline.

Installation​

MMagic depends on PyTorch, MMEngine and MMCV. Below are quick steps for installation.

Step 1. Install PyTorch following official instructions.

Step 2. Install MMCV, MMEngine and MMagic with MIM.

pip3 install openmim
mim install 'mmcv>=2.0.0'
mim install 'mmengine'
mim install 'mmagic'

Step 3. Verify MMagic has been successfully installed.

cd ~
python -c "import mmagic; print(mmagic.version)"
# Example output: 1.0.0

Getting Started

After installing MMagic successfully, now you are able to play with MMagic! To generate an image from text, you only need several lines of codes by MMagic!

from mmagic.apis import MMagicInferencer
sd_inferencer = MMagicInferencer(model_name='stable_diffusion')
text_prompts = 'A panda is having dinner at KFC'
result_out_dir = 'output/sd_res.png'
sd_inferencer.infer(text=text_prompts, result_out_dir=result_out_dir)

Please see quick run and inference for the basic usage of MMagic.

Install MMagic from source

You can also experiment on the latest developed version rather than the stable release by installing MMagic from source with the following commands:

git clone You do not have permission to view the full content of this post. Log in or register now.
cd mmagic
pip3 install -e .

Please refer to installation for more detailed instruction.

🤝 Acknowledgement​

MMagic is an open source project that is contributed by researchers and engineers from various colleges and companies. We wish that the toolbox and benchmark could serve the growing research community by providing a flexible toolkit to reimplement existing methods and develop their own new methods.

We appreciate all the contributors who implement their methods or add new features, as well as users who give valuable feedbacks. Thank you all!
==========================================================================
Please read there detailed documention You do not have permission to view the full content of this post. Log in or register now. for for further details.
(Following the provided guide sa github link wasn't easy, so read the documentation to clear out some issues. But it works fine on cpu-mode on my end. It's a multi-tool, so try other features later.)
2. If number#1 is hard to install and run in your end, better switch to the one I mentioned in Part 1.
Stable Diffusion-NCNN: You do not have permission to view the full content of this post. Log in or register now.
Stable-Diffusion implemented by You do not have permission to view the full content of this post. Log in or register now. framework based on C++, supported txt2img and img2img!

Zhihu: You do not have permission to view the full content of this post. Log in or register now.

Video: You do not have permission to view the full content of this post. Log in or register now.

txt2img Performance (time pre-it and ram)

per-iti7-12700 (512x512)i7-12700 (256x256)Snapdragon865 (256x256)
slow4.85s/5.24G(7.07G)1.05s/3.58G(4.02G)1.6s/2.2G(2.6G)
fast2.85s/9.47G(11.29G)0.65s/5.76G(6.20G)

News​

2023-03-11: happy to add img2img android and release new apk

2023-03-10: happy to add img2img x86

2023-01-19: speed up & less ram in x86, dynamic shape in x86

2023-01-12: update to the latest ncnn code and use optimize model, update android, add memory monitor

2023-01-05: add 256x256 model to x86 project

2023-01-04: merge and finish the mha op in x86, enable fast gelu

Demo​

You do not have permission to view the full content of this post. Log in or register now.

You do not have permission to view the full content of this post. Log in or register now.

Out of box​

All models and exe file you can download from You do not have permission to view the full content of this post. Log in or register now. or You do not have permission to view the full content of this post. Log in or register now. or Release

If you only need ncnn model, you can search it from You do not have permission to view the full content of this post. Log in or register now., it would be more faster and free.

x86 Windows​

  1. enter folder You do not have permission to view the full content of this post. Log in or register now.
  2. download 4 bin file: AutoencoderKL-fp16.bin, FrozenCLIPEmbedder-fp16.bin, UNetModel-MHA-fp16.bin, AutoencoderKL-encoder-512-512-fp16.bin and put them to assets folder
  3. set up your config in magic.txt, each line are:
    1. height (must be a multiple of 128, minimum is 256)
    2. width (must be a multiple of 128, minimum is 256)
    3. speed mode (0 is slow but low ram, 1 is fast but high ram)
    4. step number (15 is not bad)
    5. seed number (set 0 to be random)
    6. init image (if the file is exist, run img2img, if not, run txt2img)
    7. positive prompt (describe what you want)
    8. negative prompt (describe what you don't want)
  4. run stable-diffusion.exe

android apk​

  1. download an install the apk from the link
  2. in the top, the first one is step and the second one is seed
  3. int the bottom, the top one the positive prompt and the bottom one negative prompt (set empty to enable the default prompt)
  4. note: the apk needs 7G ram, and run very slow and power consumption

Implementation Details​

Note: Please comply with the requirements of the SD model and do not use it for îllégâl purposes

  1. Three main steps of Stable-Diffusion:
    1. CLIP: text-embedding
    2. (only img2img) encode the init image to init latent
    3. iterative sampling with sampler
    4. decode the sampler results to obtain output images
  2. Model details:
    1. Weights:Naifu (u know where to find)
    2. Sampler:Euler ancestral (k-diffusion version)
    3. Resolution:dynamic shape, but must be a multiple of 128, minimum is 256
    4. Denoiser:CFGDenoiser, CompVisDenoiser
    5. Prompt:positive & negative, both supported :)

Code Details​

Complie for x86 Windows​

  1. download 4 bin file: AutoencoderKL-fp16.bin, FrozenCLIPEmbedder-fp16.bin, UNetModel-MHA-fp16.bin, AutoencoderKL-encoder-512-512-fp16.bin and put them to assets folder
  2. open the vs2019 project and compile the release&x64

Complie for x86 Linux / MacOS​

  1. You do not have permission to view the full content of this post. Log in or register now.
  2. build the demo with CMake
cd x86/linux
mkdir -p build && cd build
cmake ..
make -j$(nproc)

  1. download 3 bin file: AutoencoderKL-fp16.bin, FrozenCLIPEmbedder-fp16.bin, UNetModel-MHA-fp16.bin and put them to build/assets folder
  2. run the demo
./stable-diffusion-ncnn

Compile for android​

  1. download three bin file: AutoencoderKL-fp16.bin, FrozenCLIPEmbedder-fp16.bin, UNetModel-MHA-fp16.bin and put them to assets folder
  2. open android studio and run the project

ONNX Model​

I've uploaded the three onnx models used by Stable-Diffusion, so that you can do some interesting work.

You can find them from the link above.

Statements​

  1. Please abide by the agreement of the stable diffusion model consciously, and DO NOT use it for îllégâl purposes!
  2. If you use these onnx models to make open source projects, please inform me and I'll follow and look forward for your next great work :)

Instructions​

  1. FrozenCLIPEmbedder
ncnn (input & output): token, multiplier, cond, conds
onnx (input & output): onnx::Reshape_0, 2271

z = onnx(onnx::Reshape_0=token)
origin_mean = z.mean()
z *= multiplier
new_mean = z.mean()
z *= origin_mean / new_mean
conds = torch.concat([cond,z], dim=-2)

  1. UNetModel
ncnn (input & output): in0, in1, in2, c_in, c_out, outout
onnx (input & output): x, t, cc, out

outout = in0 + onnx(x=in0 * c_in, t=in1, cc=in2) * c_out
Di siya naglalayo sa project na ito: You do not have permission to view the full content of this post. Log in or register now.
Parehas silang ok sa cpu-mode din. Check ninyo na lang yung android mode na supplied dyan kay EdVince. Pang-anime lang ang models na gamit sa UI. Nasa inyo na lang kung merong makuha sa You do not have permission to view the full content of this post. Log in or register now. na iba.
 

Attachments

Last edited:
3. OnnxDiffusersUI : You do not have permission to view the full content of this post. Log in or register now.

(May 2023) Deprecation Notice​

This repo is no longer maintained and is out of date. Please check this fork of webui from lshqqytiger: You do not have permission to view the full content of this post. Log in or register now.

I’ve been helping people setup Stable Diffusion and run it on their AMD graphics card (or CPU) on Windows. I’ve also wrote a basic UI for the diffusers library version to make it more user friendly. This guide is a consolidation of what I’ve learned and hopefully will help other people setup their PC to run Stable Diffusion too.

The intent of this UI is to get people started running Stable Diffusion on Windows. As such this UI won't be as feature rich as other UI, nor will it be as fast as running Stable Diffusion on Linux and ROCm.

Example screenshot:
You do not have permission to view the full content of this post. Log in or register now.

Credits​

A lot of this document is based on other guides. I've listed them below:


Prerequisites​

You'll need to have a few things prepared first:

  • Install Python 3.10: You do not have permission to view the full content of this post. Log in or register now.
    • NOTE: don't install the version of Python from the Microsoft Store
    • make sure that you enable "add Python to environment variables/PATH" during the install
  • Install Git for Windows: You do not have permission to view the full content of this post. Log in or register now.
    • just install with the default recommended settings
  • Have a You do not have permission to view the full content of this post. Log in or register now. account
NOTE: For Windows 10/11 you need to do an additional step. Go to Settings -> search for "Manage app execution aliases" -> disable the App Installer for "python.exe" and "python3.exe".

To check if they’re installed properly open up command prompt and run the following commands:

python --version
git --version
pip --version


There shouldn't be any "not recognized as an internal or external command" errors.

Creating a Workspace​

Start by creating a folder somewhere to store your project. I named mine stable_diff.

Download the setup.bat file and save it into your stable_diff folder: You do not have permission to view the full content of this post. Log in or register now.
NOTE: make sure you save the file as a .bat file and not a .bat.txt file.

Open command prompt and navigate to your stable_diff folder. Once there run the setup.bat file:

cd <path to your stable_diff folder>
.\setup.bat

The setup batch file should create a virtual envrionment and install the Python packages. It will also download Python scripts from online repositories.

Activate the virtual environment:
.\virtualenv\Scripts\activate.bat

At this point you should be in your virtual environment and your prompt should have a (virtualenv) at the begining of the line. To exit the virtual environment just run deactivate at any time.

To restart the virtual environment after closing the command prompt window, cd back into the stable_diff folder and run the .\virtualenv\Scripts\activate.bat batch file again.

Logging in Using Your Token​

Login to huggingface:
huggingface-cli.exe login
You do not have permission to view the full content of this post. Log in or register now.

Go to the You do not have permission to view the full content of this post. Log in or register now. of the huggingface website and copy your token.
You do not have permission to view the full content of this post. Log in or register now.

Go back to the command prompt window. Make sure there's no characters selected (see below). Press Esc to de-select.
You do not have permission to view the full content of this post. Log in or register now.

Right click the Title Bar -> Edit -> Paste -> Press Enter. You should be logged in at this point.
You do not have permission to view the full content of this post. Log in or register now.

NOTE: when pasting, the command prompt will look like nothing has happened. This is normal behaviour, just press enter and it should update.

Download Model and Convert to ONNX​

Go to You do not have permission to view the full content of this post. Log in or register now. and accept the terms and conditions for the model.

Option 1​

Run the Python script to download and convert:
python convert_stable_diffusion_checkpoint_to_onnx.py --model_path="runwayml/stable-diffusion-v1-5" --output_path="model/stable_diffusion_onnx"

NOTE: This may take a while depending on your internet connection speed.

Option 2​

Althernatively, you could download the pre-converted version of the model using git:
git clone You do not have permission to view the full content of this post. Log in or register now. --branch onnx --single-branch model/stable_diffusion_onnx

Basic Script and Setup Check​

Run the txt2img_onnx.py script and check if any images were generated in the output folder. NOTE: some warnings may show up but it should be working as long as an output image is generated:
python txt2img_onnx.py

If an image was generated and it's not just a blank image then you're ready to generate art! You can use the txt2img_onnx.py script to input your own prompt for example:
python txt2img_onnx.py --prompt="tire swing hanging from a tree" --height=512 --width=512

Running The GUI​

Run the UI script and wait for everything to load:
python onnxUI.py

Once you see "Running on local URL:" open up your browser and go to "You do not have permission to view the full content of this post. Log in or register now.". You should be able to generate images using the web UI. To close the program, go back to the command prompt and hit ctrl-C.

Using Other Models​

Models Using Diffuers​

If the model is on the hugging face website and it's using the diffusers library, then you can use the same convert script from the guide. Make sure you've accepted the terms for any new model. In this example I'll use waifu-diffusion.
python convert_stable_diffusion_checkpoint_to_onnx.py --model_path="hakurei/waifu-diffusion" --output_path="model/waifu_diffusion_onnx"

Models Using .ckpt​

If the pretrained model is a .ckpt file, then you'll need to do a two step conversion. You first will need to convert from .ckpt to diffusers, then from diffusers to ONNX.

Download the .ckpt model of your choice and put them in your stable_diff folder. Run the first conversion script, using trinart2_step115000.ckpt in this example:
python convert_original_stable_diffusion_to_diffusers.py --checkpoint_path="./trinart2_step115000.ckpt" --dump_path="./trinart2_step115000_diffusers"
Then run the second conversion script:
python convert_stable_diffusion_checkpoint_to_onnx.py --model_path="./trinart2_step115000_diffusers" --output_path="model/trinart2_step115000_onnx"
NOTE: make sure the --dump_path in the first script and the --model_path is the same folder name.

After Conversion​

Once you have your newly converted model, make sure the model is saved into the model folder (create one if it doesn't exist). Once you restarted the UI, select the model from the dropdown menu on the top left.

Reduce VRAM use by having Text Encoder on CPU​

The Text Encoder runs only once per generation and is not very compute intensive, but the model uses VRAM resulting in reduced available VRAM. VRAM memory pressure will reduce the speed of every iteration. It can be beneficial to run the Text Encoder on CPU instead.
You can make the UI load the Text Encoder on CPU by adding --cpu-textenc flag:
python onnxUI.py --cpu-textenc

De-allocate memory after each image generation​

You can de-allocate memory after each image generation in case you want to do that. Might be useful for very low VRAM.

You can de-allocate memory after each generation by adding --release-memory-after-generation flag: python onnxUI.py --release-memory-after-generation

De-allocate memory when changing pipelines​

You can de-allocate memory when swapping pipelines (txt2img, img2img, inpaint). With low VRAM sometimes you may want to do this to prevent slowdowns or OOM errors that may occur from having multiple loaded at once. With more than 8GB of VRAM this is possibly not needed.

You can de-allocate memory when swapping pipelines by adding --release-memory-on-change flag: python onnxUI.py --release-memory-on-change

Running Stable Diffusion on CPUs​

If you don't have a graphics card with enough VRAM or you only have onboard graphics, you can still run Stable Diffusion with the CPU. Simply add a --cpu-only flag to your command line:
python txt2img_onnx.py --cpu-only

Updating onnxUI.py​

If you want to update the program, download the latest setup.bat and overwrite the old one: You do not have permission to view the full content of this post. Log in or register now.

Then run the following:
.\setup.bat -update

NOTE: if you're updating from diffusers v0.5.1 and below, you will need to re-convert your models.

Inpainting Fix​

  • If inpainting does not work for you, please follow these steps from de_inferno#6407 on #forbidden# to fix it.
    • Within: virtualenv\lib\site-packages\diffusers\pipelines\stable_diffusion\pipeline_onnx_stable_diffusion_inpaint_legacy.py
    • Find (likely on line 402): sample=latent_model_input, timestep=np.array([t]), encoder_hidden_states=prompt_embeds
    • Replace with: sample=latent_model_input, timestep=np.array([t], dtype="float32"), encoder_hidden_states=prompt_embeds

=============================================================

Note: This is just one of the early UI bago na-update na sa You do not have permission to view the full content of this post. Log in or register now.. Ang focus ko rito is it supports cpu mode using onnx runtime para operational siya kahit low-end hardware (non-GPU) though mas preferred sa GPU. Ang maganda lang dito, there is an option to convert your custom checkpoints (*.ckpt) to ONNX diffusers.
Gamitin nyo muna itong You do not have permission to view the full content of this post. Log in or register now. if your base model is using safetensor format para ma-convert back to ckpt format. Ckpt2Safetensors and Safetensors2Ckpt din ang converter na ito. PArehas yan ng app You do not have permission to view the full content of this post. Log in or register now. na explained You do not have permission to view the full content of this post. Log in or register now.. I hope you know what I mean since most releases are in safetensor format now due to security reasons.
Good Luck.

Note: Again, don't forget to read and browse external links to understand about the app. Straight-forward yan and easy to follow para sa familiar na using new Stable Diffusion UIs.
 
Last edited:
4. LAMA CLEANER: You do not have permission to view the full content of this post. Log in or register now.
The rest of the documentation can be found You do not have permission to view the full content of this post. Log in or register now.. You can run it using "pip", using a windows installer, docker, online (see You do not have permission to view the full content of this post. Log in or register now. and You do not have permission to view the full content of this post. Log in or register now.) and on your vps. So it's fun and easy to use.

You do not have permission to view the full content of this post. Log in or register now.

Lama Cleaner​

A free and open-source inpainting tool powered by SOTA AI model.
You do not have permission to view the full content of this post. Log in or register now.You do not have permission to view the full content of this post. Log in or register now.You do not have permission to view the full content of this post. Log in or register now.You do not have permission to view the full content of this post. Log in or register now.You do not have permission to view the full content of this post. Log in or register now.You do not have permission to view the full content of this post. Log in or register now.
example-0.24.0.mp4

Sponsor​

You do not have permission to view the full content of this post. Log in or register now.You do not have permission to view the full content of this post. Log in or register now.

Features​

  • Completely free and open-source, fully self-hosted, support CPU & GPU & M1/2
  • You do not have permission to view the full content of this post. Log in or register now.
  • You do not have permission to view the full content of this post. Log in or register now.
  • Multiple SOTA AI You do not have permission to view the full content of this post. Log in or register now.
    • Erase model: LaMa/LDM/ZITS/MAT/FcF/Manga
    • Erase and Replace model: Stable Diffusion/Paint by Example
  • You do not have permission to view the full content of this post. Log in or register now. for post-processing:
    • You do not have permission to view the full content of this post. Log in or register now.: Remove images background
    • You do not have permission to view the full content of this post. Log in or register now.: Super Resolution
    • You do not have permission to view the full content of this post. Log in or register now.: Face Restoration
    • You do not have permission to view the full content of this post. Log in or register now.: Face Restoration
    • You do not have permission to view the full content of this post. Log in or register now.: Accurate and fast interactive object segmentation
  • More features at You do not have permission to view the full content of this post. Log in or register now.

Quick Start​

Lama Cleaner make it easy to use SOTA AI model in just two commands:
# In order to use the GPU, install cuda version of pytorch first.
# pip install torch==1.13.1+cu117 torchvision==0.14.1 --extra-index-url You do not have permission to view the full content of this post. Log in or register now.
pip install lama-cleaner
lama-cleaner --model=lama --device=cpu --port=8080

That's it, Lama Cleaner is now running at You do not have permission to view the full content of this post. Log in or register now.
See all command line arguments at You do not have permission to view the full content of this post. Log in or register now.

Development​

Only needed if you plan to modify the frontend and recompile yourself.

Frontend​

Frontend code are modified from You do not have permission to view the full content of this post. Log in or register now., You can experience their great online services You do not have permission to view the full content of this post. Log in or register now..
  • Install dependencies:cd lama_cleaner/app/ && pnpm install
  • Start development server: pnpm start
  • Build: pnpm build

5. Inpaint-anything: You do not have permission to view the full content of this post. Log in or register now.
(This is a standalone application and not an extension of SD-Web-UI - though You do not have permission to view the full content of this post. Log in or register now..)
Check also this site to get more ideas: You do not have permission to view the full content of this post. Log in or register now. and You do not have permission to view the full content of this post. Log in or register now..
Images pa lang support ng mga ito. Siguro, later on sa videos na.

Mention ko na lang yung ibang similar softwares which use inpainting din:
You do not have permission to view the full content of this post. Log in or register now. by teorex w/ Windows installer too. May free demo link din ito to try na halos unlimited.
download ninyo itong portable full version:
Spoiler contents are visible only to Established Members.

Now we move on to our app:

Inpaint Anything (Inpainting with Segment Anything)​

Inpaint Anything performs stable diffusion inpainting on a browser UI using any mask selected from the output of You do not have permission to view the full content of this post. Log in or register now..

Using Segment Anything enables users to specify masks by simply pointing to the desired areas, instead of manually filling them in. This can increase the efficiency and accuracy of the mask creation process, leading to potentially higher-quality inpainting results while saving time and effort.

You do not have permission to view the full content of this post. Log in or register now.

You do not have permission to view the full content of this post. Log in or register now.

Installation​

Please follow these steps to install the software:

  • Create a new conda environment:
conda create -n inpaint python=3.10
conda activate inpaint

  • Clone the software repository:
git clone You do not have permission to view the full content of this post. Log in or register now.
cd inpaint-anything

  • For the CUDA environment, install the following packages:
pip install -r requirements.txt

  • If you are using macOS, please install the package from the following file instead:
pip install -r requirements_mac.txt

Running the application​

python iasam_app.py

  • Open You do not have permission to view the full content of this post. Log in or register now. in your browser.
  • Note: If you have a privacy protection extension enabled in your web browser, such as DuckDuckGo, you may not be able to retrieve the mask from your sketch.

Options​

  • --save_segment: Save the segmentation image generated by SAM.
  • --offline: Execute inpainting using an offline network.
  • --sam_cpu: Perform the Segment Anything operation on CPU.

Downloading the Model​

  • Launch this application.
  • Click on the Download model button, located next to the You do not have permission to view the full content of this post. Log in or register now.. This includes the You do not have permission to view the full content of this post. Log in or register now., You do not have permission to view the full content of this post. Log in or register now., and You do not have permission to view the full content of this post. Log in or register now..
    • Please note that the SAM is available in three sizes: Base, Large, and Huge. Remember, larger sizes consume more VRAM.
  • Wait for the download to complete.
  • The downloaded model file will be stored in the models directory of this application's repository.

Usage​

  • Drag and drop your image onto the input image area.
    • Outpainting can be achieved by the Padding options, configuring the scale and balance, and then clicking on the Run Padding button.
    • The Anime Style checkbox enhances segmentation mask detection, particularly in anime style images, at the expense of a slight reduction in mask quality.
  • Click on the Run Segment Anything button.
  • Use sketching to point the area you want to inpaint. You can undo and adjust the pen size.
    • Hover over either the SAM image or the mask image and press the S key for Fullscreen mode, or the R key to Reset zoom.
  • Click on the Create mask button. The mask will appear in the selected mask image area.

Mask Adjustment​

  • Expand mask region button: Use this to slightly expand the area of the mask for broader coverage.
  • Trim mask by sketch button: Clicking this will exclude the sketched area from the mask.
  • Add mask by sketch button: Clicking this will add the sketched area to the mask.

Inpainting Tab​

  • Enter your desired Prompt and Negative Prompt, then choose the Inpainting Model ID.
  • Click on the Run Inpainting button (Please note that it may take some time to download the model for the first time).
    • In the Advanced options, you can adjust the Sampler, Sampling Steps, Guidance Scale, and Seed.
    • If you enable the Mask area Only option, modifications will be confined to the designated mask area only.
  • Inpainting process is performed using You do not have permission to view the full content of this post. Log in or register now..

Tips​

  • You can directly drag and drop the inpainted image into the input image field on the Web UI. (useful with Chrome and Edge browsers)

Model Cache​

  • The inpainting model, which is saved in HuggingFace's cache and includes inpaint (case-insensitive) in its repo_id, will also be added to the Inpainting Model ID dropdown list.
    • If there's a specific model you'd like to use, you can cache it in advance using the following Python commands:
python

from diffusers import StableDiffusionInpaintPipeline
pipe = StableDiffusionInpaintPipeline.from_pretrained("Uminosachi/dreamshaper_5-inpainting")
exit()

  • The model diffusers downloaded is typically stored in your home directory. You can find it at /home/username/.cache/huggingface/hub for Linux and MacOS users, or at C:\Users\username\.cache\huggingface\hub for Windows users.

Cleaner Tab​

  • Choose the Cleaner Model ID.
  • Click on the Run Cleaner button (Please note that it may take some time to download the model for the first time).
  • Cleaner process is performed using You do not have permission to view the full content of this post. Log in or register now..

Mask only Tab​

  • Gives ability to just save mask without any other processing, so it's then possible to use the mask in other graphic applications.
  • Get mask as alpha of image button: Save the mask as RGBA image, with the mask put into the alpha channel of the input image.
  • Get mask button: Save the mask as RGB image.
You do not have permission to view the full content of this post. Log in or register now.

Auto-saving images​

  • The inpainted image will be automatically saved in the folder that matches the current date within the outputs directory.
  • If you would also like to save the segmented images, run the Python script with the following argument:

Development​

With the You do not have permission to view the full content of this post. Log in or register now., you can perform segmentation and create masks using sketches from other applications.

License​

The source code is licensed under the You do not have permission to view the full content of this post. Log in or register now..
==========================================================================
The installation provided is using "conda" - another python option, but you can still use the standard python method of using "pip". In the end it still runs using "python iasam_app.py" script.
( TIPS1: To avoid corruption of your system python dependencies when using multiple python apps with different python version module requirements, please create a python virtual environment and activate it each time you test these devs and install their dependencies using pip. Deactivate them and close later afterwards. Refer You do not have permission to view the full content of this post. Log in or register now. and You do not have permission to view the full content of this post. Log in or register now..
Example: I normally use these scripts first to create venv and activate it.
Code:
python -m venv venv
.\venv\Scripts\activate
Then use pip to install requirements.txt is present:
Code:
pip install -r requirements.txt
To deactivate, just type this:
Code:
.\venv\Scripts\deactivate
It's hard to fix a corrupt python installation. It's much easier to uninstall and install a new one.
TIP2: The "requirements.txt" provided is for GPU mode though it works on cpu-mode if you're lucky, but very slow while some encounter crashes. Try replacing "You do not have permission to view the full content of this post. Log in or register now. " to "You do not have permission to view the full content of this post. Log in or register now." in line#1 for better compatibility. There's no guarantee since some old hardware can't support all python requirements. You need to find that out for yourselves. "cu118" is for NVIDIA Graphic Cards supporting You do not have permission to view the full content of this post. Log in or register now.. Be aware of what you are installing compared to your present hardware to avoid problems. Be advised.
TIP3: Para updated kayo sa mga updates sa AI, just check here para laging handa he he:
You do not have permission to view the full content of this post. Log in or register now..)

6. UPSCALING Softwares: Understandably, they are used to increase image resolution without losing quality. Maraming online services but my goal is for offline use only. straightforward naman ito by just visiting the sites here, and test them all you want to get what you desired. Stable Diffusion has this option assuming you have the right model installed there.

For the free opensource options just visit the following:
1. Free
Spoiler contents are visible only to Established Members.
These free ones at Sourceforge also connect to github sources and vice-versa, so check them too. My search entry may not be enough.
To fully understand image upscaling, including restoration, you need to study how it works and which one works including their limitations to find which one fits the category you want to fulfill.
You do not have permission to view the full content of this post. Log in or register now.
You do not have permission to view the full content of this post. Log in or register now.
You do not have permission to view the full content of this post. Log in or register now. (old) or You do not have permission to view the full content of this post. Log in or register now. (latest)
The models are used in Stable Diffusion and your chosen upscaling UIs. Be guided on where to put them and support of your UIs.
2. Commercial (most items)
Spoiler contents are visible only to Established Members.
 
Last edited:
Para sa mga interisado, ilagay ko na lang dito yung binurang post ko sa isang thread. It's about this FREE Stable Diffusion plugin, NO GPU required using ONLINE service, and UNLIMITED use:

Spoiler contents are visible only to Established Members.
Plugin po ito, so you need the required UI for it to run . Just click the link and browse for the FAQ and other information to run them.
Kung may malakas naman kayong GPU and you have A1111 installed, you can integrate it to your PS using this plugin locally kahit walang net:
Spoiler contents are visible only to Established Members.
These are freely available year-old apps, so there's no need for secrecy, except the "spoiler" he he.
(Note: Kung nakuha nyo yung scheme ng mga yan, you'll realize that is a much easier aside from plugins using the one used by Stable Horde - read between the lines.)
Ang bonus ko na lang to use Stable Diffusion for Free is visit hugginface.co and look for the "SPACES" page. Then type the application related to Stable Diffusion (or any app developed there) that is being deployed. Type and try "StableDiffusion" as an example and look for "running" apps. Many users even link their AI apis sa HF liike the free option sa prodia.com.
Click and try any if they work! Choose the ones with upgraded hardware para mabilis ang genration or responses. Halos lahat ng mga AI apps ay nandyan since it's an open source playground. Sa mga ibang deployment servers like vercel, gitpod, railways, etc. ay meron din nyan, pero you need to use a search engine and the right queries to find them. Github like HF is one source that leads to these servers. That's the logic.
Nakalimutan ko pala idagdag doon sa mga curious sa Adobe Firefly/Genrative Fill. Pwede ninyong ubukan yan mismo sa Adobe page : You do not have permission to view the full content of this post. Log in or register now. . Test and enjoy.
 
Last edited:
Medyo nagiging obsolete na itong thread sa bilis ng development ng AI ngayon. Malingat ka lang meron ng bago he he. Bihira naman ang interisado sa offline method kaya doon na lang kayo sa online mag-concentrate para mas mabilis yung processing, mas madali at mas marami ang options for ease of use. Mahirap din kasi mag-umpisa ng AI offline with only using your cpu dahil may malaking requirement din sa system RAM. At hindi madaling i-setup tulad ng standard designed interfaces for GPU use.

Search engine lang yung katapat in searching for online services, at di kayo mauubusan lalo pa kung libre he he! Sa ρrémíùm service naman ay maraming providers ng live accounts and cøøkíés for limited use and period. Or can be circumvented with multiple logins or some userscripts to make it extend the number of requests/limits or even close to unlimited use.

Kaya good for beginners na lang ito sa mga interisadong mag-aral,. Sundan nyo na lang yung later releases nila sa given source sites at mga forks nila na mas bago at stable. It just needs a lot of reading, research and practice. Guides are all around YøùTùbé to assist you.

Basta sa CPU-mode, ang mabilis lang ang rendering ay yung gumagamit ng models using ONNX format with ONNX runtime (for Intel cpus using openvino toolkit), or else matagal yang mag-generate ng images in that mode - using torch. Yan yung puntiryahin ninyo if you don't have a recommended dedicated GPU and VRAM for faster image generation, same as generative ai, machine learning, natural language processing, computer vision, etc.
 
Lipas na sa'kin ang thread na ito, pero doon sa di updated sa SD cpu development, ang pinakamabilis sa cpu-mode sa ngayon is this app: You do not have permission to view the full content of this post. Log in or register now.
Don't try if you don't have the hardware requirements, especially sa RAM. Kahit 3rd gen intel gagana yan basta malaki ang RAM mo. Hindi ka maiinip sa pag-intay sa results di tulad noon using pytorch or the early openvino. Itis only used to speed-up txt-image generation, so quality is decline - kahit gamitin yung TAESD sa Standard A1111 or Comfy UI.
 
Last edited:
Back
Top