Skip to content

Commit

Permalink
Revert "[Bug nranks_download] (#3073)" (#3101)
Browse files Browse the repository at this point in the history
This reverts commit 148ad7b.
  • Loading branch information
Sunting78 authored Mar 27, 2023
1 parent ea4f4fa commit 24dbd54
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 29 deletions.
2 changes: 1 addition & 1 deletion configs/portraitnet/portraitnet_eg1800_224x224_46k.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,5 @@ model:
backbone:
type: MobileNetV2_x1_0
pretrained: https://paddleseg.bj.bcebos.com/dygraph/backbone/mobilenetv2_x1_0_ssld.tar.gz
add_edge: False
add_edge: True
num_classes: 2
43 changes: 15 additions & 28 deletions paddleseg/utils/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,34 +146,21 @@ def download_file_and_uncompress(url,
shutil.rmtree(extraname)
full_path = os.path.join(extraname,
filename) if filename is not None else extraname

rank_id_curr_node = int(os.environ.get("PADDLE_RANK_IN_NODE", 0))

if not os.path.exists(
full_path): # If pretrained model exists, skip download process.
lock_path = extraname + '.download.lock'
with open(lock_path, 'w'): # touch
os.utime(lock_path, None)
if rank_id_curr_node == 0:
if not os.path.exists(savename):
if not os.path.exists(savepath):
_download_file(url, savepath, print_progress)

if (not tarfile.is_tarfile(savepath)) and (
not zipfile.is_zipfile(savepath)):
if not os.path.exists(extraname):
os.makedirs(extraname)

else:
savename = _uncompress_file(savepath, extrapath,
delete_file, print_progress)
savename = os.path.join(extrapath, savename)

shutil.move(savename, extraname)
os.remove(lock_path)

else:
while os.path.exists(lock_path):
time.sleep(0.5)

if not os.path.exists(savename):
if not os.path.exists(savepath):
_download_file(url, savepath, print_progress)

if (not tarfile.is_tarfile(savepath)) and (
not zipfile.is_zipfile(savepath)):
if not os.path.exists(extraname):
os.makedirs(extraname)
shutil.move(savepath, extraname)
return extraname

savename = _uncompress_file(savepath, extrapath, delete_file,
print_progress)
savename = os.path.join(extrapath, savename)
shutil.move(savename, extraname)
return extraname

0 comments on commit 24dbd54

Please sign in to comment.