# flake8: noqa: E501 # Copyright (c) 2025 ByteDance Ltd. and/or its affiliates # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """ CSS and HTML content for the Depth Anything 3 Gradio application. This module contains all the CSS styles and HTML content blocks used in the Gradio interface. """ # CSS Styles for the Gradio interface # Color palette: # - Primary: #2563EB (Modern Blue) # - Secondary: #14B8A6 (Vibrant Teal) # - Accent: #F97316 (Electric Orange) # - Neutrals: #F9FAFB to #111827 GRADIO_CSS = """ /* Add Font Awesome CDN with all styles including brands and colors */ @import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css'); /* Force light mode */ html, body, .gradio-container { color-scheme: light !important; } /* CSS Custom Properties for theming */ :root { --primary: #2563EB; --primary-light: #3B82F6; --primary-dark: #1D4ED8; --secondary: #14B8A6; --secondary-light: #2DD4BF; --secondary-dark: #0D9488; --accent: #F97316; --accent-light: #FB923C; --accent-dark: #EA580C; --neutral-50: #F9FAFB; --neutral-100: #F3F4F6; --neutral-200: #E5E7EB; --neutral-300: #D1D5DB; --neutral-400: #9CA3AF; --neutral-500: #6B7280; --neutral-600: #4B5563; --neutral-700: #374151; --neutral-800: #1F2937; --neutral-900: #111827; } /* Add custom styles for colored icons */ .fa-color-blue { color: var(--primary); } .fa-color-purple { color: #8B5CF6; } .fa-color-cyan { color: var(--secondary); } .fa-color-green { color: #10B981; } .fa-color-yellow { color: var(--accent); } .fa-color-red { color: #EF4444; } .link-btn { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; padding: 12px 24px; border-radius: 50px; font-weight: 500; transition: all 0.3s ease; } /* Dark mode theme */ @media (prefers-color-scheme: dark) { html, body { background: var(--neutral-800); color: var(--neutral-50); } .gradio-container { background: var(--neutral-800); color: var(--neutral-50); } .link-btn { background: rgba(20, 184, 166, 0.2); color: white; border: 1px solid rgba(20, 184, 166, 0.4); } .link-btn:hover { background: rgba(20, 184, 166, 0.35); transform: translateY(-2px); box-shadow: 0 8px 25px rgba(20, 184, 166, 0.25); } .tech-bg { background: linear-gradient(135deg, var(--neutral-900), var(--neutral-800)); position: relative; overflow: hidden; } .tech-bg::before { content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: radial-gradient(circle at 20% 80%, rgba(37, 99, 235, 0.15) 0%, transparent 50%), radial-gradient(circle at 80% 20%, rgba(20, 184, 166, 0.15) 0%, transparent 50%), radial-gradient(circle at 40% 40%, rgba(249, 115, 22, 0.1) 0%, transparent 50%); animation: techPulse 8s ease-in-out infinite; } .gradio-container .panel, .gradio-container .block, .gradio-container .form { background: rgba(0, 0, 0, 0.3); border: 1px solid rgba(20, 184, 166, 0.2); border-radius: 10px; } .gradio-container * { color: var(--neutral-50); } .gradio-container label { color: var(--neutral-200); } .gradio-container .markdown { color: var(--neutral-200); } } /* Light mode theme */ @media (prefers-color-scheme: light) { html, body { background: var(--neutral-50); color: var(--neutral-800); } .gradio-container { background: var(--neutral-50); color: var(--neutral-800); } .tech-bg { background: linear-gradient(135deg, var(--neutral-50), var(--neutral-100)); position: relative; overflow: hidden; } .link-btn { background: rgba(20, 184, 166, 0.12); color: var(--neutral-700); border: 1px solid rgba(20, 184, 166, 0.3); } .link-btn:hover { background: rgba(20, 184, 166, 0.2); transform: translateY(-2px); box-shadow: 0 8px 25px rgba(20, 184, 166, 0.2); } .tech-bg::before { content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: radial-gradient(circle at 20% 80%, rgba(37, 99, 235, 0.08) 0%, transparent 50%), radial-gradient(circle at 80% 20%, rgba(20, 184, 166, 0.08) 0%, transparent 50%), radial-gradient(circle at 40% 40%, rgba(249, 115, 22, 0.06) 0%, transparent 50%); animation: techPulse 8s ease-in-out infinite; } .gradio-container .panel, .gradio-container .block, .gradio-container .form { background: rgba(255, 255, 255, 0.9); border: 1px solid rgba(20, 184, 166, 0.2); border-radius: 10px; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05); } .gradio-container * { color: var(--neutral-800); } .gradio-container label { color: var(--neutral-600); } .gradio-container .markdown { color: var(--neutral-600); } } @keyframes techPulse { 0%, 100% { opacity: 0.5; } 50% { opacity: 0.8; } } /* Custom log with tech gradient */ .custom-log * { font-style: italic; font-size: 22px !important; background: linear-gradient(135deg, var(--primary), var(--secondary)); background-size: 400% 400%; -webkit-background-clip: text; background-clip: text; font-weight: bold !important; color: transparent !important; text-align: center !important; animation: techGradient 3s ease infinite; } @keyframes techGradient { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } } @keyframes metricPulse { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } } @keyframes pointcloudPulse { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } } @keyframes camerasPulse { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } } @keyframes gaussiansPulse { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } } /* Special colors for key terms - Global styles with gradient animations */ .metric-text { background: linear-gradient(135deg, #10B981, #059669); background-size: 200% 200%; -webkit-background-clip: text; background-clip: text; color: transparent !important; font-weight: 700; animation: metricPulse 3s ease infinite; } .pointcloud-text { background: linear-gradient(135deg, #10B981, #059669); background-size: 200% 200%; -webkit-background-clip: text; background-clip: text; color: transparent !important; font-weight: 700; animation: pointcloudPulse 3s ease infinite; } .cameras-text { background: linear-gradient(135deg, #F97316, #EA580C); background-size: 200% 200%; -webkit-background-clip: text; background-clip: text; color: transparent !important; font-weight: 700; animation: camerasPulse 3s ease infinite; } .gaussians-text { background: linear-gradient(135deg, #2563EB, #1D4ED8); background-size: 200% 200%; -webkit-background-clip: text; background-clip: text; color: transparent !important; font-weight: 700; animation: gaussiansPulse 3s ease infinite; } .example-log * { font-style: italic; font-size: 16px !important; background: linear-gradient(135deg, var(--primary), var(--secondary)); -webkit-background-clip: text; background-clip: text; color: transparent !important; } #my_radio .wrap { display: flex; flex-wrap: nowrap; justify-content: center; align-items: center; } #my_radio .wrap label { display: flex; width: 50%; justify-content: center; align-items: center; margin: 0; padding: 10px 0; box-sizing: border-box; } /* Align navigation buttons with dropdown bottom */ .navigation-row { display: flex !important; align-items: flex-end !important; gap: 8px !important; } .navigation-row > div:nth-child(1), .navigation-row > div:nth-child(3) { align-self: flex-end !important; } .navigation-row > div:nth-child(2) { flex: 1 !important; } /* Make thumbnails clickable with pointer cursor */ .clickable-thumbnail img { cursor: pointer !important; } .clickable-thumbnail:hover img { cursor: pointer !important; opacity: 0.8; transition: opacity 0.3s ease; } /* Make thumbnail containers narrower horizontally */ .clickable-thumbnail { padding: 5px 2px !important; margin: 0 2px !important; } .clickable-thumbnail .image-container { margin: 0 !important; padding: 0 !important; } .scene-info { text-align: center !important; padding: 5px 2px !important; margin: 0 !important; } """ def get_header_html(logo_base64=None): """ Generate the main header HTML with logo and title. Args: logo_base64 (str, optional): Base64 encoded logo image Returns: str: HTML string for the header """ return """

Depth Anything 3

Recovering the Visual Space from Any Views

Project Page Paper Awesome Optimized Fork Original
""" def get_description_html(): """ Generate the main description and getting started HTML. Returns: str: HTML string for the description """ return """

What This Demo Does

Upload images or videosGet Metric Point Clouds, Cameras and Novel ViewsExplore in 3D

Tip: Landscape-oriented images or videos are preferred for best 3D recovering.

""" def get_acknowledgements_html(): """ Generate the acknowledgements section HTML. Returns: str: HTML string for the acknowledgements """ return """

Research Credits & Acknowledgments

Original Research

Depth Anything 3

Previous Versions

Depth-Anything

Depth-Anything-V2

HF demo adapted from Map Anything

""" def get_gradio_theme(): """ Get the configured Gradio theme with modern teal/blue colors. Color palette: - Primary: Teal (#14B8A6) - Secondary: Blue (#2563EB) - Accent: Orange (#F97316) - Neutrals: Clean grays (#F9FAFB to #111827) Returns: gr.themes.Base: Configured Gradio theme """ import gradio as gr return gr.themes.Base( # Primary hue: Teal primary_hue=gr.themes.Color( c50="#F0FDFA", c100="#CCFBF1", c200="#99F6E4", c300="#5EEAD4", c400="#2DD4BF", c500="#14B8A6", c600="#0D9488", c700="#0F766E", c800="#115E59", c900="#134E4A", c950="#042F2E", ), # Secondary hue: Blue secondary_hue=gr.themes.Color( c50="#EFF6FF", c100="#DBEAFE", c200="#BFDBFE", c300="#93C5FD", c400="#60A5FA", c500="#3B82F6", c600="#2563EB", c700="#1D4ED8", c800="#1E40AF", c900="#1E3A8A", c950="#172554", ), # Neutral hue: Clean grays neutral_hue=gr.themes.Color( c50="#F9FAFB", c100="#F3F4F6", c200="#E5E7EB", c300="#D1D5DB", c400="#9CA3AF", c500="#6B7280", c600="#4B5563", c700="#374151", c800="#1F2937", c900="#111827", c950="#030712", ), ) # Measure tab instructions HTML MEASURE_INSTRUCTIONS_HTML = """ ### Click points on the image to compute distance. > Metric scale estimation is difficult on aerial/drone images. """