Spaces:
Sleeping
Sleeping
added resolution info and general info
Browse files
app.py
CHANGED
|
@@ -48,8 +48,32 @@ def swin2sr_upscale(input_image: Image.Image, mode: str):
|
|
| 48 |
|
| 49 |
# ---ensure JPEG-compatible mode ---
|
| 50 |
sr_image = sr_image.convert("RGB")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
# ---- Gradio UI ----
|
| 55 |
with gr.Blocks() as demo:
|
|
@@ -62,7 +86,12 @@ with gr.Blocks() as demo:
|
|
| 62 |
with gr.Row():
|
| 63 |
input_image = gr.Image(type="pil", label="Upload low-res image")
|
| 64 |
output_image = gr.Image(type="pil",format="jpeg", label="4x Super-resolved image")
|
| 65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
mode_dropdown = gr.Dropdown(
|
| 67 |
label="Style",
|
| 68 |
choices=["Clear (OFtB)", "Smooth (Over Smoothing | tuned_1)"],
|
|
|
|
| 48 |
|
| 49 |
# ---ensure JPEG-compatible mode ---
|
| 50 |
sr_image = sr_image.convert("RGB")
|
| 51 |
+
# ----OG and new size ---
|
| 52 |
+
w_sr, h_sr = sr_image.size
|
| 53 |
+
msg = (
|
| 54 |
+
f"Original resolution: {w_lr}×{h_lr} pixels\n"
|
| 55 |
+
f"Super-resolved: {w_sr}×{h_sr} pixels "
|
| 56 |
+
f"(scale factors: {w_sr / w_lr:.1f}×, {h_sr / h_lr:.1f}×)"
|
| 57 |
|
| 58 |
+
ABOUT_TEXT = """
|
| 59 |
+
**About this tool**
|
| 60 |
+
|
| 61 |
+
This is a free image enhancement tool that uses Swin2SR to reconstruct and refine image detail at the pixel level (“pixel refabrication”).
|
| 62 |
+
I built it because many of my own photos are distorted or only exist as low‑quality copies on social media.
|
| 63 |
+
|
| 64 |
+
**Tip for social media images**
|
| 65 |
+
|
| 66 |
+
If your only copy is on Instagram, open Instagram on a computer, view the photo in full‑screen, take a screenshot, and crop it tightly around the image before uploading here.
|
| 67 |
+
|
| 68 |
+
**Usage notes**
|
| 69 |
+
|
| 70 |
+
Processing and queue times can occasionally exceed ten minutes, especially during heavy use.
|
| 71 |
+
If this tool gets regular traffic, I plan to upgrade to a stronger GPU backend.
|
| 72 |
+
|
| 73 |
+
Please reach out if you need any help or have questions.
|
| 74 |
+
"""
|
| 75 |
+
|
| 76 |
+
return sr_image, msg
|
| 77 |
|
| 78 |
# ---- Gradio UI ----
|
| 79 |
with gr.Blocks() as demo:
|
|
|
|
| 86 |
with gr.Row():
|
| 87 |
input_image = gr.Image(type="pil", label="Upload low-res image")
|
| 88 |
output_image = gr.Image(type="pil",format="jpeg", label="4x Super-resolved image")
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
res_info = gr.Markdown("Resolution info.")
|
| 92 |
+
# ---- info / help box ----
|
| 93 |
+
gr.Markdown(ABOUT_TEXT)
|
| 94 |
+
|
| 95 |
mode_dropdown = gr.Dropdown(
|
| 96 |
label="Style",
|
| 97 |
choices=["Clear (OFtB)", "Smooth (Over Smoothing | tuned_1)"],
|