Spaces:
Running
on
L4
Running
on
L4
Commit
·
de752a5
1
Parent(s):
390338e
Update app.py and navigation.py for UI enhancements and image path correction. Changed primary color theme in app.py and updated image path in navigation.py to reflect new asset.
Browse files- app.py +20 -21
- navigation.py +1 -1
app.py
CHANGED
@@ -13,11 +13,9 @@ import spaces
|
|
13 |
import gradio as gr
|
14 |
import numpy as np
|
15 |
import torch
|
16 |
-
from torchvision.datasets.utils import download_and_extract_archive
|
17 |
-
from einops import repeat
|
18 |
from omegaconf import OmegaConf
|
19 |
from modeling.pipeline import VMemPipeline
|
20 |
-
from diffusers.utils import export_to_video
|
21 |
from scipy.spatial.transform import Rotation, Slerp
|
22 |
from navigation import Navigator
|
23 |
from PIL import Image
|
@@ -48,6 +46,7 @@ IMAGE_PATHS = ['test_samples/oxford.jpg',
|
|
48 |
'test_samples/changi.jpg',
|
49 |
'test_samples/jesus.jpg',]
|
50 |
|
|
|
51 |
# If no images found, create placeholders
|
52 |
if not IMAGE_PATHS:
|
53 |
def create_placeholder_images(num_samples=5, height=HEIGHT, width=WIDTH):
|
@@ -692,7 +691,7 @@ def render_demonstrate(
|
|
692 |
|
693 |
|
694 |
# Create the Gradio Blocks
|
695 |
-
with gr.Blocks(theme=gr.themes.Base(primary_hue="
|
696 |
gr.HTML(
|
697 |
"""
|
698 |
<style>
|
@@ -701,10 +700,10 @@ with gr.Blocks(theme=gr.themes.Base(primary_hue="purple")) as demo:
|
|
701 |
font-weight: bold;
|
702 |
}
|
703 |
#page-title h1 {
|
704 |
-
color: #
|
705 |
}
|
706 |
.task-title h2 {
|
707 |
-
color: #
|
708 |
}
|
709 |
.header-button-row {
|
710 |
gap: 4px !important;
|
@@ -717,7 +716,7 @@ with gr.Blocks(theme=gr.themes.Base(primary_hue="purple")) as demo:
|
|
717 |
gap: 5px !important;
|
718 |
}
|
719 |
.header-button a {
|
720 |
-
border: 1px solid #
|
721 |
}
|
722 |
.header-button .button-icon {
|
723 |
margin-right: 8px;
|
@@ -740,7 +739,7 @@ with gr.Blocks(theme=gr.themes.Base(primary_hue="purple")) as demo:
|
|
740 |
margin-top: 8px;
|
741 |
}
|
742 |
#selected-demo-button {
|
743 |
-
color: #
|
744 |
text-decoration: underline;
|
745 |
}
|
746 |
.demo-button {
|
@@ -760,17 +759,17 @@ with gr.Blocks(theme=gr.themes.Base(primary_hue="purple")) as demo:
|
|
760 |
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
761 |
}
|
762 |
#navigation-gallery .gallery-item.selected {
|
763 |
-
border: 3px solid #
|
764 |
}
|
765 |
/* Upload image styling */
|
766 |
#upload-image {
|
767 |
border-radius: 8px;
|
768 |
-
border: 2px dashed #
|
769 |
padding: 10px;
|
770 |
transition: all 0.3s ease;
|
771 |
}
|
772 |
#upload-image:hover {
|
773 |
-
border-color: #
|
774 |
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
775 |
}
|
776 |
/* Box styling */
|
@@ -778,28 +777,28 @@ with gr.Blocks(theme=gr.themes.Base(primary_hue="purple")) as demo:
|
|
778 |
border-radius: 10px;
|
779 |
margin-bottom: 20px;
|
780 |
padding: 15px;
|
781 |
-
background-color: #
|
782 |
-
border: 1px solid #
|
783 |
}
|
784 |
/* Start Navigation button styling */
|
785 |
button[data-testid="Start Navigation"] {
|
786 |
-
background-color: #
|
787 |
-
border-color: #
|
788 |
color: white !important;
|
789 |
}
|
790 |
button[data-testid="Start Navigation"]:hover {
|
791 |
-
background-color: #
|
792 |
-
border-color: #
|
793 |
}
|
794 |
/* Override Gradio's primary button color */
|
795 |
.gradio-button.primary {
|
796 |
-
background-color: #
|
797 |
-
border-color: #
|
798 |
color: white !important;
|
799 |
}
|
800 |
.gradio-button.primary:hover {
|
801 |
-
background-color: #
|
802 |
-
border-color: #
|
803 |
}
|
804 |
</style>
|
805 |
"""
|
|
|
13 |
import gradio as gr
|
14 |
import numpy as np
|
15 |
import torch
|
|
|
|
|
16 |
from omegaconf import OmegaConf
|
17 |
from modeling.pipeline import VMemPipeline
|
18 |
+
from diffusers.utils import export_to_video
|
19 |
from scipy.spatial.transform import Rotation, Slerp
|
20 |
from navigation import Navigator
|
21 |
from PIL import Image
|
|
|
46 |
'test_samples/changi.jpg',
|
47 |
'test_samples/jesus.jpg',]
|
48 |
|
49 |
+
|
50 |
# If no images found, create placeholders
|
51 |
if not IMAGE_PATHS:
|
52 |
def create_placeholder_images(num_samples=5, height=HEIGHT, width=WIDTH):
|
|
|
691 |
|
692 |
|
693 |
# Create the Gradio Blocks
|
694 |
+
with gr.Blocks(theme=gr.themes.Base(primary_hue="blue")) as demo:
|
695 |
gr.HTML(
|
696 |
"""
|
697 |
<style>
|
|
|
700 |
font-weight: bold;
|
701 |
}
|
702 |
#page-title h1 {
|
703 |
+
color: #002147 !important;
|
704 |
}
|
705 |
.task-title h2 {
|
706 |
+
color: #004080 !important;
|
707 |
}
|
708 |
.header-button-row {
|
709 |
gap: 4px !important;
|
|
|
716 |
gap: 5px !important;
|
717 |
}
|
718 |
.header-button a {
|
719 |
+
border: 1px solid #002147;
|
720 |
}
|
721 |
.header-button .button-icon {
|
722 |
margin-right: 8px;
|
|
|
739 |
margin-top: 8px;
|
740 |
}
|
741 |
#selected-demo-button {
|
742 |
+
color: #004080;
|
743 |
text-decoration: underline;
|
744 |
}
|
745 |
.demo-button {
|
|
|
759 |
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
760 |
}
|
761 |
#navigation-gallery .gallery-item.selected {
|
762 |
+
border: 3px solid #002147;
|
763 |
}
|
764 |
/* Upload image styling */
|
765 |
#upload-image {
|
766 |
border-radius: 8px;
|
767 |
+
border: 2px dashed #002147;
|
768 |
padding: 10px;
|
769 |
transition: all 0.3s ease;
|
770 |
}
|
771 |
#upload-image:hover {
|
772 |
+
border-color: #002147;
|
773 |
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
774 |
}
|
775 |
/* Box styling */
|
|
|
777 |
border-radius: 10px;
|
778 |
margin-bottom: 20px;
|
779 |
padding: 15px;
|
780 |
+
background-color: #002147;
|
781 |
+
border: 1px solid #002147;
|
782 |
}
|
783 |
/* Start Navigation button styling */
|
784 |
button[data-testid="Start Navigation"] {
|
785 |
+
background-color: #004080 !important;
|
786 |
+
border-color: #004080 !important;
|
787 |
color: white !important;
|
788 |
}
|
789 |
button[data-testid="Start Navigation"]:hover {
|
790 |
+
background-color: #002147 !important;
|
791 |
+
border-color: #002147 !important;
|
792 |
}
|
793 |
/* Override Gradio's primary button color */
|
794 |
.gradio-button.primary {
|
795 |
+
background-color: #004080 !important;
|
796 |
+
border-color: #004080 !important;
|
797 |
color: white !important;
|
798 |
}
|
799 |
.gradio-button.primary:hover {
|
800 |
+
background-color: #002147 !important;
|
801 |
+
border-color: #002147 !important;
|
802 |
}
|
803 |
</style>
|
804 |
"""
|
navigation.py
CHANGED
@@ -451,7 +451,7 @@ def main():
|
|
451 |
navigator = Navigator(pipeline, step_size=args.step_size, num_interpolation_frames=args.interpolation_frames)
|
452 |
|
453 |
# Load episode data
|
454 |
-
frame_path = "test_samples/
|
455 |
image, _ = load_img_and_K(frame_path, None, K=None, device=device)
|
456 |
image, _ = transform_img_and_K(image, (config.model.height, config.model.width), mode="crop", K=None)
|
457 |
ori_K = np.array(get_default_intrinsics()[0])
|
|
|
451 |
navigator = Navigator(pipeline, step_size=args.step_size, num_interpolation_frames=args.interpolation_frames)
|
452 |
|
453 |
# Load episode data
|
454 |
+
frame_path = "test_samples/arc_de_tromphe.jpeg"
|
455 |
image, _ = load_img_and_K(frame_path, None, K=None, device=device)
|
456 |
image, _ = transform_img_and_K(image, (config.model.height, config.model.width), mode="crop", K=None)
|
457 |
ori_K = np.array(get_default_intrinsics()[0])
|