Skip to content

Commit d09d1e6

Browse files
Misc
1 parent 5133abc commit d09d1e6

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-3
lines changed

huggingface/HF/NN/CInterpolantVisualization.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import hashlib, json, os, time, glob, sys
2+
import tensorflow as tf
23
import numpy as np
34
import math
45
import imageio
@@ -358,17 +359,19 @@ def _process(self,
358359
def _blurred(self,
359360
VT_fps, VT_seed, VT_initialValues, VT_resolution,
360361
VT_maxBlurRadius, VT_blurSteps,
362+
targetResolution, # replace the target resolution with the VT_resolution
361363
**kwargs
362364
):
363365
VT_resolution = int(VT_resolution)
364-
assert 64 <= VT_resolution <= 512, 'Unexpected resolution'
366+
assert 128 <= VT_resolution <= 512, 'Unexpected resolution'
365367
videoFileName = self._generateFilename(
366368
VT_fps=VT_fps, VT_seed=VT_seed, VT_initialValues=VT_initialValues,
367369
VT_resolution=VT_resolution, VT_maxBlurRadius=VT_maxBlurRadius, VT_blurSteps=VT_blurSteps,
368370
**kwargs
369371
)
370372

371373
blurRadius = np.linspace(0.0, float(VT_maxBlurRadius), int(VT_blurSteps))[::-1]
374+
blurRadius = blurRadius.astype(np.float32)
372375
initialValues = self._initialValuesFor(
373376
initialValues=VT_initialValues, seed=VT_seed, N=VT_resolution ** 2
374377
)
@@ -421,7 +424,7 @@ def __call__(self,
421424
if VT_kind is None: return self._model(**kwargs)
422425
VT_seed = None if VT_seed < 0 else int(VT_seed)
423426
VT_fps = int(VT_fps)
424-
assert VT_kind in ['trajectories', 'process'], f'Unexpected VT_kind: {VT_kind}'
427+
assert VT_kind in ['trajectories', 'process', 'blurred'], f'Unexpected VT_kind: {VT_kind}'
425428

426429
if VT_kind == 'trajectories':
427430
return self._trajectories(

huggingface/HF/UI/areas/visualizeArea.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def imageArea(submit, parameters):
3333
Here you can visualize the image restoration process step by step.
3434
''')
3535
VT_resolution = gr.Slider(
36-
label='Resolution', value=64, minimum=8, maximum=512, step=1
36+
label='Resolution', value=128, minimum=128, maximum=512, step=1
3737
)
3838
# Radio buttons for the displayed values. 'value' or 'x0
3939
VT_show = gr.Radio(
@@ -53,6 +53,34 @@ def imageArea(submit, parameters):
5353
**parameters,
5454
outputs={'video': video}
5555
)
56+
return
57+
58+
def blurVideoArea(submit, parameters):
59+
with gr.Tab(label='Blurred'):
60+
VT_resolution = gr.Slider(
61+
label='Resolution', value=128, minimum=128, maximum=512, step=1
62+
)
63+
VT_maxBlurRadius = gr.Slider(
64+
label='Max Blur Radius', value=8, minimum=1, maximum=100, step=1
65+
)
66+
VT_blurSteps = gr.Slider(
67+
label='Blur Steps', value=10, minimum=1, maximum=100, step=1
68+
)
69+
button = gr.Button(value='Visualize')
70+
video = gr.Video(label='Video', interactive=False)
71+
# Hidden kind parameter
72+
kind = gr.Textbox(label='Kind', value='blurred', visible=False)
73+
# bind button
74+
submit(
75+
btn=button,
76+
VT_kind=kind,
77+
VT_resolution=VT_resolution,
78+
VT_maxBlurRadius=VT_maxBlurRadius,
79+
VT_blurSteps=VT_blurSteps,
80+
**parameters,
81+
outputs={'video': video}
82+
)
83+
return
5684

5785
def visualizeArea(submit):
5886
with gr.Accordion('Visualize Area', open=False):
@@ -73,5 +101,6 @@ def visualizeArea(submit):
73101
)
74102
trajectoriesArea(submit, parameters)
75103
imageArea(submit, parameters)
104+
blurVideoArea(submit, parameters)
76105
pass
77106
return

0 commit comments

Comments
 (0)