Spaces:
Sleeping
Sleeping
Commit Β·
1984142
1
Parent(s): 4e2a788
UI redesign: match SentiEnhance mockup - light theme, teal accents, satellite navbar, improved layout
Browse files62 unmodified lines636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501512 unmodified lines1541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582591 unmodified line2612622632642652662672682692702712722732742752761 unmodified line2782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793801 unmodified line3823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534541 unmodified line45645745845946046146246346446546662 unmodified lines# ============================================================CSS = """/* Google Font */@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');body, .gradio-container {font-family: 'Inter', sans-serif !important;background-color: #f8fafc !important;}/* Hide default Gradio padding/footers */footer { display: none !important; }.gradio-container { max-width: 100% !important; padding: 0 !important; margin: 0 !important; }/* Top Navbar */.top-nav {background: linear-gradient(135deg, #03182b 0%, #07355c 100%);padding: 20px 40px;display: flex;justify-content: space-between;align-items: center;color: white;}.nav-left { display: flex; align-items: center; gap: 16px; }.nav-logo-icon { width: 36px; height: 36px; fill: #38bdf8; }.nav-title { display: flex; flex-direction: column; }.nav-logo-text { font-size: 1.6rem; font-weight: 700; color: #38bdf8; margin: 0; line-height: 1.1; }.nav-logo-text span { color: white; }.nav-subtitle { font-size: 0.8rem; color: #cbd5e1; margin: 0; }.nav-links { display: flex; gap: 30px; font-size: 0.95rem; align-items: center; }.nav-links a { color: #cbd5e1; text-decoration: none; font-weight: 500; transition: color 0.2s; }.nav-links a:hover { color: white; }.nav-links a.active { color: white; border-bottom: 2px solid white; padding-bottom: 4px; }.nav-btn { background: #34d399; color: #064e3b !important; padding: 10px 20px; border-radius: 6px; font-weight: 600; text-decoration: none; transition: background 0.2s; }.nav-btn:hover { background: #10b981; }/* Sidebar */.sidebar-container { background: #f8fafc; padding: 30px 20px; height: 100%; border-right: 1px solid #e2e8f0; display: flex; flex-direction: column; justify-content: space-between; }.sidebar-links { display: flex; flex-direction: column; gap: 8px; }.sidebar-link { display: flex; align-items: center; padding: 14px 20px; border-radius: 10px; color: #475569; text-decoration: none; font-weight: 500; font-size: 0.95rem; gap: 16px; transition: background 0.2s; cursor: pointer; }.sidebar-link:hover { background: #f1f5f9; }.sidebar-link.active { background: #d1fae5; color: #065f46; font-weight: 600; }.sidebar-link svg { width: 20px; height: 20px; }.sidebar-banner { background: #e0f2fe; padding: 24px 20px; border-radius: 16px; text-align: center; color: #0369a1; display: flex; flex-direction: column; align-items: center; gap: 12px; }.sidebar-banner svg { width: 40px; height: 40px; color: #0284c7; }.sidebar-banner div { font-weight: 600; font-size: 0.95rem; line-height: 1.4; }/* Main Content Area */.main-wrapper { padding: 30px 40px; }.page-title { font-size: 2.2rem; font-weight: 700; color: #0f172a; margin: 0 0 8px; letter-spacing: -0.5px; }.page-title span { color: #0369a1; }.page-subtitle { color: #64748b; font-size: 1.05rem; margin: 0 0 30px; }/* Upload box */.upload-card { background: white !important; border-radius: 16px !important; padding: 0 !important; border: 1px dashed #cbd5e1 !important; box-shadow: 0 4px 20px rgba(0,0,0,0.03) !important; overflow: hidden; }/* Model Select & Enhance Button */.model-card { background: white; border-radius: 12px; padding: 20px; border: 1px solid #e2e8f0; box-shadow: 0 4px 6px rgba(0,0,0,0.02); margin-bottom: 20px; }.model-card-title { font-size: 1rem; font-weight: 600; color: #1e293b; margin-bottom: 12px; }.model-info-box { background: #f0f9ff; color: #0369a1; padding: 14px; border-radius: 8px; font-size: 0.85rem; margin-top: 12px; display: flex; gap: 12px; align-items: flex-start; line-height: 1.5; }#enhance-btn { background: #0f9d58 !important; color: white !important; font-weight: 600 !important; font-size: 1.1rem !important; padding: 16px !important; border-radius: 8px !important; border: none !important; width: 100%; transition: all 0.2s; }#enhance-btn:hover { background: #0b8043 !important; transform: translateY(-1px); }/* Features List */.features-card { background: #f8fafc; border-radius: 12px; padding: 24px; border: 1px solid #e2e8f0; height: 100%; display: flex; flex-direction: column; justify-content: center; }.features-title { font-size: 1.1rem; font-weight: 600; color: #0f172a; margin-bottom: 20px; }.feature-item { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; color: #334155; font-size: 0.95rem; font-weight: 500; }.feature-icon { width: 24px; height: 24px; color: #0f9d58; flex-shrink: 0; }/* Results */.results-header { font-size: 1.4rem; font-weight: 700; color: #0f172a; margin: 40px 0 20px; }.image-card { border-radius: 12px !important; overflow: hidden; border: 1px solid #e2e8f0; background: white; padding: 0 !important; box-shadow: 0 4px 12px rgba(0,0,0,0.04); }/* Buttons */.download-col { display: flex; flex-direction: column; gap: 12px; padding-top: 36px; }.btn-primary { background: #0f9d58 !important; color: white !important; padding: 12px 16px !important; border-radius: 8px !important; font-weight: 600 !important; text-align: center; border: none !important; }.btn-outline { background: white !important; color: #334155 !important; border: 1px solid #cbd5e1 !important; padding: 12px 16px !important; border-radius: 8px !important; font-weight: 500 !important; text-align: center; box-shadow: 0 1px 2px rgba(0,0,0,0.02) !important; }/* Footer */.footer-strip { background: #03182b; color: white; padding: 24px 40px; display: flex; justify-content: space-between; align-items: center; font-size: 0.9rem; margin-top: 40px; }.footer-left { display: flex; gap: 10px; align-items: center; color: #cbd5e1; }.footer-left strong { color: white; }.footer-links { display: flex; gap: 24px; color: #94a3b8; align-items: center; }.footer-links a { color: #94a3b8; text-decoration: none; transition: color 0.2s; }.footer-links a:hover { color: white; }"""# ============================================================2 unmodified linesdef run_super_resolution(image_path, model_choice, progress=gr.Progress()):if image_path is None:raise gr.Error("β οΈ Please upload a satellite image before running.")model_map = {"HAT-SAT (Recommended)": "hatsat", "ESRGAN (Baseline)": "esrgan"}selected_model = model_map.get(model_choice)if selected_model is None:raise gr.Error("β οΈ Please select a valid model.")if not isinstance(image_path, list):image_path = [image_path]is_tiff = Falseif len(image_path) == 3:paths = [str(p) for p in image_path]if not all(p.lower().endswith(('.tif', '.tiff')) for p in paths):raise gr.Error("β οΈ When uploading multiple files, they must all be TIFF files.")red_path = next((p for p in paths if "B04" in p.upper()), None)green_path = next((p for p in paths if "B03" in p.upper()), None)blue_path = next((p for p in paths if "B02" in p.upper()), None)if not (red_path and green_path and blue_path):paths = sorted(paths)blue_path, green_path, red_path = paths[0], paths[1], paths[2]try:with rasterio.open(red_path) as src_r, rasterio.open(green_path) as src_g, rasterio.open(blue_path) as src_b:profile = src_r.profile.copy()profile.update(count=3)if not (src_r.width == src_g.width == src_b.width and src_r.height == src_g.height == src_b.height):raise gr.Error("β οΈ The uploaded bands have mismatched dimensions.")r_data = src_r.read(1)g_data = src_g.read(1)b_data = src_b.read(1)data = np.stack([r_data, g_data, b_data], axis=-1)input_w, input_h = src_r.width, src_r.heightis_tiff = Trueexcept Exception as e:raise gr.Error(f"β οΈ Error reading 3-band TIFFs: {str(e)}")if data.dtype != np.uint8:data = normalize_rgb(data)original_image = Image.fromarray(data, mode="RGB")elif len(image_path) == 1:file_path = str(image_path[0])is_tiff = file_path.lower().endswith(('.tif', '.tiff'))if is_tiff:try:with rasterio.open(file_path) as src:profile = src.profile.copy()count = src.countif count not in [1, 3, 4]:raise gr.Error(f"β οΈ Unsupported band count: {count}. Expected 1, 3, or 4 bands.")if count == 3:data = src.read([1, 2, 3])data = np.transpose(data, (1, 2, 0))elif count == 4:data = src.read([1, 2, 3])data = np.transpose(data, (1, 2, 0))else:data = src.read(1)data = np.stack([data, data, data], axis=-1)input_w, input_h = src.width, src.heightexcept rasterio.errors.RasterioIOError:raise gr.Error("β οΈ Corrupted TIFF or unsupported format.")except Exception as e:raise gr.Error(f"β οΈ Error reading TIFF: {str(e)}")if data.dtype == np.uint8:passelse:data = normalize_rgb(data)original_image = Image.fromarray(data, mode="RGB")else:try:original_image = Image.open(file_path).convert("RGB")input_w, input_h = original_image.sizeexcept Exception:raise gr.Error("β οΈ Could not read image.")else:raise gr.Error("β οΈ Please upload either 1 file (multiband image) or 3 files (B04, B03, B02 GeoTIFFs).")if input_w < 16 or input_h < 16:raise gr.Error(f"β οΈ Image too small ({input_w}x{input_h}). Please upload an image at least 16x16 pixels.")if input_w > 1024 or input_h > 1024:raise gr.Error(f"β οΈ Image too large ({input_w}x{input_h}). Please use images up to 1024x1024 pixels.")start_time = time.time()try:progress(0.5, desc=f"Running {selected_model} 4x super-resolution (ZeroGPU) π")if selected_model == "hatsat":result = infer_hatsat(original_image)else:1 unmodified lineexcept Exception as e:raise gr.Error(f"{selected_model} inference failed: {e}")progress(0.9, desc="Finalising output π")# Generate PNG downloadtmp_png = tempfile.NamedTemporaryFile(suffix=f"_sr_{selected_model}_4x.png", delete=False)result.save(tmp_png.name, format="PNG")tmp_png.close()out_png = tmp_png.name# Generate TIFF download if input was TIFFif is_tiff:tmp_tiff = tempfile.NamedTemporaryFile(suffix=f"_sr_{selected_model}_4x_georef.tif", delete=False)tmp_tiff.close()save_sr_geotiff(result, profile, tmp_tiff.name, scale=4)1 unmodified lineelse:out_tiff = Noneprogress(1.0, desc="Done.")# Return: original preview, enhanced preview, png download, tiff downloadreturn original_image, result, gr.update(value=out_png, interactive=True), gr.update(value=out_tiff, interactive=True)# ============================================================# HTML COMPONENTS# ============================================================TOP_NAV = """<div class="top-nav"><div class="nav-left"><svg class="nav-logo-icon" viewBox="0 0 24 24"><path d="M12 2L2 22h20L12 2zm0 4.2l6.8 13.8H5.2L12 6.2z"/><path d="M12 10.5l-2.5 5h5z"/></svg><div class="nav-title"><h1 class="nav-logo-text">Senti<span>Enhance</span></h1><p class="nav-subtitle">AI-Powered Super-Resolution for Sentinel-2 Imagery</p></div></div><div class="nav-links"><a href="#" class="active">Home</a><a href="#">About</a><a href="#">How It Works</a><a href="#">Use Cases</a><a href="#">Contact</a><a href="#" class="nav-btn">Get Started</a></div></div>"""SIDEBAR = """<div class="sidebar-container"><div class="sidebar-links"><a href="#" class="sidebar-link active"><svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"></path></svg>Super-Resolution</a><a href="#" class="sidebar-link"><svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"></path></svg>Compare</a><a href="#" class="sidebar-link"><svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"></path></svg>Image Gallery</a><a href="#" class="sidebar-link"><svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path></svg>Documentation</a><a href="#" class="sidebar-link"><svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>About Project</a></div><div class="sidebar-banner"><svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3.055 11H5a2 2 0 012 2v1a2 2 0 002 2 2 2 0 012 2v2.945M8 3.935V5.5A2.5 2.5 0 0010.5 8h.5a2 2 0 012 2 2 2 0 104 0 2 2 0 012-2h1.064M15 20.488V18a2 2 0 012-2h3.064M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg><div>Satellite data<br>for a sustainable<br>future</div></div></div>"""WHY_USE_US = """<div class="features-title">Why Use Our Platform?</div><div class="feature-item"><svg class="feature-icon" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z"></path></svg>AI-powered super-resolution</div><div class="feature-item"><svg class="feature-icon" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 7v10c0 2.21 3.582 4 8 4s8-1.79 8-4V7M4 7c0 2.21 3.582 4 8 4s8-1.79 8-4M4 7c0-2.21 3.582-4 8-4s8 1.79 8 4m0 5c0 2.21-3.582 4-8 4s-8-1.79-8-4"></path></svg>Supports Sentinel-2 imagery</div><div class="feature-item"><svg class="feature-icon" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z"></path><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 11a3 3 0 11-6 0 3 3 0 016 0z"></path></svg>Preserves geospatial metadata</div><div class="feature-item"><svg class="feature-icon" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9.75 17L9 20l-1 1h8l-1-1-.75-3M3 13h18M5 17h14a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"></path></svg>Easy to use web interface</div><div class="feature-item"><svg class="feature-icon" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3.055 11H5a2 2 0 012 2v1a2 2 0 002 2 2 2 0 012 2v2.945M8 3.935V5.5A2.5 2.5 0 0010.5 8h.5a2 2 0 012 2 2 2 0 104 0 2 2 0 012-2h1.064M15 20.488V18a2 2 0 012-2h3.064M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>Free for research & education</div>"""FOOTER = """<div class="footer-strip"><div class="footer-left"><strong>SentiEnhance</strong> | AI for a Sustainable Planet</div><div class="footer-links"><a href="#">Privacy Policy</a> |<a href="#">Terms of Use</a> |<a href="#">Contact</a><a href="#"><svg width="18" height="18" fill="currentColor" viewBox="0 0 24 24"><path d="M19 0h-14c-2.761 0-5 2.239-5 5v14c0 2.761 2.239 5 5 5h14c2.762 0 5-2.239 5-5v-14c0-2.761-2.238-5-5-5zm-11 19h-3v-11h3v11zm-1.5-12.268c-.966 0-1.75-.79-1.75-1.764s.784-1.764 1.75-1.764 1.75.79 1.75 1.764-.783 1.764-1.75 1.764zm13.5 12.268h-3v-5.604c0-3.368-4-3.113-4 0v5.604h-3v-11h3v1.765c1.396-2.586 7-2.777 7 2.476v6.759z"/></svg></a><a href="#"><svg width="18" height="18" fill="currentColor" viewBox="0 0 24 24"><path d="M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"/></svg></a></div></div>"""1 unmodified line# APP LAYOUT# ============================================================with gr.Blocks(theme=gr.themes.Base(), css=CSS) as demo:gr.HTML(TOP_NAV)with gr.Row():with gr.Column(scale=1, min_width=240, elem_classes="sidebar"):gr.HTML(SIDEBAR)with gr.Column(scale=5, elem_classes="main-wrapper"):gr.HTML("""<h2 class="page-title">Enhance <span>Sentinel-2</span> Satellite Images</h2><p class="page-subtitle">Upload your Sentinel-2 image (GeoTIFF, TIFF, JP2, or PNG) and use AI to generate a high-resolution version.</p>""")with gr.Row():with gr.Column(scale=4, elem_classes="upload-card"):input_image = gr.File(label="Drag & drop your satellite image here",file_count="multiple",file_types=["image", ".tif", ".tiff", ".jp2"])with gr.Column(scale=3):with gr.Group(elem_classes="model-card"):gr.HTML("<div class='model-card-title'>Model Selection</div>")model_selector = gr.Dropdown(choices=["HAT-SAT (Recommended)", "ESRGAN (Baseline)"],value="HAT-SAT (Recommended)",show_label=False,container=False)gr.HTML("""<div class="model-info-box"><svg width="20" height="20" fill="currentColor" viewBox="0 0 24 24"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"/></svg><span><strong>HAT-SAT:</strong> State-of-the-art model for satellite image super-resolution with high detail and spectral consistency.</span></div>""")enhance_btn = gr.Button("β¨ Enhance Image", elem_id="enhance-btn")gr.HTML("<div style='text-align:center; font-size:0.85rem; color:#94a3b8; margin-top:8px;'>Processing may take a few moments...</div>")with gr.Column(scale=3, elem_classes="features-card"):gr.HTML(WHY_USE_US)# Results Sectiongr.HTML("<div class='results-header'>Results</div>")with gr.Row():with gr.Column(scale=4, elem_classes="image-card"):original_image = gr.Image(label="Original (Sentinel-2, 10m)", type="pil", interactive=False)with gr.Column(scale=4, elem_classes="image-card"):enhanced_image = gr.Image(label="Enhanced (HAT-SAT, 2x)", type="pil", interactive=False)with gr.Column(scale=3, elem_classes="download-col"):gr.HTML("<div style='font-weight:700; font-size:1.05rem; color:#0f172a; margin-bottom:4px;'>Download & Share</div>")download_png = gr.DownloadButton("π₯ Download Enhanced Image", elem_classes="btn-primary")download_tiff = gr.DownloadButton("π Download as GeoTIFF", elem_classes="btn-outline")compare_btn = gr.Button("π Compare Images", elem_classes="btn-outline")share_btn = gr.Button("π Share Result", elem_classes="btn-outline")gr.HTML(FOOTER)# ============================================================# EVENTS# ============================================================enhance_btn.click(fn=run_super_resolution,inputs=[input_image, model_selector],1 unmodified lineshow_progress="full",)# Interactive elements that don't do anything functionally but can show alertsdef show_alert():gr.Info("This feature is coming soon!")compare_btn.click(fn=show_alert)share_btn.click(fn=show_alert)# ============================================================62 unmodified lines636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715722 unmodified lines5755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696701 unmodified line6726736746756766776786796806816826836846851 unmodified line6876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198201 unmodified line8228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429431 unmodified line94594694794894995095195295395462 unmodified lines# ============================================================CSS = """@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');*, *::before, *::after { box-sizing: border-box; }body, .gradio-container {font-family: 'Inter', sans-serif !important;background-color: #f0f4f8 !important;margin: 0 !important;padding: 0 !important;}footer { display: none !important; }.gradio-container { max-width: 100% !important; padding: 0 !important; margin: 0 !important; }.main { padding: 0 !important; }/* ββ TOP NAVBAR ββ */.top-nav {background: linear-gradient(135deg, #0a2540 0%, #0e4a6e 40%, #1a6b5a 100%);background-size: cover;padding: 18px 40px;display: flex;justify-content: space-between;align-items: center;position: relative;overflow: hidden;min-height: 90px;border-bottom: 2px solid rgba(32, 201, 151, 0.3);}.top-nav::before {content: '';position: absolute;inset: 0;background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%2320c997' fill-opacity='0.04'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");opacity: 0.5;}.nav-left {display: flex;align-items: center;gap: 14px;z-index: 1;}.nav-logo-wrap {background: rgba(32, 201, 151, 0.15);border: 1px solid rgba(32, 201, 151, 0.3);border-radius: 12px;padding: 8px 10px;display: flex;align-items: center;justify-content: center;}.nav-logo-wrap svg { width: 38px; height: 38px; }.nav-brand { display: flex; flex-direction: column; }.nav-brand-name {font-size: 1.75rem;font-weight: 800;color: #20c997;line-height: 1;letter-spacing: -0.5px;margin: 0;}.nav-brand-name span { color: #ffffff; }.nav-brand-sub {font-size: 0.78rem;color: rgba(255,255,255,0.65);margin: 3px 0 0;font-weight: 400;letter-spacing: 0.2px;}.nav-brand-tagline {font-size: 0.72rem;color: rgba(255,255,255,0.45);margin: 1px 0 0;font-style: italic;}.nav-center {display: flex;gap: 28px;align-items: center;z-index: 1;}.nav-center a {color: rgba(255,255,255,0.80);text-decoration: none;font-size: 0.9rem;font-weight: 500;padding-bottom: 2px;transition: color 0.2s;border-bottom: 2px solid transparent;}.nav-center a:hover { color: #fff; }.nav-center a.active {color: #fff;border-bottom-color: #20c997;padding-bottom: 2px;}.nav-right {display: flex;align-items: center;gap: 20px;z-index: 1;}.nav-quote {text-align: right;color: rgba(255,255,255,0.65);font-size: 0.78rem;font-style: italic;line-height: 1.5;}.nav-quote strong { color: rgba(255,255,255,0.85); font-style: normal; }.nav-cta {background: #20c997;color: #0a2540 !important;padding: 10px 22px;border-radius: 8px;font-weight: 700;font-size: 0.9rem;text-decoration: none;white-space: nowrap;transition: background 0.2s, transform 0.15s;border: none;display: inline-block;}.nav-cta:hover { background: #12b886; transform: translateY(-1px); }/* ββ BODY LAYOUT ββ */.body-layout {display: flex;min-height: calc(100vh - 90px - 64px);background: #f0f4f8;}/* ββ SIDEBAR ββ */.sidebar-wrap {width: 220px;min-width: 220px;background: #ffffff;border-right: 1px solid #e2e8f0;display: flex;flex-direction: column;justify-content: space-between;padding: 24px 14px 24px;flex-shrink: 0;}.sidebar-nav { display: flex; flex-direction: column; gap: 4px; }.sb-item {display: flex;align-items: center;gap: 12px;padding: 11px 14px;border-radius: 10px;color: #64748b;text-decoration: none;font-size: 0.9rem;font-weight: 500;transition: background 0.15s, color 0.15s;cursor: pointer;}.sb-item svg { width: 18px; height: 18px; flex-shrink: 0; }.sb-item:hover { background: #f1f5f9; color: #1e293b; }.sb-item.active {background: #e6faf4;color: #0e7c5a;font-weight: 600;}.sb-item.active svg { color: #20c997; }.sb-badge {margin-left: auto;background: #20c997;color: #fff;font-size: 0.65rem;font-weight: 700;padding: 2px 7px;border-radius: 20px;letter-spacing: 0.3px;}.sidebar-globe {background: linear-gradient(135deg, #e6faf4 0%, #dbeafe 100%);border-radius: 16px;padding: 20px 16px;text-align: center;display: flex;flex-direction: column;align-items: center;gap: 10px;}.sidebar-globe svg { width: 44px; height: 44px; }.sidebar-globe-text {font-size: 0.82rem;font-weight: 600;color: #334155;line-height: 1.5;}/* ββ MAIN AREA ββ */.main-area {flex: 1;padding: 32px 36px 40px;min-width: 0;}/* Page Title */.page-title {font-size: 2rem;font-weight: 800;color: #0f172a;margin: 0 0 6px;letter-spacing: -0.5px;}.page-title em {color: #20c997;font-style: normal;}.page-subtitle {font-size: 0.95rem;color: #64748b;margin: 0 0 24px;font-weight: 400;}/* ββ INPUT ROW ββ */.input-row {display: grid;grid-template-columns: 1fr 280px 240px;gap: 20px;margin-bottom: 24px;}/* Upload Card */.upload-panel {background: white;border: 2px dashed #cbd5e1;border-radius: 16px;padding: 36px 28px;display: flex;flex-direction: column;align-items: center;justify-content: center;text-align: center;min-height: 240px;transition: border-color 0.2s;cursor: pointer;}.upload-panel:hover { border-color: #20c997; }.upload-icon-wrap {width: 68px; height: 68px;background: #e6faf4;border-radius: 50%;display: flex; align-items: center; justify-content: center;margin-bottom: 16px;}.upload-icon-wrap svg { width: 32px; height: 32px; color: #20c997; }.upload-title {font-size: 1rem;font-weight: 600;color: #1e293b;margin: 0 0 4px;}.upload-or { font-size: 0.85rem; color: #94a3b8; margin: 8px 0; }.upload-btn-fake {background: #1a6b9a;color: white;padding: 10px 24px;border-radius: 8px;font-weight: 600;font-size: 0.9rem;display: inline-block;margin-bottom: 14px;letter-spacing: 0.1px;}.upload-formats {font-size: 0.8rem;color: #94a3b8;line-height: 1.6;}/* Override Gradio file upload appearance */.upload-card .wrap { min-height: 240px !important; }.upload-card { background: white !important; border: 2px dashed #cbd5e1 !important; border-radius: 16px !important; }.upload-card:hover { border-color: #20c997 !important; }/* Model Panel */.model-panel {background: white;border-radius: 16px;border: 1px solid #e2e8f0;padding: 20px;display: flex;flex-direction: column;gap: 14px;box-shadow: 0 1px 8px rgba(0,0,0,0.04);}.model-label {font-size: 0.88rem;font-weight: 700;color: #1e293b;text-transform: uppercase;letter-spacing: 0.5px;}.model-badge-row { display: flex; align-items: center; gap: 8px; }.model-best-badge {background: #dcfce7;color: #166534;font-size: 0.7rem;font-weight: 700;padding: 3px 9px;border-radius: 20px;letter-spacing: 0.3px;}.model-info {background: #eff6ff;border-left: 3px solid #3b82f6;padding: 10px 12px;border-radius: 0 8px 8px 0;font-size: 0.8rem;color: #1e40af;line-height: 1.55;}.model-info strong { color: #1e3a8a; }#enhance-btn {background: linear-gradient(135deg, #10b981 0%, #20c997 100%) !important;color: white !important;font-weight: 700 !important;font-size: 1rem !important;padding: 14px !important;border-radius: 10px !important;border: none !important;width: 100%;letter-spacing: 0.2px;box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35) !important;transition: all 0.2s !important;}#enhance-btn:hover {box-shadow: 0 6px 20px rgba(16, 185, 129, 0.45) !important;transform: translateY(-1px) !important;}.processing-hint {font-size: 0.78rem;color: #94a3b8;text-align: center;margin-top: -4px;font-style: italic;}/* Why Use Panel */.why-panel {background: white;border-radius: 16px;border: 1px solid #e2e8f0;padding: 20px;box-shadow: 0 1px 8px rgba(0,0,0,0.04);}.why-title {font-size: 0.88rem;font-weight: 700;color: #1e293b;text-transform: uppercase;letter-spacing: 0.5px;margin: 0 0 14px;}.why-item {display: flex;align-items: flex-start;gap: 10px;padding: 8px 0;border-bottom: 1px solid #f1f5f9;font-size: 0.845rem;color: #475569;font-weight: 500;line-height: 1.4;}.why-item:last-child { border-bottom: none; }.why-item svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }/* ββ RESULTS SECTION ββ */.results-title {font-size: 1.25rem;font-weight: 700;color: #0f172a;margin: 8px 0 18px;display: flex;align-items: center;gap: 10px;}.results-title::after {content: '';flex: 1;height: 1px;background: #e2e8f0;}.results-row {display: grid;grid-template-columns: 1fr 1fr 220px;gap: 20px;align-items: start;}.img-card {background: white;border: 1px solid #e2e8f0;border-radius: 16px;overflow: hidden;box-shadow: 0 2px 12px rgba(0,0,0,0.05);}.img-card-header {display: flex;align-items: center;justify-content: space-between;padding: 12px 16px;border-bottom: 1px solid #f1f5f9;}.img-card-label {font-size: 0.82rem;font-weight: 600;color: #475569;display: flex;align-items: center;gap: 8px;}.img-label-dot {width: 8px; height: 8px;border-radius: 50%;flex-shrink: 0;}.img-label-dot.original { background: #94a3b8; }.img-label-dot.enhanced { background: #20c997; }/* Gradio image overrides */.result-img-wrap { padding: 0 !important; }.result-img-wrap .svelte-1uydkzt { border-radius: 0 0 16px 16px !important; }/* Download Panel */.dl-panel {background: white;border: 1px solid #e2e8f0;border-radius: 16px;padding: 20px;display: flex;flex-direction: column;gap: 10px;box-shadow: 0 2px 12px rgba(0,0,0,0.05);}.dl-title {font-size: 0.88rem;font-weight: 700;color: #1e293b;text-transform: uppercase;letter-spacing: 0.5px;margin-bottom: 4px;}#dl-png-btn {background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;color: white !important;font-weight: 600 !important;font-size: 0.88rem !important;padding: 12px 14px !important;border-radius: 9px !important;border: none !important;width: 100%;box-shadow: 0 3px 10px rgba(16, 185, 129, 0.3) !important;transition: all 0.15s !important;}#dl-png-btn:hover { transform: translateY(-1px) !important; }.btn-outline-custom {background: white !important;color: #475569 !important;border: 1.5px solid #e2e8f0 !important;font-size: 0.86rem !important;font-weight: 500 !important;padding: 11px 14px !important;border-radius: 9px !important;width: 100%;transition: all 0.15s !important;text-align: left !important;}.btn-outline-custom:hover {border-color: #20c997 !important;color: #0e7c5a !important;background: #f0fdf9 !important;}/* ββ FOOTER ββ */.site-footer {background: #0a2540;color: rgba(255,255,255,0.6);padding: 18px 40px;display: flex;justify-content: space-between;align-items: center;font-size: 0.82rem;}.footer-brand { color: rgba(255,255,255,0.85); font-weight: 600; }.footer-links { display: flex; gap: 20px; align-items: center; }.footer-links a {color: rgba(255,255,255,0.55);text-decoration: none;transition: color 0.2s;}.footer-links a:hover { color: white; }.footer-socials { display: flex; gap: 14px; align-items: center; }.footer-socials a { color: rgba(255,255,255,0.5); transition: color 0.2s; }.footer-socials a:hover { color: white; }"""# ============================================================2 unmodified linesdef run_super_resolution(image_path, model_choice, progress=gr.Progress()):if image_path is None:raise gr.Error("Please upload a satellite image before running.")model_map = {"HAT-SAT (Recommended)": "hatsat", "ESRGAN (Baseline)": "esrgan"}selected_model = model_map.get(model_choice)if selected_model is None:raise gr.Error("Please select a valid model.")if not isinstance(image_path, list):image_path = [image_path]is_tiff = Falseprofile = Noneif len(image_path) == 3:paths = [str(p) for p in image_path]if not all(p.lower().endswith(('.tif', '.tiff')) for p in paths):raise gr.Error("When uploading multiple files, all must be TIFF files.")red_path = next((p for p in paths if "B04" in p.upper()), None)green_path = next((p for p in paths if "B03" in p.upper()), None)blue_path = next((p for p in paths if "B02" in p.upper()), None)if not (red_path and green_path and blue_path):paths = sorted(paths)blue_path, green_path, red_path = paths[0], paths[1], paths[2]try:with rasterio.open(red_path) as src_r, rasterio.open(green_path) as src_g, rasterio.open(blue_path) as src_b:profile = src_r.profile.copy()profile.update(count=3)if not (src_r.width == src_g.width == src_b.width and src_r.height == src_g.height == src_b.height):raise gr.Error("Uploaded bands have mismatched dimensions.")r_data = src_r.read(1)g_data = src_g.read(1)b_data = src_b.read(1)data = np.stack([r_data, g_data, b_data], axis=-1)input_w, input_h = src_r.width, src_r.heightis_tiff = Trueexcept gr.Error:raiseexcept Exception as e:raise gr.Error(f"Error reading 3-band TIFFs: {str(e)}")if data.dtype != np.uint8:data = normalize_rgb(data)original_image = Image.fromarray(data, mode="RGB")elif len(image_path) == 1:file_path = str(image_path[0])is_tiff = file_path.lower().endswith(('.tif', '.tiff'))if is_tiff:try:with rasterio.open(file_path) as src:profile = src.profile.copy()count = src.countif count not in [1, 3, 4]:raise gr.Error(f"Unsupported band count: {count}. Expected 1, 3, or 4.")if count in [3, 4]:data = src.read([1, 2, 3])data = np.transpose(data, (1, 2, 0))else:data = src.read(1)data = np.stack([data, data, data], axis=-1)input_w, input_h = src.width, src.heightexcept gr.Error:raiseexcept rasterio.errors.RasterioIOError:raise gr.Error("Corrupted TIFF or unsupported format.")except Exception as e:raise gr.Error(f"Error reading TIFF: {str(e)}")if data.dtype != np.uint8:data = normalize_rgb(data)original_image = Image.fromarray(data, mode="RGB")else:try:original_image = Image.open(file_path).convert("RGB")input_w, input_h = original_image.sizeexcept Exception:raise gr.Error("Could not read image file.")else:raise gr.Error("Please upload 1 file (multiband) or 3 files (B04, B03, B02 bands).")if input_w < 16 or input_h < 16:raise gr.Error(f"Image too small ({input_w}x{input_h}). Minimum is 16x16 pixels.")if input_w > 1024 or input_h > 1024:raise gr.Error(f"Image too large ({input_w}x{input_h}). Maximum is 1024x1024 pixels.")try:progress(0.5, desc=f"Running {selected_model} 4x super-resolution...")if selected_model == "hatsat":result = infer_hatsat(original_image)else:1 unmodified lineexcept Exception as e:raise gr.Error(f"{selected_model} inference failed: {e}")progress(0.9, desc="Finalising output...")tmp_png = tempfile.NamedTemporaryFile(suffix=f"_sr_{selected_model}_4x.png", delete=False)result.save(tmp_png.name, format="PNG")tmp_png.close()out_png = tmp_png.nameif is_tiff and profile is not None:tmp_tiff = tempfile.NamedTemporaryFile(suffix=f"_sr_{selected_model}_4x_georef.tif", delete=False)tmp_tiff.close()save_sr_geotiff(result, profile, tmp_tiff.name, scale=4)1 unmodified lineelse:out_tiff = Noneprogress(1.0, desc="Done!")return original_image, result, gr.update(value=out_png, interactive=True), gr.update(value=out_tiff, interactive=True)# ============================================================# HTML SNIPPETS# ============================================================TOP_NAV = """<div class="top-nav"><div class="nav-left"><div class="nav-logo-wrap"><svg viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="24" cy="24" r="10" stroke="#20c997" stroke-width="2.5"/><ellipse cx="24" cy="24" rx="22" ry="10" stroke="#20c997" stroke-width="2" opacity="0.5"/><ellipse cx="24" cy="24" rx="10" ry="22" stroke="#20c997" stroke-width="2" opacity="0.5"/><circle cx="24" cy="24" r="3" fill="#20c997"/><circle cx="38" cy="12" r="3" fill="#20c997" opacity="0.8"/><line x1="36.5" y1="13.5" x2="27" y2="21" stroke="#20c997" stroke-width="1.5" opacity="0.6"/></svg></div><div class="nav-brand"><h1 class="nav-brand-name">Senti<span>Enhance</span></h1><p class="nav-brand-sub">AI-Powered Super-Resolution for Sentinel-2 Imagery</p><p class="nav-brand-tagline">Sharper Insights for a Better Tomorrow</p></div></div><div class="nav-center"><a href="#" class="active">Home</a><a href="#">About</a><a href="#">How It Works</a><a href="#">Use Cases</a><a href="#">Contact</a></div><div class="nav-right"><div class="nav-quote"><em>"From Pixels to Possibilities"</em><br><strong>for a Smarter, Greener India πΏ</strong></div><a href="#" class="nav-cta">Get Started</a></div></div>"""SIDEBAR_HTML = """<div class="sidebar-wrap"><div class="sidebar-nav"><a href="#" class="sb-item active"><svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"/></svg>Super-Resolution<span class="sb-badge">BETA</span></a><a href="#" class="sb-item"><svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"/></svg>Compare</a><a href="#" class="sb-item"><svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"/></svg>Image Gallery</a><a href="#" class="sb-item"><svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"/></svg>Documentation</a><a href="#" class="sb-item"><svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/></svg>About Project</a></div><div class="sidebar-globe"><svg viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="32" cy="32" r="28" stroke="#20c997" stroke-width="2"/><ellipse cx="32" cy="32" rx="14" ry="28" stroke="#20c997" stroke-width="1.5" opacity="0.5"/><line x1="4" y1="32" x2="60" y2="32" stroke="#20c997" stroke-width="1.5" opacity="0.4"/><line x1="32" y1="4" x2="32" y2="60" stroke="#20c997" stroke-width="1.5" opacity="0.4"/><ellipse cx="32" cy="32" rx="28" ry="10" stroke="#20c997" stroke-width="1.5" opacity="0.3"/><circle cx="20" cy="28" r="3" fill="#3b82f6" opacity="0.7"/><circle cx="38" cy="38" r="2" fill="#10b981" opacity="0.7"/></svg><div class="sidebar-globe-text">Satellite data<br>for a sustainable<br>future</div></div></div>"""WHY_HTML = """<div class="why-panel"><div class="why-title">Why Use Our Platform?</div><div class="why-item"><svg fill="none" stroke="#10b981" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z"/></svg>AI-powered super-resolution</div><div class="why-item"><svg fill="none" stroke="#3b82f6" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 7v10c0 2.21 3.582 4 8 4s8-1.79 8-4V7M4 7c0 2.21 3.582 4 8 4s8-1.79 8-4M4 7c0-2.21 3.582-4 8-4s8 1.79 8 4m0 5c0 2.21-3.582 4-8 4s-8-1.79-8-4"/></svg>Supports Sentinel-2 imagery</div><div class="why-item"><svg fill="none" stroke="#8b5cf6" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z"/><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 11a3 3 0 11-6 0 3 3 0 016 0z"/></svg>Preserves geospatial metadata</div><div class="why-item"><svg fill="none" stroke="#f59e0b" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9.75 17L9 20l-1 1h8l-1-1-.75-3M3 13h18M5 17h14a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"/></svg>Easy to use web interface</div><div class="why-item"><svg fill="none" stroke="#10b981" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3.055 11H5a2 2 0 012 2v1a2 2 0 002 2 2 2 0 012 2v2.945M8 3.935V5.5A2.5 2.5 0 0010.5 8h.5a2 2 0 012 2 2 2 0 104 0 2 2 0 012-2h1.064M15 20.488V18a2 2 0 012-2h3.064M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/></svg>Free for research & education</div></div>"""FOOTER_HTML = """<div class="site-footer"><div><span class="footer-brand">SentiEnhance</span> | AI for a Sustainable Planet</div><div class="footer-links"><a href="#">Privacy Policy</a><span>|</span><a href="#">Terms of Use</a><span>|</span><a href="#">Contact</a></div><div class="footer-socials"><a href="#" title="LinkedIn"><svg width="18" height="18" fill="currentColor" viewBox="0 0 24 24"><path d="M19 0h-14c-2.761 0-5 2.239-5 5v14c0 2.761 2.239 5 5 5h14c2.762 0 5-2.239 5-5v-14c0-2.761-2.238-5-5-5zm-11 19h-3v-11h3v11zm-1.5-12.268c-.966 0-1.75-.79-1.75-1.764s.784-1.764 1.75-1.764 1.75.79 1.75 1.764-.783 1.764-1.75 1.764zm13.5 12.268h-3v-5.604c0-3.368-4-3.113-4 0v5.604h-3v-11h3v1.765c1.396-2.586 7-2.777 7 2.476v6.759z"/></svg></a><a href="#" title="GitHub"><svg width="18" height="18" fill="currentColor" viewBox="0 0 24 24"><path d="M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"/></svg></a><a href="#" title="YouTube"><svg width="18" height="18" fill="currentColor" viewBox="0 0 24 24"><path d="M23.495 6.205a3.007 3.007 0 00-2.088-2.088c-1.87-.501-9.396-.501-9.396-.501s-7.507-.01-9.396.501A3.007 3.007 0 00.527 6.205a31.247 31.247 0 00-.522 5.805 31.247 31.247 0 00.522 5.783 3.007 3.007 0 002.088 2.088c1.868.502 9.396.502 9.396.502s7.506 0 9.396-.502a3.007 3.007 0 002.088-2.088 31.247 31.247 0 00.5-5.783 31.247 31.247 0 00-.5-5.805zM9.609 15.601V8.408l6.264 3.602z"/></svg></a></div></div>"""1 unmodified line# APP LAYOUT# ============================================================with gr.Blocks(css=CSS, title="SentiEnhance β AI Satellite Super-Resolution") as demo:gr.HTML(TOP_NAV)with gr.Row(equal_height=True):# ββ SIDEBAR ββwith gr.Column(scale=0, min_width=220, elem_id="sidebar-col"):gr.HTML(SIDEBAR_HTML)# ββ MAIN CONTENT ββwith gr.Column(scale=1, elem_id="main-col"):gr.HTML("""<div class="main-area"><h2 class="page-title">Enhance <em>Sentinel-2</em> Satellite Images</h2><p class="page-subtitle">Upload your Sentinel-2 image (GeoTIFF, TIFF, JP2, or PNG) and use AI to generate a high-resolution version.</p></div>""")with gr.Row():# Uploadwith gr.Column(scale=5):input_image = gr.File(label="Drag & drop your satellite image here",file_count="multiple",file_types=["image", ".tif", ".tiff", ".jp2"],elem_classes="upload-card")gr.HTML("""<div style="text-align:center; font-size:0.8rem; color:#94a3b8; margin-top:8px;">Supported formats: .tif, .tiff, .jp2, .png (Sentinel-2 imagery)</div>""")# Model + Enhancewith gr.Column(scale=3):gr.HTML("""<div class="model-panel"><div class="model-label">Model Selection</div></div>""")model_selector = gr.Dropdown(choices=["HAT-SAT (Recommended)", "ESRGAN (Baseline)"],value="HAT-SAT (Recommended)",show_label=False,container=False)gr.HTML("""<div style="display:flex;align-items:center;gap:8px;margin:6px 0 2px;"><span style="font-size:0.78rem;color:#64748b;">Selected Model:</span><span class="model-best-badge">Best Quality</span></div><div class="model-info"><strong>HAT-SAT:</strong> State-of-the-art model for satellite image super-resolution with high detail and spectral consistency.</div>""")enhance_btn = gr.Button("β¨ Enhance Image", elem_id="enhance-btn")gr.HTML('<div class="processing-hint">Processing may take a few moments...</div>')# Why Use Uswith gr.Column(scale=3):gr.HTML(WHY_HTML)# ββ RESULTS ββgr.HTML('<div class="results-title">Results</div>')with gr.Row():with gr.Column(scale=5, elem_classes="img-card"):gr.HTML("""<div class="img-card-header"><div class="img-card-label"><span class="img-label-dot original"></span>Original (Sentinel-2, 10m)</div></div>""")original_image = gr.Image(label="",type="pil",interactive=False,show_label=False,elem_classes="result-img-wrap")with gr.Column(scale=5, elem_classes="img-card"):gr.HTML("""<div class="img-card-header"><div class="img-card-label"><span class="img-label-dot enhanced"></span>Enhanced (HAT-SAT, 4x)</div></div>""")enhanced_image = gr.Image(label="",type="pil",interactive=False,show_label=False,elem_classes="result-img-wrap")with gr.Column(scale=3):gr.HTML('<div class="dl-panel"><div class="dl-title">Download & Share</div></div>')download_png = gr.DownloadButton("π₯ Download Enhanced Image",elem_id="dl-png-btn")download_tiff = gr.DownloadButton("π Download as GeoTIFF",elem_classes="btn-outline-custom")compare_btn = gr.Button("π Compare Images", elem_classes="btn-outline-custom")share_btn = gr.Button("π Share Result", elem_classes="btn-outline-custom")gr.HTML(FOOTER_HTML)# ββ EVENTS ββenhance_btn.click(fn=run_super_resolution,inputs=[input_image, model_selector],1 unmodified lineshow_progress="full",)def show_soon():gr.Info("This feature is coming soon!")compare_btn.click(fn=show_soon)share_btn.click(fn=show_soon)# ============================================================
app.py+732-244