Spaces:
Sleeping
Sleeping
Initialize ImageSlider value
Browse files
app.py
CHANGED
|
@@ -162,6 +162,15 @@ def _prepare_input(image: Image.Image) -> Image.Image:
|
|
| 162 |
return image.resize((TARGET_RESOLUTION, TARGET_RESOLUTION), Image.Resampling.BICUBIC)
|
| 163 |
|
| 164 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
def _gpu_duration(*args, **kwargs) -> int:
|
| 166 |
value = os.environ.get("ASASR_GPU_DURATION", "45")
|
| 167 |
try:
|
|
@@ -276,6 +285,7 @@ with gr.Blocks(title="ASASR Super-Resolution") as demo:
|
|
| 276 |
with gr.Column(scale=2, min_width=420):
|
| 277 |
comparison_slider = ImageSlider(
|
| 278 |
label="Input LR | ASASR HR",
|
|
|
|
| 279 |
type="pil",
|
| 280 |
height=560,
|
| 281 |
position=0.5,
|
|
|
|
| 162 |
return image.resize((TARGET_RESOLUTION, TARGET_RESOLUTION), Image.Resampling.BICUBIC)
|
| 163 |
|
| 164 |
|
| 165 |
+
def _initial_slider_value() -> Tuple[Image.Image, Image.Image]:
|
| 166 |
+
if EXAMPLE_FILES:
|
| 167 |
+
with Image.open(EXAMPLE_FILES[0]) as image:
|
| 168 |
+
preview = _prepare_input(image)
|
| 169 |
+
else:
|
| 170 |
+
preview = Image.new("RGB", (TARGET_RESOLUTION, TARGET_RESOLUTION), "#f8fafc")
|
| 171 |
+
return preview, preview.copy()
|
| 172 |
+
|
| 173 |
+
|
| 174 |
def _gpu_duration(*args, **kwargs) -> int:
|
| 175 |
value = os.environ.get("ASASR_GPU_DURATION", "45")
|
| 176 |
try:
|
|
|
|
| 285 |
with gr.Column(scale=2, min_width=420):
|
| 286 |
comparison_slider = ImageSlider(
|
| 287 |
label="Input LR | ASASR HR",
|
| 288 |
+
value=_initial_slider_value(),
|
| 289 |
type="pil",
|
| 290 |
height=560,
|
| 291 |
position=0.5,
|