Skip to content
This repository has been archived by the owner on Jan 2, 2021. It is now read-only.

Commit

Permalink
Nicer console output while enhancing
Browse files Browse the repository at this point in the history
file.png (tile    4 of    9)

instead of just printing dots
  • Loading branch information
vi committed Nov 11, 2016
1 parent fabe04f commit 689aacd
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion enhance.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,12 +555,21 @@ def process(self, original):
image = np.pad(original, ((p, p), (p, p), (0, 0)), mode='reflect')
output = np.zeros((original.shape[0] * z, original.shape[1] * z, 3), dtype=np.float32)

numtiles=0
for y, x in itertools.product(range(0, original.shape[0], s), range(0, original.shape[1], s)):
numtiles+=1

curtile=1

# Iterate through the tile coordinates and pass them through the network.
for y, x in itertools.product(range(0, original.shape[0], s), range(0, original.shape[1], s)):
img = np.transpose(image[y:y+p*2+s,x:x+p*2+s,:] / 255.0 - 0.5, (2, 0, 1))[np.newaxis].astype(np.float32)
*_, repro = self.model.predict(img)
output[y*z:(y+s)*z,x*z:(x+s)*z,:] = np.transpose(repro[0] + 0.5, (1, 2, 0))[p*z:-p*z,p*z:-p*z,:]
print('.', end='', flush=True)
if curtile > 1:
print("\x7f" * 19, end='')
print("(tile %4d of %4d)"%(curtile,numtiles), end='', flush=True)
curtile+=1
output = output.clip(0.0, 1.0) * 255.0

# Match color histograms if the user specified this option.
Expand Down

0 comments on commit 689aacd

Please sign in to comment.