Skip to content

Commit

Permalink
Merge pull request AUTOMATIC1111#11199 from akx/makedirs
Browse files Browse the repository at this point in the history
Use os.makedirs(..., exist_ok=True)
  • Loading branch information
AUTOMATIC1111 authored Jun 27, 2023
2 parents 001cbd3 + 165ab44 commit a9e7a3d
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 15 deletions.
4 changes: 1 addition & 3 deletions modules/codeformer_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@


def setup_model(dirname):
global model_path
if not os.path.exists(model_path):
os.makedirs(model_path)
os.makedirs(model_path, exist_ok=True)

path = modules.paths.paths.get("CodeFormer", None)
if path is None:
Expand Down
3 changes: 1 addition & 2 deletions modules/extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@

extensions = []

if not os.path.exists(extensions_dir):
os.makedirs(extensions_dir)
os.makedirs(extensions_dir, exist_ok=True)


def active():
Expand Down
5 changes: 1 addition & 4 deletions modules/gfpgan_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,8 @@ def gfpgan_fix_faces(np_image):


def setup_model(dirname):
global model_path
if not os.path.exists(model_path):
os.makedirs(model_path)

try:
os.makedirs(model_path, exist_ok=True)
from gfpgan import GFPGANer
from facexlib import detection, parsing # noqa: F401
global user_path
Expand Down
3 changes: 1 addition & 2 deletions modules/modelloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ def cleanup_models():

def move_files(src_path: str, dest_path: str, ext_filter: str = None):
try:
if not os.path.exists(dest_path):
os.makedirs(dest_path)
os.makedirs(dest_path, exist_ok=True)
if os.path.exists(src_path):
for file in os.listdir(src_path):
fullpath = os.path.join(src_path, file)
Expand Down
3 changes: 1 addition & 2 deletions modules/sd_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ def calculate_shorthash(self):


def setup_model():
if not os.path.exists(model_path):
os.makedirs(model_path)
os.makedirs(model_path, exist_ok=True)

enable_midas_autodownload()

Expand Down
3 changes: 1 addition & 2 deletions modules/textual_inversion/autocrop.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,7 @@ def download_and_cache_models(dirname):
download_url = 'https://github.com/opencv/opencv_zoo/blob/91fb0290f50896f38a0ab1e558b74b16bc009428/models/face_detection_yunet/face_detection_yunet_2022mar.onnx?raw=true'
model_file_name = 'face_detection_yunet.onnx'

if not os.path.exists(dirname):
os.makedirs(dirname)
os.makedirs(dirname, exist_ok=True)

cache_file = os.path.join(dirname, model_file_name)
if not os.path.exists(cache_file):
Expand Down

0 comments on commit a9e7a3d

Please sign in to comment.