xinjie.wang commited on
Commit
b7f1342
·
1 Parent(s): e39cf22
Files changed (2) hide show
  1. app.py +3 -0
  2. common.py +14 -0
app.py CHANGED
@@ -15,6 +15,7 @@ from common import (
15
  preprocess_sam_image_fn,
16
  select_point,
17
  start_session,
 
18
  )
19
  from gradio.themes import Default
20
  from gradio.themes.utils.colors import slate
@@ -22,6 +23,7 @@ from gradio.themes.utils.colors import slate
22
  with gr.Blocks(
23
  delete_cache=(43200, 43200), theme=Default(primary_hue=slate)
24
  ) as demo:
 
25
  gr.Markdown(
26
  f"""
27
  ## Image to 3D Asset Pipeline \n
@@ -41,6 +43,7 @@ with gr.Blocks(
41
  image_mode="RGBA",
42
  type="pil",
43
  height=300,
 
44
  )
45
  gr.Markdown(
46
  """
 
15
  preprocess_sam_image_fn,
16
  select_point,
17
  start_session,
18
+ inject_image_css,
19
  )
20
  from gradio.themes import Default
21
  from gradio.themes.utils.colors import slate
 
23
  with gr.Blocks(
24
  delete_cache=(43200, 43200), theme=Default(primary_hue=slate)
25
  ) as demo:
26
+ inject_image_css()
27
  gr.Markdown(
28
  f"""
29
  ## Image to 3D Asset Pipeline \n
 
43
  image_mode="RGBA",
44
  type="pil",
45
  height=300,
46
+ elem_classes=["image-container"],
47
  )
48
  gr.Markdown(
49
  """
common.py CHANGED
@@ -127,6 +127,20 @@ elif os.getenv("GRADIO_APP") == "texture_edit":
127
  os.makedirs(TMP_DIR, exist_ok=True)
128
 
129
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
  def start_session(req: gr.Request) -> None:
131
  user_dir = os.path.join(TMP_DIR, str(req.session_hash))
132
  os.makedirs(user_dir, exist_ok=True)
 
127
  os.makedirs(TMP_DIR, exist_ok=True)
128
 
129
 
130
+ def inject_image_css():
131
+ return gr.HTML(
132
+ """
133
+ <style>
134
+ .image-container img {
135
+ object-fit: contain !important;
136
+ max-width: 100% !important;
137
+ max-height: 100% !important;
138
+ }
139
+ </style>
140
+ """
141
+ )
142
+
143
+
144
  def start_session(req: gr.Request) -> None:
145
  user_dir = os.path.join(TMP_DIR, str(req.session_hash))
146
  os.makedirs(user_dir, exist_ok=True)