├── .gitignore ├── README.md └── scripts ├── lama_cleaner_lama.py └── lama_cleaner_tab.py /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | *.py,cover 51 | .hypothesis/ 52 | .pytest_cache/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # IPython 81 | profile_default/ 82 | ipython_config.py 83 | 84 | # pyenv 85 | .python-version 86 | 87 | # pipenv 88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 91 | # install all needed dependencies. 92 | #Pipfile.lock 93 | 94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 95 | __pypackages__/ 96 | 97 | # Celery stuff 98 | celerybeat-schedule 99 | celerybeat.pid 100 | 101 | # SageMath parsed files 102 | *.sage.py 103 | 104 | # Environments 105 | .env 106 | .venv 107 | env/ 108 | venv/ 109 | ENV/ 110 | env.bak/ 111 | venv.bak/ 112 | 113 | # Spyder project settings 114 | .spyderproject 115 | .spyproject 116 | 117 | # Rope project settings 118 | .ropeproject 119 | 120 | # mkdocs documentation 121 | /site 122 | 123 | # mypy 124 | .mypy_cache/ 125 | .dmypy.json 126 | dmypy.json 127 | 128 | # Pyre type checker 129 | .pyre/ 130 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # sd_lama_cleaner 2 | 3 | Lama Cleaner 1111 Extension 4 | 5 | 「LamaCreaner」タブが追加されます。 6 | 7 | ## 作者について 8 | 9 | - 現在メインでWSL2を使っているため、Windows固有の問題には対応が鈍いです。 10 | - ユーザーがどれだけいるのかチェックしてないので、需要があったら教えてください。 11 | 12 | ## Install 13 | 14 | 最初に使い始める前に、一回だけ実行してください。 15 | 16 | - extensionを入れただけでは何もしません 17 | - Installボタンを押す 18 | 19 | ### うまくいかないとき 20 | 21 | コマンドラインから手動でInstallできます。 22 | 23 | for Windows: 24 | ```bash 25 | cd stable-diffusion-webui 26 | venv/Scripts/pip install -U lama-cleaner 27 | ``` 28 | 29 | for Linux: 30 | ```bash 31 | cd stable-diffusion-webui 32 | venv/bin/pip install -U lama-cleaner 33 | ``` 34 | 35 | ## Start 36 | 37 | webuiが再起動するたびに、毎回実行してください。 38 | 39 | - Startボタンを押す(窓が開く) 40 | - Linuxで使う時は少し書き換えてください 41 | 42 | for Windows: 43 | ```bash 44 | start venv/Scripts/lama-cleaner --model=lama --device=cpu --port=7870 45 | ``` 46 | 47 | for Linux: 48 | ```bash 49 | venv/bin/lama-cleaner --model=lama --device=cpu --port=7870 50 | ``` 51 | 52 | 読み込み中の表示のままになった場合はブラウザをリロードすると直るかも。 53 | 54 | ## Enjoy 55 | 56 | - Openを押す(画面が開く) 57 | - Openが不満なら「Open New Window」をお好みで押す 58 | 59 | ### Open New Window 60 | 61 | for Windows: 62 | ```bash 63 | start http://127.0.0.1:7870/ 64 | ``` 65 | 66 | Linuxだと動かないかも? 67 | -------------------------------------------------------------------------------- /scripts/lama_cleaner_lama.py: -------------------------------------------------------------------------------- 1 | from typing import List 2 | from pydantic import BaseModel 3 | from lama_cleaner.server import main 4 | 5 | class FakeArgs(BaseModel): 6 | host: str = "0.0.0.0" 7 | port: int = 7870 8 | model: str = 'lama' 9 | hf_access_token: str = "" 10 | sd_disable_nsfw: bool = False 11 | sd_cpu_textencoder: bool = True 12 | sd_run_local: bool = False 13 | sd_enable_xformers: bool = False 14 | local_files_only: bool = False 15 | cpu_offload: bool = False 16 | device: str = "cpu" 17 | gui: bool = False 18 | gui_size: List[int] = [1000, 1000] 19 | input: str = '' 20 | disable_model_switch: bool = True 21 | debug: bool = False 22 | no_half: bool = False 23 | disable_nsfw: bool = False 24 | enable_xformers: bool = False 25 | model_dir: str = None 26 | output_dir: str = None 27 | enable_interactive_seg: bool = True 28 | enable_remove_bg: bool = True 29 | enable_realesrgan: bool = True 30 | 31 | if __name__ == "__main__": 32 | main(FakeArgs()) 33 | -------------------------------------------------------------------------------- /scripts/lama_cleaner_tab.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | 4 | import gradio as gr 5 | 6 | from modules import scripts, script_callbacks, sd_models, shared 7 | 8 | import launch 9 | 10 | dir = os.path.dirname(os.path.dirname(__file__)) 11 | 12 | def install_lama_cleaner(): 13 | try: 14 | launch.run_pip("install -U lama-cleaner", desc='lama-cleaner') 15 | return ['Installed.'] 16 | except: 17 | print("Install failed.") 18 | 19 | def start_lama_server(command): 20 | launch.run(command) 21 | return ['Server started.'] 22 | 23 | def open_lama_cleaner(height): 24 | return f'