Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -18,6 +18,8 @@ import math
|
|
| 18 |
from huggingface_hub import hf_hub_download
|
| 19 |
from safetensors.torch import load_file
|
| 20 |
from typing import Union, Tuple
|
|
|
|
|
|
|
| 21 |
from basicsr.archs.rrdbnet_arch import RRDBNet
|
| 22 |
from basicsr.utils.download_util import load_file_from_url
|
| 23 |
from realesrgan import RealESRGANer
|
|
@@ -296,7 +298,7 @@ def infer(
|
|
| 296 |
image_url=None,
|
| 297 |
return_upscaled=False,
|
| 298 |
no_background=False,
|
| 299 |
-
num_images_per_prompt=
|
| 300 |
progress=gr.Progress(track_tqdm=True),
|
| 301 |
):
|
| 302 |
"""
|
|
@@ -308,7 +310,8 @@ def infer(
|
|
| 308 |
rewrite_prompt=False
|
| 309 |
if randomize_seed:
|
| 310 |
seed = random.randint(0, MAX_SEED)
|
| 311 |
-
|
|
|
|
| 312 |
# Set up the generator for reproducibility
|
| 313 |
generator = torch.Generator(device=device).manual_seed(seed)
|
| 314 |
expected_key = os.environ.get("deepseek_key")
|
|
@@ -405,14 +408,14 @@ with gr.Blocks(css=css) as demo:
|
|
| 405 |
show_label=False,
|
| 406 |
type="pil",
|
| 407 |
interactive=True)
|
| 408 |
-
image_url = gr.Textbox(label="", placeholder="")
|
| 409 |
prompt = gr.Text(
|
| 410 |
label="Prompt",
|
| 411 |
show_label=True,
|
| 412 |
placeholder="",
|
| 413 |
)
|
| 414 |
-
return_upscaled = gr.Checkbox(label="", value=False)
|
| 415 |
-
remove_background = gr.Checkbox(label="", value=False)
|
| 416 |
run_button = gr.Button("Edit!", variant="primary")
|
| 417 |
|
| 418 |
with gr.Accordion("Advanced Settings", open=False):
|
|
@@ -469,7 +472,7 @@ with gr.Blocks(css=css) as demo:
|
|
| 469 |
|
| 470 |
with gr.Column():
|
| 471 |
result = gr.Gallery(label="", show_label=False, type="pil")
|
| 472 |
-
upscaled = gr.Image(label="")
|
| 473 |
|
| 474 |
|
| 475 |
gr.on(
|
|
|
|
| 18 |
from huggingface_hub import hf_hub_download
|
| 19 |
from safetensors.torch import load_file
|
| 20 |
from typing import Union, Tuple
|
| 21 |
+
|
| 22 |
+
|
| 23 |
from basicsr.archs.rrdbnet_arch import RRDBNet
|
| 24 |
from basicsr.utils.download_util import load_file_from_url
|
| 25 |
from realesrgan import RealESRGANer
|
|
|
|
| 298 |
image_url=None,
|
| 299 |
return_upscaled=False,
|
| 300 |
no_background=False,
|
| 301 |
+
num_images_per_prompt=4,
|
| 302 |
progress=gr.Progress(track_tqdm=True),
|
| 303 |
):
|
| 304 |
"""
|
|
|
|
| 310 |
rewrite_prompt=False
|
| 311 |
if randomize_seed:
|
| 312 |
seed = random.randint(0, MAX_SEED)
|
| 313 |
+
if return_upscaled or no_background:
|
| 314 |
+
num_images_per_prompt = 1
|
| 315 |
# Set up the generator for reproducibility
|
| 316 |
generator = torch.Generator(device=device).manual_seed(seed)
|
| 317 |
expected_key = os.environ.get("deepseek_key")
|
|
|
|
| 408 |
show_label=False,
|
| 409 |
type="pil",
|
| 410 |
interactive=True)
|
| 411 |
+
image_url = gr.Textbox(label="option", placeholder="")
|
| 412 |
prompt = gr.Text(
|
| 413 |
label="Prompt",
|
| 414 |
show_label=True,
|
| 415 |
placeholder="",
|
| 416 |
)
|
| 417 |
+
return_upscaled = gr.Checkbox(label="upscale", value=False)
|
| 418 |
+
remove_background = gr.Checkbox(label="background remove", value=False)
|
| 419 |
run_button = gr.Button("Edit!", variant="primary")
|
| 420 |
|
| 421 |
with gr.Accordion("Advanced Settings", open=False):
|
|
|
|
| 472 |
|
| 473 |
with gr.Column():
|
| 474 |
result = gr.Gallery(label="", show_label=False, type="pil")
|
| 475 |
+
upscaled = gr.Image(label="upscaled")
|
| 476 |
|
| 477 |
|
| 478 |
gr.on(
|