Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added apps/__init__.py
Empty file.
27 changes: 27 additions & 0 deletions apps/app_style.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from gradio.themes import Soft
from gradio.themes.utils.colors import gray, neutral, slate, stone, teal, zinc

lighting_css = """
<style>
#lighter_mesh canvas {
filter: brightness(1.9) !important;
}
</style>
"""

image_css = """
<style>
.image_fit .image-frame {
object-fit: contain !important;
height: 100% !important;
}
</style>
"""

custom_theme = Soft(
primary_hue=stone,
secondary_hue=gray,
radius_size="md",
text_size="sm",
spacing_size="sm",
)
33 changes: 3 additions & 30 deletions apps/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
import torch.nn.functional as F
import trimesh
from easydict import EasyDict as edict
from gradio.themes import Soft
from gradio.themes.utils.colors import gray, neutral, slate, stone, teal, zinc
from PIL import Image
from embodied_gen.data.backproject_v2 import entrypoint as backproject_api
from embodied_gen.data.differentiable_render import entrypoint as render_api
Expand Down Expand Up @@ -151,6 +149,7 @@ def build_covariance_from_scaling_rotation(
TMP_DIR = os.path.join(
os.path.dirname(os.path.abspath(__file__)), "sessions/imageto3d"
)
os.makedirs(TMP_DIR, exist_ok=True)
elif os.getenv("GRADIO_APP") == "textto3d":
RBG_REMOVER = RembgRemover()
RBG14_REMOVER = BMGG14Remover()
Expand All @@ -168,6 +167,7 @@ def build_covariance_from_scaling_rotation(
TMP_DIR = os.path.join(
os.path.dirname(os.path.abspath(__file__)), "sessions/textto3d"
)
os.makedirs(TMP_DIR, exist_ok=True)
elif os.getenv("GRADIO_APP") == "texture_edit":
PIPELINE_IP = build_texture_gen_pipe(
base_ckpt_dir="./weights",
Expand All @@ -182,34 +182,7 @@ def build_covariance_from_scaling_rotation(
TMP_DIR = os.path.join(
os.path.dirname(os.path.abspath(__file__)), "sessions/texture_edit"
)

os.makedirs(TMP_DIR, exist_ok=True)


lighting_css = """
<style>
#lighter_mesh canvas {
filter: brightness(1.9) !important;
}
</style>
"""

image_css = """
<style>
.image_fit .image-frame {
object-fit: contain !important;
height: 100% !important;
}
</style>
"""

custom_theme = Soft(
primary_hue=stone,
secondary_hue=gray,
radius_size="md",
text_size="sm",
spacing_size="sm",
)
os.makedirs(TMP_DIR, exist_ok=True)


def start_session(req: gr.Request) -> None:
Expand Down
4 changes: 1 addition & 3 deletions apps/image_to_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,16 @@
from glob import glob

import gradio as gr
from app_style import custom_theme, image_css, lighting_css
from common import (
MAX_SEED,
VERSION,
active_btn_by_content,
custom_theme,
end_session,
extract_3d_representations_v2,
extract_urdf,
get_seed,
image_css,
image_to_3d,
lighting_css,
preprocess_image_fn,
preprocess_sam_image_fn,
select_point,
Expand Down
4 changes: 1 addition & 3 deletions apps/text_to_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,18 @@


import gradio as gr
from app_style import custom_theme, image_css, lighting_css
from common import (
MAX_SEED,
VERSION,
active_btn_by_text_content,
custom_theme,
end_session,
extract_3d_representations_v2,
extract_urdf,
get_cached_image,
get_seed,
get_selected_image,
image_css,
image_to_3d,
lighting_css,
start_session,
text2image_fn,
)
Expand Down
4 changes: 1 addition & 3 deletions apps/texture_edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,16 @@

os.environ["GRADIO_APP"] = "texture_edit"
import gradio as gr
from app_style import custom_theme, image_css, lighting_css
from common import (
MAX_SEED,
VERSION,
backproject_texture_v2,
custom_theme,
end_session,
generate_condition,
generate_texture_mvimages,
get_seed,
get_selected_image,
image_css,
lighting_css,
render_result_video,
start_session,
)
Expand Down
Loading