Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions examples/volume_renderer.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import time
import taichi as ti
import argparse
import numpy as np
Expand Down Expand Up @@ -181,10 +182,24 @@ def main():

if not os.path.exists('bunny_128.bin'):
url = 'https://github.com/yuanming-hu/taichi_assets/releases/download/llvm8/bunny_128.bin'
print(':: Downloading {}'.format(url))
report = lambda bn, bs, size: print(':: Downloading {:.2f}/{:.2f} MiB ...'.format(bn * bs / 1e6, size / 1e6), end='\r')
urllib.request.urlretrieve(url, 'bunny_128.bin', reporthook=report)
print(':: Download finished' + ' ' * 10)
attempt = 0
while True:
try:
print(':: Downloading {}'.format(url))
report = lambda bn, bs, size: print(':: Downloading {:.2f}/{:.2f} MiB ...'.format(bn * bs / 1e6, size / 1e6), end='\r')
urllib.request.urlretrieve(url, 'bunny_128.bin', reporthook=report)
print(':: Download finished' + ' ' * 10)
break
except Exception as e:
print(":: download failed")
if attempt <= 5:
print(':: retrying')
time.sleep(1)
else:
print(':: already tried 5 times, exit')
raise e
attempt += 1


print(':: Loading bunny_128 ...')
volume = np.fromfile("bunny_128.bin", dtype=np.float32).reshape(
Expand Down