From 261d2fce00225334f293d8bfed213c0a01c6cd8e Mon Sep 17 00:00:00 2001 From: Qing Date: Mon, 3 Apr 2023 23:04:59 +0800 Subject: [PATCH] fix transformers version --- lama_cleaner/const.py | 42 ++++++++++++++++++++++++++++++++++++++ lama_cleaner/parse_args.py | 2 -- lama_cleaner/web_config.py | 40 ------------------------------------ requirements.txt | 2 +- 4 files changed, 43 insertions(+), 43 deletions(-) diff --git a/lama_cleaner/const.py b/lama_cleaner/const.py index 8db2dbe..e6a0235 100644 --- a/lama_cleaner/const.py +++ b/lama_cleaner/const.py @@ -1,5 +1,8 @@ +import json import os from enum import Enum +from pydantic import BaseModel + MPS_SUPPORT_MODELS = [ "instruct_pix2pix", @@ -113,3 +116,42 @@ GFPGAN_AVAILABLE_DEVICES = ["cpu", "cuda", "mps"] RESTOREFORMER_HELP = "Enable RestoreFormer face restore. To enhance background, use with --enable-realesrgan" RESTOREFORMER_AVAILABLE_DEVICES = ["cpu", "cuda", "mps"] GIF_HELP = "Enable GIF plugin. Make GIF to compare original and cleaned image" + + +class Config(BaseModel): + host: str = "127.0.0.1" + port: int = 8080 + model: str = DEFAULT_MODEL + sd_local_model_path: str = None + sd_controlnet: bool = False + device: str = DEFAULT_DEVICE + gui: bool = False + no_gui_auto_close: bool = False + no_half: bool = False + cpu_offload: bool = False + disable_nsfw: bool = False + sd_cpu_textencoder: bool = False + enable_xformers: bool = False + local_files_only: bool = False + model_dir: str = DEFAULT_MODEL_DIR + input: str = None + output_dir: str = None + # plugins + enable_interactive_seg: bool = False + enable_remove_bg: bool = False + enable_realesrgan: bool = False + realesrgan_device: str = "cpu" + realesrgan_model: str = RealESRGANModelName.realesr_general_x4v3.value + enable_gfpgan: bool = False + gfpgan_device: str = "cpu" + enable_restoreformer: bool = False + restoreformer_device: str = "cpu" + enable_gif: bool = False + + +def load_config(installer_config: str): + if os.path.exists(installer_config): + with open(installer_config, "r", encoding="utf-8") as f: + return Config(**json.load(f)) + else: + return Config() diff --git a/lama_cleaner/parse_args.py b/lama_cleaner/parse_args.py index 576f6a7..4f9ed07 100644 --- a/lama_cleaner/parse_args.py +++ b/lama_cleaner/parse_args.py @@ -166,8 +166,6 @@ def parse_args(): exit() if args.load_installer_config: - from lama_cleaner.web_config import load_config - if args.installer_config and not os.path.exists(args.installer_config): parser.error(f"args.installer_config={args.installer_config} not exists") diff --git a/lama_cleaner/web_config.py b/lama_cleaner/web_config.py index 93bae99..0f806e3 100644 --- a/lama_cleaner/web_config.py +++ b/lama_cleaner/web_config.py @@ -4,52 +4,12 @@ from datetime import datetime import gradio as gr from loguru import logger -from pydantic import BaseModel from lama_cleaner.const import * _config_file = None -class Config(BaseModel): - host: str = "127.0.0.1" - port: int = 8080 - model: str = DEFAULT_MODEL - sd_local_model_path: str = None - sd_controlnet: bool = False - device: str = DEFAULT_DEVICE - gui: bool = False - no_gui_auto_close: bool = False - no_half: bool = False - cpu_offload: bool = False - disable_nsfw: bool = False - sd_cpu_textencoder: bool = False - enable_xformers: bool = False - local_files_only: bool = False - model_dir: str = DEFAULT_MODEL_DIR - input: str = None - output_dir: str = None - # plugins - enable_interactive_seg: bool = False - enable_remove_bg: bool = False - enable_realesrgan: bool = False - realesrgan_device: str = "cpu" - realesrgan_model: str = RealESRGANModelName.realesr_general_x4v3.value - enable_gfpgan: bool = False - gfpgan_device: str = "cpu" - enable_restoreformer: bool = False - restoreformer_device: str = "cpu" - enable_gif: bool = False - - -def load_config(installer_config: str): - if os.path.exists(installer_config): - with open(installer_config, "r", encoding="utf-8") as f: - return Config(**json.load(f)) - else: - return Config() - - def save_config( host, port, diff --git a/requirements.txt b/requirements.txt index 0368182..34590a8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,7 +13,7 @@ yacs markupsafe==2.0.1 scikit-image==0.19.3 diffusers[torch]==0.14.0 -transformers>=4.25.1 +transformers==4.27.4 gradio piexif==1.1.3 safetensors