beta1
This commit is contained in:
		
							parent
							
								
									a95dd10ceb
								
							
						
					
					
						commit
						cc06f30e9a
					
				| 
						 | 
				
			
			@ -48,6 +48,7 @@ def batch_inpaint(
 | 
			
		|||
            f"invalid --output: when image is a directory, output should be a directory"
 | 
			
		||||
        )
 | 
			
		||||
        exit(-1)
 | 
			
		||||
    output.mkdir(parents=True, exist_ok=True)
 | 
			
		||||
 | 
			
		||||
    image_paths = glob_images(image)
 | 
			
		||||
    mask_paths = glob_images(mask)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,7 +7,6 @@ from loguru import logger
 | 
			
		|||
from typer import Option
 | 
			
		||||
 | 
			
		||||
from iopaint.const import *
 | 
			
		||||
from iopaint.download import cli_download_model, scan_models
 | 
			
		||||
from iopaint.runtime import setup_model_dir, dump_environment_info, check_device
 | 
			
		||||
 | 
			
		||||
typer_app = typer.Typer(pretty_exceptions_show_locals=False, add_completion=False)
 | 
			
		||||
| 
						 | 
				
			
			@ -25,16 +24,29 @@ def download(
 | 
			
		|||
    model: str = Option(
 | 
			
		||||
        ..., help="Model id on HuggingFace e.g: runwayml/stable-diffusion-inpainting"
 | 
			
		||||
    ),
 | 
			
		||||
    model_dir: Path = Option(DEFAULT_MODEL_DIR, help=MODEL_DIR_HELP, file_okay=False),
 | 
			
		||||
    model_dir: Path = Option(
 | 
			
		||||
        DEFAULT_MODEL_DIR,
 | 
			
		||||
        help=MODEL_DIR_HELP,
 | 
			
		||||
        file_okay=False,
 | 
			
		||||
        callback=setup_model_dir,
 | 
			
		||||
    ),
 | 
			
		||||
):
 | 
			
		||||
    cli_download_model(model, model_dir)
 | 
			
		||||
    from iopaint.download import cli_download_model
 | 
			
		||||
 | 
			
		||||
    cli_download_model(model)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@typer_app.command(name="list", help="List downloaded models")
 | 
			
		||||
def list_model(
 | 
			
		||||
    model_dir: Path = Option(DEFAULT_MODEL_DIR, help=MODEL_DIR_HELP, file_okay=False),
 | 
			
		||||
    model_dir: Path = Option(
 | 
			
		||||
        DEFAULT_MODEL_DIR,
 | 
			
		||||
        help=MODEL_DIR_HELP,
 | 
			
		||||
        file_okay=False,
 | 
			
		||||
        callback=setup_model_dir,
 | 
			
		||||
    ),
 | 
			
		||||
):
 | 
			
		||||
    setup_model_dir(model_dir)
 | 
			
		||||
    from iopaint.download import scan_models
 | 
			
		||||
 | 
			
		||||
    scanned_models = scan_models()
 | 
			
		||||
    for it in scanned_models:
 | 
			
		||||
        print(it.name)
 | 
			
		||||
| 
						 | 
				
			
			@ -59,13 +71,19 @@ def run(
 | 
			
		|||
    concat: bool = Option(
 | 
			
		||||
        False, help="Concat original image, mask and output images into one image"
 | 
			
		||||
    ),
 | 
			
		||||
    model_dir: Path = Option(DEFAULT_MODEL_DIR, help=MODEL_DIR_HELP, file_okay=False),
 | 
			
		||||
    model_dir: Path = Option(
 | 
			
		||||
        DEFAULT_MODEL_DIR,
 | 
			
		||||
        help=MODEL_DIR_HELP,
 | 
			
		||||
        file_okay=False,
 | 
			
		||||
        callback=setup_model_dir,
 | 
			
		||||
    ),
 | 
			
		||||
):
 | 
			
		||||
    setup_model_dir(model_dir)
 | 
			
		||||
    from iopaint.download import cli_download_model, scan_models
 | 
			
		||||
 | 
			
		||||
    scanned_models = scan_models()
 | 
			
		||||
    if model not in [it.name for it in scanned_models]:
 | 
			
		||||
        logger.info(f"{model} not found in {model_dir}, try to downloading")
 | 
			
		||||
        cli_download_model(model, model_dir)
 | 
			
		||||
        cli_download_model(model)
 | 
			
		||||
 | 
			
		||||
    from iopaint.batch_processing import batch_inpaint
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -82,7 +100,11 @@ def start(
 | 
			
		|||
        f"You can use download command to download other SD/SDXL normal/inpainting models on huggingface",
 | 
			
		||||
    ),
 | 
			
		||||
    model_dir: Path = Option(
 | 
			
		||||
        DEFAULT_MODEL_DIR, help=MODEL_DIR_HELP, dir_okay=True, file_okay=False
 | 
			
		||||
        DEFAULT_MODEL_DIR,
 | 
			
		||||
        help=MODEL_DIR_HELP,
 | 
			
		||||
        dir_okay=True,
 | 
			
		||||
        file_okay=False,
 | 
			
		||||
        callback=setup_model_dir,
 | 
			
		||||
    ),
 | 
			
		||||
    no_half: bool = Option(False, help=NO_HALF_HELP),
 | 
			
		||||
    cpu_offload: bool = Option(False, help=CPU_OFFLOAD_HELP),
 | 
			
		||||
| 
						 | 
				
			
			@ -125,16 +147,17 @@ def start(
 | 
			
		|||
            output_dir.mkdir(parents=True)
 | 
			
		||||
 | 
			
		||||
    model_dir = model_dir.expanduser().absolute()
 | 
			
		||||
    setup_model_dir(model_dir)
 | 
			
		||||
 | 
			
		||||
    if local_files_only:
 | 
			
		||||
        os.environ["TRANSFORMERS_OFFLINE"] = "1"
 | 
			
		||||
        os.environ["HF_HUB_OFFLINE"] = "1"
 | 
			
		||||
 | 
			
		||||
    from iopaint.download import cli_download_model, scan_models
 | 
			
		||||
 | 
			
		||||
    scanned_models = scan_models()
 | 
			
		||||
    if model not in [it.name for it in scanned_models]:
 | 
			
		||||
        logger.info(f"{model} not found in {model_dir}, try to downloading")
 | 
			
		||||
        cli_download_model(model, model_dir)
 | 
			
		||||
        cli_download_model(model)
 | 
			
		||||
 | 
			
		||||
    from iopaint.api import Api
 | 
			
		||||
    from iopaint.schema import ApiConfig
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,11 +15,9 @@ from iopaint.const import (
 | 
			
		|||
)
 | 
			
		||||
from iopaint.model.utils import handle_from_pretrained_exceptions
 | 
			
		||||
from iopaint.model_info import ModelInfo, ModelType
 | 
			
		||||
from iopaint.runtime import setup_model_dir
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def cli_download_model(model: str, model_dir: Path):
 | 
			
		||||
    setup_model_dir(model_dir)
 | 
			
		||||
def cli_download_model(model: str):
 | 
			
		||||
    from iopaint.model import models
 | 
			
		||||
 | 
			
		||||
    if model in models and models[model].is_erase_model:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -84,3 +84,4 @@ def setup_model_dir(model_dir: Path):
 | 
			
		|||
    if not model_dir.exists():
 | 
			
		||||
        logger.info(f"Create model directory: {model_dir}")
 | 
			
		||||
        model_dir.mkdir(exist_ok=True, parents=True)
 | 
			
		||||
    return model_dir
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,7 +1,7 @@
 | 
			
		|||
torch>=2.0.0
 | 
			
		||||
opencv-python
 | 
			
		||||
diffusers==0.25.0
 | 
			
		||||
transformers==4.34.1
 | 
			
		||||
transformers>=4.35.1
 | 
			
		||||
safetensors
 | 
			
		||||
controlnet-aux==0.0.3
 | 
			
		||||
fastapi==0.108.0
 | 
			
		||||
| 
						 | 
				
			
			@ -11,6 +11,5 @@ pydantic
 | 
			
		|||
rich
 | 
			
		||||
loguru
 | 
			
		||||
yacs
 | 
			
		||||
gradio
 | 
			
		||||
piexif==1.1.3
 | 
			
		||||
omegaconf
 | 
			
		||||
							
								
								
									
										6
									
								
								setup.py
								
								
								
								
							
							
						
						
									
										6
									
								
								setup.py
								
								
								
								
							| 
						 | 
				
			
			@ -1,8 +1,8 @@
 | 
			
		|||
import setuptools
 | 
			
		||||
from pathlib import Path
 | 
			
		||||
 | 
			
		||||
web_files = Path("iopaint/app/build/").glob("**/*")
 | 
			
		||||
web_files = [str(it).replace("lama_cleaner/", "") for it in web_files]
 | 
			
		||||
web_files = Path("iopaint/web_app").glob("**/*")
 | 
			
		||||
web_files = [str(it).replace("iopaint/", "") for it in web_files]
 | 
			
		||||
 | 
			
		||||
with open("README.md", "r", encoding="utf-8") as fh:
 | 
			
		||||
    long_description = fh.read()
 | 
			
		||||
| 
						 | 
				
			
			@ -21,7 +21,7 @@ def load_requirements():
 | 
			
		|||
# https://setuptools.readthedocs.io/en/latest/setuptools.html#including-data-files
 | 
			
		||||
setuptools.setup(
 | 
			
		||||
    name="IOPaint",
 | 
			
		||||
    version="1.0.0",
 | 
			
		||||
    version="1.0.0-beta.1",
 | 
			
		||||
    author="PanicByte",
 | 
			
		||||
    author_email="cwq1913@gmail.com",
 | 
			
		||||
    description="Image inpainting, outpainting tool powered by SOTA AI Model",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue