Skip to content

Commit

Permalink
🐛 修复默认目录变化导致的保存失败
Browse files Browse the repository at this point in the history
  • Loading branch information
zhulinyv committed Sep 17, 2024
1 parent cbcc6c7 commit 60eefe8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
16 changes: 12 additions & 4 deletions utils/selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def show_first_img(input_path):
return [img], img
except Exception:
logger.error("未输入图片目录或输入的目录为空!")
return None, None


def show_next_img():
Expand All @@ -50,22 +51,28 @@ def show_next_img():
return None, None
except Exception:
logger.error("未输入图片目录或输入的目录为空!")
return None, None


def move_current_img(current_img, output_path):
try:
img_name = os.path.basename(current_img)
shutil.move(current_img, str(Path(output_path) / img_name))
logger.info(f"已将 {current_img} 移动到 {output_path}")
logger.info(f"\n已将 {current_img} 移动到 {output_path}")
return show_next_img()
except Exception:
logger.error("未输入要移动的目录!")
return None, None


def del_current_img(current_img):
send2trash.send2trash(current_img)
logger.info(f"\n已将 {current_img} 移动到回收站")
return show_next_img()
try:
send2trash.send2trash(current_img)
logger.info(f"\n已将 {current_img} 移动到回收站")
return show_next_img()
except Exception:
logger.error("当前未选择图片!")
return None, None


def copy_current_img(current_img, output_path):
Expand All @@ -76,3 +83,4 @@ def copy_current_img(current_img, output_path):
return show_next_img()
except Exception:
logger.error("未输入要复制的目录!")
return None, None
4 changes: 4 additions & 0 deletions utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
from utils.jsondata import headers
from utils.prepare import logger

PATH = os.getcwd()

RESOLUTION = [
"832x1216",
"1216x832",
Expand All @@ -42,6 +44,7 @@
]
NOISE_SCHEDULE = ["native", "karras", "exponential", "polyexponential"]


if env.proxy != "xxx:xxx":
proxies = {
"http": "http://" + env.proxy,
Expand Down Expand Up @@ -235,6 +238,7 @@ def save_image(img_data, type_, seed, choose_game, choose_character, *args):
else:
path = ""
if not os.path.exists(f"./output/{type_}{path}"):
os.chdir(PATH)
os.mkdir(f"./output/{type_}{path}")

if img_data:
Expand Down

0 comments on commit 60eefe8

Please sign in to comment.