Spaces:
Running
on
Zero
Running
on
Zero
sync with source
Browse files- app.py +25 -31
- demo/render_hints.py +1 -1
app.py
CHANGED
@@ -68,19 +68,18 @@ with gr.Blocks(title="DiLightNet Demo") as demo:
|
|
68 |
outputs=[mesh, fov],
|
69 |
)
|
70 |
|
71 |
-
gr.Markdown("## Step 4. Render Hints")
|
72 |
with gr.Row():
|
73 |
-
with gr.Column():
|
|
|
74 |
hint_image = gr.Image(label="Hint Image", height=512, width=512)
|
75 |
-
with gr.Column():
|
76 |
res_folder_path = gr.Textbox("", visible=False)
|
77 |
is_env_lighting = gr.Checkbox(label="Use Environmental Lighting", value=True, interactive=False, visible=False)
|
78 |
with gr.Tab("Environmental Lighting"):
|
79 |
env_map_preview = gr.Image(label="Environment Map Preview", height=256, width=512, interactive=False, show_download_button=False)
|
80 |
-
env_map_path = gr.Text(interactive=False, visible=
|
81 |
env_rotation = gr.Slider(value=0., label="Environment Rotation", minimum=0., maximum=360., step=0.5)
|
82 |
env_examples = gr.Examples(
|
83 |
-
examples=[[os.path.join("examples/env_map_preview", i), os.path.join("examples/
|
84 |
inputs=[env_map_preview, env_map_path],
|
85 |
examples_per_page = 20,
|
86 |
)
|
@@ -126,39 +125,35 @@ with gr.Blocks(title="DiLightNet Demo") as demo:
|
|
126 |
outputs=[hint_image, res_folder_path, is_env_lighting]
|
127 |
)
|
128 |
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
with gr.Column():
|
133 |
with gr.Group():
|
134 |
-
|
135 |
-
relighting_prompt = gr.Textbox(value="", label="Appearance Text Prompt", lines=3,
|
136 |
placeholder="Input prompt here",
|
137 |
interactive=True)
|
|
|
138 |
with gr.Row():
|
139 |
-
# several example prompts
|
140 |
metallic_prompt_btn = gr.Button(value="Metallic", size="sm")
|
141 |
specular_prompt_btn = gr.Button(value="Specular", size="sm")
|
142 |
very_specular_prompt_btn = gr.Button(value="Very Specular", size="sm")
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
very_specular_prompt_btn.click(fn=lambda x: x + " very specular", inputs=[relighting_prompt], outputs=[relighting_prompt])
|
147 |
-
clear_prompt_btn.click(fn=lambda x: "", inputs=[relighting_prompt], outputs=[relighting_prompt])
|
148 |
with gr.Row():
|
|
|
149 |
reuse_btn = gr.Button(value="Reuse Provisional Image Generation Prompt")
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
relighting_generate_btn = gr.Button(value="Generate")
|
158 |
|
159 |
def gen_relighting_image(masked_image, mask, res_folder_path, relighting_prompt, relighting_seed,
|
160 |
-
|
161 |
-
|
162 |
relighting_gen(
|
163 |
masked_ref_img=masked_image,
|
164 |
mask=mask,
|
@@ -178,11 +173,10 @@ with gr.Blocks(title="DiLightNet Demo") as demo:
|
|
178 |
relit_img = (relit_img * 255).clip(0, 255).astype(np.uint8)
|
179 |
return relit_img
|
180 |
|
181 |
-
|
182 |
relighting_generate_btn.click(fn=gen_relighting_image,
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
|
187 |
|
188 |
if __name__ == '__main__':
|
|
|
68 |
outputs=[mesh, fov],
|
69 |
)
|
70 |
|
|
|
71 |
with gr.Row():
|
72 |
+
with gr.Column(variant="panel"):
|
73 |
+
gr.Markdown("## Step 4. Render Hints")
|
74 |
hint_image = gr.Image(label="Hint Image", height=512, width=512)
|
|
|
75 |
res_folder_path = gr.Textbox("", visible=False)
|
76 |
is_env_lighting = gr.Checkbox(label="Use Environmental Lighting", value=True, interactive=False, visible=False)
|
77 |
with gr.Tab("Environmental Lighting"):
|
78 |
env_map_preview = gr.Image(label="Environment Map Preview", height=256, width=512, interactive=False, show_download_button=False)
|
79 |
+
env_map_path = gr.Text(interactive=False, visible=True, value="examples/env_map/grace.exr")
|
80 |
env_rotation = gr.Slider(value=0., label="Environment Rotation", minimum=0., maximum=360., step=0.5)
|
81 |
env_examples = gr.Examples(
|
82 |
+
examples=[[os.path.join("examples/env_map_preview", i), os.path.join("examples/env_map_preview", i).replace("png", "exr")] for i in os.listdir("examples/env_map_preview")],
|
83 |
inputs=[env_map_preview, env_map_path],
|
84 |
examples_per_page = 20,
|
85 |
)
|
|
|
125 |
outputs=[hint_image, res_folder_path, is_env_lighting]
|
126 |
)
|
127 |
|
128 |
+
with gr.Column(variant="panel"):
|
129 |
+
gr.Markdown("## Step 5. Control Lighting!")
|
130 |
+
res_image = gr.Image(label="Result Image", height=512, width=512)
|
|
|
131 |
with gr.Group():
|
132 |
+
relighting_prompt = gr.Textbox(value="", label="Appearance Text Prompt", lines=3,
|
|
|
133 |
placeholder="Input prompt here",
|
134 |
interactive=True)
|
135 |
+
# several example prompts
|
136 |
with gr.Row():
|
|
|
137 |
metallic_prompt_btn = gr.Button(value="Metallic", size="sm")
|
138 |
specular_prompt_btn = gr.Button(value="Specular", size="sm")
|
139 |
very_specular_prompt_btn = gr.Button(value="Very Specular", size="sm")
|
140 |
+
metallic_prompt_btn.click(fn=lambda x: x + " metallic", inputs=[relighting_prompt], outputs=[relighting_prompt])
|
141 |
+
specular_prompt_btn.click(fn=lambda x: x + " specular", inputs=[relighting_prompt], outputs=[relighting_prompt])
|
142 |
+
very_specular_prompt_btn.click(fn=lambda x: x + " very specular", inputs=[relighting_prompt], outputs=[relighting_prompt])
|
|
|
|
|
143 |
with gr.Row():
|
144 |
+
clear_prompt_btn = gr.Button(value="Clear")
|
145 |
reuse_btn = gr.Button(value="Reuse Provisional Image Generation Prompt")
|
146 |
+
clear_prompt_btn.click(fn=lambda x: "", inputs=[relighting_prompt], outputs=[relighting_prompt])
|
147 |
+
reuse_btn.click(fn=lambda x: x, inputs=[prompt], outputs=[relighting_prompt])
|
148 |
+
with gr.Accordion("Options", open=False):
|
149 |
+
relighting_seed = gr.Number(value=3407, label="Seed", interactive=True)
|
150 |
+
relighting_steps = gr.Number(value=20, label="Steps", interactive=True)
|
151 |
+
relighting_cfg = gr.Number(value=3.0, label="CFG", interactive=True)
|
152 |
+
relighting_generate_btn = gr.Button(value="Generate")
|
|
|
153 |
|
154 |
def gen_relighting_image(masked_image, mask, res_folder_path, relighting_prompt, relighting_seed,
|
155 |
+
relighting_steps, relighting_cfg, do_env_inpainting,
|
156 |
+
progress=gr.Progress(track_tqdm=True)):
|
157 |
relighting_gen(
|
158 |
masked_ref_img=masked_image,
|
159 |
mask=mask,
|
|
|
173 |
relit_img = (relit_img * 255).clip(0, 255).astype(np.uint8)
|
174 |
return relit_img
|
175 |
|
|
|
176 |
relighting_generate_btn.click(fn=gen_relighting_image,
|
177 |
+
inputs=[masked_image, mask, res_folder_path, relighting_prompt, relighting_seed,
|
178 |
+
relighting_steps, relighting_cfg, is_env_lighting],
|
179 |
+
outputs=[res_image])
|
180 |
|
181 |
|
182 |
if __name__ == '__main__':
|
demo/render_hints.py
CHANGED
@@ -58,7 +58,7 @@ def render_hint_images(model_path, fov, pls, power=500., geo_smooth=True, output
|
|
58 |
obj.modifiers.new("Smooth", type="SMOOTH")
|
59 |
smooth_modifier = obj.modifiers["Smooth"]
|
60 |
smooth_modifier.factor = 0.5
|
61 |
-
smooth_modifier.iterations =
|
62 |
configure_blender()
|
63 |
|
64 |
c2w = np.array([
|
|
|
58 |
obj.modifiers.new("Smooth", type="SMOOTH")
|
59 |
smooth_modifier = obj.modifiers["Smooth"]
|
60 |
smooth_modifier.factor = 0.5
|
61 |
+
smooth_modifier.iterations = 25
|
62 |
configure_blender()
|
63 |
|
64 |
c2w = np.array([
|