Spaces:
Running
on
Zero
Running
on
Zero
xinjie.wang
commited on
Commit
·
0fd2448
1
Parent(s):
3be48e2
update
Browse files
app.py
CHANGED
@@ -245,7 +245,7 @@ with gr.Blocks(
|
|
245 |
label="Mesh Representation",
|
246 |
height=300,
|
247 |
interactive=False,
|
248 |
-
clear_color=[0.
|
249 |
elem_id="lighter_mesh",
|
250 |
)
|
251 |
|
|
|
245 |
label="Mesh Representation",
|
246 |
height=300,
|
247 |
interactive=False,
|
248 |
+
clear_color=[0.8, 0.8, 0.8, 1],
|
249 |
elem_id="lighter_mesh",
|
250 |
)
|
251 |
|
common.py
CHANGED
@@ -78,6 +78,25 @@ DELIGHT = DelightingModel()
|
|
78 |
IMAGESR_MODEL = ImageRealESRGAN(outscale=4)
|
79 |
|
80 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
if os.getenv("GRADIO_APP") == "imageto3d":
|
82 |
RBG_REMOVER = RembgRemover()
|
83 |
SAM_PREDICTOR = SAMPredictor(model_type="vit_h", device="cpu")
|
@@ -98,10 +117,14 @@ elif os.getenv("GRADIO_APP") == "textto3d":
|
|
98 |
"JeffreyXiang/TRELLIS-image-large"
|
99 |
)
|
100 |
# PIPELINE.cuda()
|
|
|
|
|
|
|
|
|
101 |
PIPELINE_IMG_IP = build_text2img_ip_pipeline(
|
102 |
-
|
103 |
)
|
104 |
-
PIPELINE_IMG = build_text2img_pipeline(
|
105 |
SEG_CHECKER = ImageSegChecker(GPT_CLIENT)
|
106 |
GEO_CHECKER = MeshGeoChecker(GPT_CLIENT)
|
107 |
AESTHETIC_CHECKER = ImageAestheticChecker()
|
@@ -110,6 +133,9 @@ elif os.getenv("GRADIO_APP") == "textto3d":
|
|
110 |
os.path.dirname(os.path.abspath(__file__)), "sessions/textto3d"
|
111 |
)
|
112 |
elif os.getenv("GRADIO_APP") == "texture_edit":
|
|
|
|
|
|
|
113 |
PIPELINE_IP = build_texture_gen_pipe(
|
114 |
base_ckpt_dir="./weights",
|
115 |
ip_adapt_scale=0.7,
|
@@ -130,7 +156,7 @@ os.makedirs(TMP_DIR, exist_ok=True)
|
|
130 |
lighting_css = """
|
131 |
<style>
|
132 |
#lighter_mesh canvas {
|
133 |
-
filter: brightness(2
|
134 |
}
|
135 |
</style>
|
136 |
"""
|
|
|
78 |
IMAGESR_MODEL = ImageRealESRGAN(outscale=4)
|
79 |
|
80 |
|
81 |
+
def download_kolors_weights() -> None:
|
82 |
+
logger.info(f"Download kolors weights from huggingface...")
|
83 |
+
subprocess.run(
|
84 |
+
[
|
85 |
+
"huggingface-cli", "download", "--resume-download",
|
86 |
+
"Kwai-Kolors/Kolors", "--local-dir", "weights/Kolors"
|
87 |
+
],
|
88 |
+
check=True
|
89 |
+
)
|
90 |
+
subprocess.run(
|
91 |
+
[
|
92 |
+
"huggingface-cli", "download", "--resume-download",
|
93 |
+
"Kwai-Kolors/Kolors-IP-Adapter-Plus", "--local-dir",
|
94 |
+
"weights/Kolors-IP-Adapter-Plus"
|
95 |
+
],
|
96 |
+
check=True
|
97 |
+
)
|
98 |
+
|
99 |
+
|
100 |
if os.getenv("GRADIO_APP") == "imageto3d":
|
101 |
RBG_REMOVER = RembgRemover()
|
102 |
SAM_PREDICTOR = SAMPredictor(model_type="vit_h", device="cpu")
|
|
|
117 |
"JeffreyXiang/TRELLIS-image-large"
|
118 |
)
|
119 |
# PIPELINE.cuda()
|
120 |
+
text_model_dir = "weights/Kolors"
|
121 |
+
if not os.path.exists(text_model_dir):
|
122 |
+
download_kolors_weights()
|
123 |
+
|
124 |
PIPELINE_IMG_IP = build_text2img_ip_pipeline(
|
125 |
+
text_model_dir, ref_scale=0.3
|
126 |
)
|
127 |
+
PIPELINE_IMG = build_text2img_pipeline(text_model_dir)
|
128 |
SEG_CHECKER = ImageSegChecker(GPT_CLIENT)
|
129 |
GEO_CHECKER = MeshGeoChecker(GPT_CLIENT)
|
130 |
AESTHETIC_CHECKER = ImageAestheticChecker()
|
|
|
133 |
os.path.dirname(os.path.abspath(__file__)), "sessions/textto3d"
|
134 |
)
|
135 |
elif os.getenv("GRADIO_APP") == "texture_edit":
|
136 |
+
if not os.path.exists("weights/Kolors"):
|
137 |
+
download_kolors_weights()
|
138 |
+
|
139 |
PIPELINE_IP = build_texture_gen_pipe(
|
140 |
base_ckpt_dir="./weights",
|
141 |
ip_adapt_scale=0.7,
|
|
|
156 |
lighting_css = """
|
157 |
<style>
|
158 |
#lighter_mesh canvas {
|
159 |
+
filter: brightness(2) !important;
|
160 |
}
|
161 |
</style>
|
162 |
"""
|