IOPaint/iopaint/const.py

151 lines
4.6 KiB
Python
Raw Normal View History

2023-04-03 17:04:59 +02:00
import json
2023-01-20 09:52:38 +01:00
import os
2024-01-31 14:51:34 +01:00
from pathlib import Path
from iopaint.schema import ApiConfig, Device, InteractiveSegModel, RealESRGANModel
2023-04-03 17:04:59 +02:00
2024-01-05 09:38:55 +01:00
INSTRUCT_PIX2PIX_NAME = "timbrooks/instruct-pix2pix"
KANDINSKY22_NAME = "kandinsky-community/kandinsky-2-2-decoder-inpaint"
POWERPAINT_NAME = "Sanster/PowerPaint-V1-stable-diffusion-inpainting"
2024-01-21 16:25:50 +01:00
ANYTEXT_NAME = "Sanster/AnyText"
2024-01-05 09:38:55 +01:00
2023-01-20 09:52:38 +01:00
2023-12-27 15:00:07 +01:00
DIFFUSERS_SD_CLASS_NAME = "StableDiffusionPipeline"
DIFFUSERS_SD_INPAINT_CLASS_NAME = "StableDiffusionInpaintPipeline"
DIFFUSERS_SDXL_CLASS_NAME = "StableDiffusionXLPipeline"
DIFFUSERS_SDXL_INPAINT_CLASS_NAME = "StableDiffusionXLInpaintPipeline"
2023-12-01 03:15:35 +01:00
MPS_UNSUPPORT_MODELS = [
"lama",
"ldm",
"zits",
"mat",
"fcf",
"cv2",
"manga",
2023-02-06 15:00:47 +01:00
]
2023-01-20 09:52:38 +01:00
DEFAULT_MODEL = "lama"
2023-12-27 15:00:07 +01:00
AVAILABLE_MODELS = ["lama", "ldm", "zits", "mat", "fcf", "manga", "cv2", "migan"]
2024-01-31 14:51:34 +01:00
DIFFUSION_MODELS = [
"runwayml/stable-diffusion-inpainting",
"Uminosachi/realisticVisionV51_v51VAE-inpainting",
"redstonehero/dreamshaper-inpainting",
"Sanster/anything-4.0-inpainting",
"diffusers/stable-diffusion-xl-1.0-inpainting-0.1",
"Fantasy-Studio/Paint-by-Example",
POWERPAINT_NAME,
ANYTEXT_NAME,
]
2023-01-20 09:52:38 +01:00
NO_HALF_HELP = """
2023-12-24 08:32:27 +01:00
Using full precision(fp32) model.
If your diffusion model generate result is always black or green, use this argument.
2023-01-20 09:52:38 +01:00
"""
CPU_OFFLOAD_HELP = """
2023-12-24 08:32:27 +01:00
Offloads diffusion model's weight to CPU RAM, significantly reducing vRAM usage.
2023-01-20 09:52:38 +01:00
"""
2024-01-31 14:51:34 +01:00
LOW_MEM_HELP = "Enable attention slicing and vae tiling to save memory."
2023-01-20 09:52:38 +01:00
DISABLE_NSFW_HELP = """
2023-12-24 08:32:27 +01:00
Disable NSFW checker for diffusion model.
2023-01-20 09:52:38 +01:00
"""
2023-12-24 08:32:27 +01:00
CPU_TEXTENCODER_HELP = """
Run diffusion models text encoder on CPU to reduce vRAM usage.
2023-01-20 09:52:38 +01:00
"""
2023-05-11 15:51:58 +02:00
SD_CONTROLNET_CHOICES = [
2023-12-01 03:15:35 +01:00
"lllyasviel/control_v11p_sd15_canny",
# "lllyasviel/control_v11p_sd15_seg",
"lllyasviel/control_v11p_sd15_openpose",
"lllyasviel/control_v11p_sd15_inpaint",
"lllyasviel/control_v11f1p_sd15_depth",
]
SD2_CONTROLNET_CHOICES = [
"thibaud/controlnet-sd21-canny-diffusers",
"thibaud/controlnet-sd21-depth-diffusers",
"thibaud/controlnet-sd21-openpose-diffusers",
]
SDXL_CONTROLNET_CHOICES = [
"thibaud/controlnet-openpose-sdxl-1.0",
2023-12-24 08:32:27 +01:00
"destitech/controlnet-inpaint-dreamer-sdxl",
2023-12-01 03:15:35 +01:00
"diffusers/controlnet-canny-sdxl-1.0",
2023-12-19 06:16:30 +01:00
"diffusers/controlnet-canny-sdxl-1.0-mid",
2023-12-24 08:32:27 +01:00
"diffusers/controlnet-canny-sdxl-1.0-small",
2023-12-01 03:15:35 +01:00
"diffusers/controlnet-depth-sdxl-1.0",
2023-12-19 06:16:30 +01:00
"diffusers/controlnet-depth-sdxl-1.0-mid",
"diffusers/controlnet-depth-sdxl-1.0-small",
2023-05-11 15:51:58 +02:00
]
2023-03-19 15:40:23 +01:00
2023-01-20 09:52:38 +01:00
LOCAL_FILES_ONLY_HELP = """
2023-12-24 08:32:27 +01:00
When loading diffusion models, using local files only, not connect to HuggingFace server.
2023-01-20 09:52:38 +01:00
"""
2024-01-31 14:51:34 +01:00
DEFAULT_MODEL_DIR = os.path.abspath(
os.getenv("XDG_CACHE_HOME", os.path.join(os.path.expanduser("~"), ".cache"))
2023-01-20 09:52:38 +01:00
)
2024-01-31 14:51:34 +01:00
2023-12-24 08:32:27 +01:00
MODEL_DIR_HELP = f"""
Model download directory (by setting XDG_CACHE_HOME environment variable), by default model download to {DEFAULT_MODEL_DIR}
2023-01-20 09:52:38 +01:00
"""
OUTPUT_DIR_HELP = """
2023-12-24 08:32:27 +01:00
Result images will be saved to output directory automatically.
2023-01-20 09:52:38 +01:00
"""
INPUT_HELP = """
If input is image, it will be loaded by default.
If input is directory, you can browse and select image in file manager.
"""
GUI_HELP = """
Launch Lama Cleaner as desktop app
"""
QUALITY_HELP = """
Quality of image encoding, 0-100. Default is 95, higher quality will generate larger file size.
"""
2023-03-28 15:55:25 +02:00
2023-04-06 15:55:20 +02:00
INTERACTIVE_SEG_HELP = "Enable interactive segmentation using Segment Anything."
2024-01-31 14:51:34 +01:00
INTERACTIVE_SEG_MODEL_HELP = "Model size: mobile_sam < vit_b < vit_l < vit_h. Bigger model size means better segmentation but slower speed."
2023-03-28 15:55:25 +02:00
REMOVE_BG_HELP = "Enable remove background. Always run on CPU"
2023-05-09 13:07:12 +02:00
ANIMESEG_HELP = "Enable anime segmentation. Always run on CPU"
2023-03-28 15:55:25 +02:00
REALESRGAN_HELP = "Enable realesrgan super resolution"
2024-01-31 14:51:34 +01:00
GFPGAN_HELP = "Enable GFPGAN face restore. To also enhance background, use with --enable-realesrgan"
RESTOREFORMER_HELP = "Enable RestoreFormer face restore. To also enhance background, use with --enable-realesrgan"
2023-03-28 15:55:25 +02:00
GIF_HELP = "Enable GIF plugin. Make GIF to compare original and cleaned image"
2023-04-03 17:04:59 +02:00
2024-01-31 14:51:34 +01:00
default_configs = dict(
host="127.0.0.1",
port=8080,
model=DEFAULT_MODEL,
model_dir=DEFAULT_MODEL_DIR,
no_half=False,
low_mem=False,
cpu_offload=False,
disable_nsfw_checker=False,
local_files_only=False,
cpu_textencoder=False,
device=Device.cuda,
input=None,
output_dir=None,
quality=95,
enable_interactive_seg=False,
interactive_seg_model=InteractiveSegModel.vit_b,
interactive_seg_device=Device.cpu,
enable_remove_bg=False,
enable_anime_seg=False,
enable_realesrgan=False,
realesrgan_device=Device.cpu,
realesrgan_model=RealESRGANModel.realesr_general_x4v3,
enable_gfpgan=False,
gfpgan_device=Device.cpu,
enable_restoreformer=False,
restoreformer_device=Device.cpu,
)