Spaces:
Sleeping
Sleeping
File size: 7,399 Bytes
9507532 f3026b8 9507532 0fc3f5c 9507532 06f1eac 75d19ab 9507532 a288991 9507532 a288991 9507532 75d19ab 9507532 eb74057 9507532 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
"""
CSS and HTML content for the MapAnything Gradio application.
This module contains all the CSS styles and HTML content blocks
used in the Gradio interface.
"""
# CSS Styles for the Gradio interface
GRADIO_CSS = """
.custom-log * {
font-style: italic;
font-size: 22px !important;
background-image: linear-gradient(120deg, #ffb366 0%, #ffa366 60%, #ff9966 100%);
-webkit-background-clip: text;
background-clip: text;
font-weight: bold !important;
color: transparent !important;
text-align: center !important;
}
.example-log * {
font-style: italic;
font-size: 16px !important;
background-image: linear-gradient(120deg, #ffb366 0%, #ffa366 60%, #ff9966 100%);
-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
"""
logo_style = "display: none;" if not logo_base64 else ""
logo_src = logo_base64 or ""
return f"""
<div style="display: flex; align-items: center; margin-bottom: 20px;">
<img src="{logo_src}" alt="WAI Logo" style="height: 40px; margin-right: 15px; {logo_style}">
<h1 style="margin: 0;"><span style="color: #ffb366;">MapAnything:</span> <span style="color: #555555;">Metric 3D Scene Reconstruction</span></h1>
</div>
<p>
<a href="https://github.com/facebookresearch/map-anything">๐ GitHub Repository</a> |
<a href="https://map-anything.github.io/">๐ Project Page</a>
</p>
"""
def get_description_html():
"""
Generate the main description and getting started HTML.
Returns:
str: HTML string for the description
"""
return """
<div style="font-size: 16px; line-height: 1.5;">
<p>Upload a video or a set of images to create a 3D reconstruction of a scene or object. Scan Spectrum takes these images and generates 3D point clouds directly from multi-view images.</p>
<p>This demo demonstrates the use of image inputs only. However, MapAnything is extremely flexible and supports any combination of inputs (images, calibration, poses & depth). For trying out memory efficient inference or additional inputs like cameras & depth, please check out the code in our <a href="https://github.com/facebookresearch/map-anything">Github repo</a>.</p>
<h3>Getting Started:</h3>
<ol>
<li><strong>Upload Your Data:</strong> Use the "Upload Video" or "Upload Images" buttons on the left to provide your input. Videos will be automatically split into individual frames (one frame per second).</li>
<li><strong>Preview:</strong> Your uploaded images will appear in the gallery on the left.</li>
<li><strong>Reconstruct:</strong> Click the "Reconstruct" button to start the 3D reconstruction process.</li>
<li><strong>Visualize:</strong> The 3D reconstruction will appear in the viewer on the right. You can rotate, pan, and zoom to explore the model, and download the GLB file. Note the visualization of 3D points may be slow for a large number of input images.</li>
<li>
<strong>Adjust Reconstruction & Visualization (Optional):</strong>
You can fine-tune the visualization using the options below the viewer
<details style="display:inline;">
<summary style="display:inline;">(<strong>click to expand</strong>):</summary>
<ul>
<li><em>Show Camera:</em> Toggle the display of estimated camera positions.</li>
<li><em>Show Mesh:</em> Use meshes for the prediction visualization.</li>
<li><em>Show Points from Frame:</em> Select specific frames to display in the viewer.</li>
<li><em>Filter Black Background:</em> Remove black background pixels.</li>
<li><em>Filter White Background:</em> Remove white background pixels.</li>
</ul>
</details>
</li>
</ol>
<p><strong style="color: #555555;">Please note:</strong> <span style="color: #555555;">The inference time changes based on the amount of input images, for e.g., less than 1 second for up to 50 views. However, downloading model weights and visualizing 3D points may take tens of seconds. Please be patient or, for faster visualization, use a local machine to run our demo from our <a href="https://github.com/facebookresearch/map-anything">GitHub repository</a>. </span></p>
</div>
"""
def get_acknowledgements_html():
"""
Generate the acknowledgements section HTML.
Returns:
str: HTML string for the acknowledgements
"""
return """
<hr style="margin-top: 40px; margin-bottom: 20px;">
<div style="text-align: center; font-size: 14px; color: #666; margin-bottom: 20px;">
<h3>Acknowledgements</h3>
<p>This site builds upon code from:</p>
<ul style="list-style: none; padding: 0;">
<li>๐ <a href="https://github.com/microsoft/MoGe">MoGe (and MoGe2) on GitHub (and HuggingFace)</a></li>
<li>๐ <a href="https://github.com/facebookresearch/vggt">VGGT on GitHub</a></li>
</ul>
<p>We extend our gratitude to these projects for their valuable contributions to the research community.</p>
</div>
"""
def get_gradio_theme():
"""
Get the configured Gradio theme.
Returns:
gr.themes.Base: Configured Gradio theme
"""
import gradio as gr
return gr.themes.Base(
primary_hue=gr.themes.Color(
c100="#ffedd5",
c200="#ffddb3",
c300="rgba(242.78125, 182.89427563548466, 120.32579495614034, 1)",
c400="#fb923c",
c50="#fff7ed",
c500="#f97316",
c600="#ea580c",
c700="#c2410c",
c800="#9a3412",
c900="#7c2d12",
c950="#6c2e12",
),
secondary_hue="amber",
)
# Measure tab instructions HTML
MEASURE_INSTRUCTIONS_HTML = """
### Click on the image to measure the distance between two points.
"""
|