Spaces:
Paused
Paused
fix: move demo to module level (Gradio SDK needs it, not inside main())
Browse files
app.py
CHANGED
|
@@ -141,52 +141,32 @@ def generate(image):
|
|
| 141 |
return depth_map, normal_map, status
|
| 142 |
|
| 143 |
|
| 144 |
-
|
| 145 |
-
import argparse
|
| 146 |
-
parser = argparse.ArgumentParser()
|
| 147 |
-
sub = parser.add_subparsers(dest="command")
|
| 148 |
-
infer = sub.add_parser("infer")
|
| 149 |
-
infer.add_argument("-i", "--input", required=True)
|
| 150 |
-
infer.add_argument("-o", "--output-dir", default=".")
|
| 151 |
-
args = parser.parse_args()
|
| 152 |
-
|
| 153 |
-
if args.command == "infer":
|
| 154 |
-
from PIL import Image
|
| 155 |
-
depth, normal, status = generate(args.input)
|
| 156 |
-
depth.save(os.path.join(args.output_dir, "depth.png"))
|
| 157 |
-
if normal:
|
| 158 |
-
normal.save(os.path.join(args.output_dir, "normal.png"))
|
| 159 |
-
print(status)
|
| 160 |
-
return
|
| 161 |
|
| 162 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 163 |
|
| 164 |
-
|
| 165 |
-
gr.Markdown(
|
| 166 |
-
"**[FE2E](https://github.com/AMAP-ML/FE2E)** Depth + Normal from a single image (CVPR 2026). "
|
| 167 |
-
"Single denoise step, Step1X-Edit DiT + LDRN LoRA (pre-merged), INT8 quantized on CPU."
|
| 168 |
-
)
|
| 169 |
-
with gr.Row():
|
| 170 |
-
with gr.Column():
|
| 171 |
-
input_img = gr.Image(label="Input Image", type="pil")
|
| 172 |
-
run_btn = gr.Button("Estimate Depth + Normal", variant="primary")
|
| 173 |
-
with gr.Column():
|
| 174 |
-
depth_out = gr.Image(label="Depth Map", type="pil")
|
| 175 |
-
normal_out = gr.Image(label="Normal Map", type="pil")
|
| 176 |
-
status_out = gr.Textbox(label="Status", interactive=False)
|
| 177 |
-
|
| 178 |
-
run_btn.click(
|
| 179 |
-
fn=generate,
|
| 180 |
-
inputs=[input_img],
|
| 181 |
-
outputs=[depth_out, normal_out, status_out],
|
| 182 |
-
concurrency_limit=1,
|
| 183 |
-
api_name="generate",
|
| 184 |
-
)
|
| 185 |
|
| 186 |
-
|
| 187 |
demo.launch(server_name="0.0.0.0", server_port=7860, show_error=True,
|
| 188 |
mcp_server=True, ssr_mode=False)
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
if __name__ == "__main__":
|
| 192 |
-
main()
|
|
|
|
| 141 |
return depth_map, normal_map, status
|
| 142 |
|
| 143 |
|
| 144 |
+
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 145 |
|
| 146 |
+
with gr.Blocks(title="FE2E: Depth + Normal (CPU)") as demo:
|
| 147 |
+
gr.Markdown(
|
| 148 |
+
"**[FE2E](https://github.com/AMAP-ML/FE2E)** Depth + Normal from a single image (CVPR 2026). "
|
| 149 |
+
"Single denoise step, Step1X-Edit DiT + LDRN LoRA (pre-merged), INT8 quantized on CPU."
|
| 150 |
+
)
|
| 151 |
+
with gr.Row():
|
| 152 |
+
with gr.Column():
|
| 153 |
+
input_img = gr.Image(label="Input Image", type="pil")
|
| 154 |
+
run_btn = gr.Button("Estimate Depth + Normal", variant="primary")
|
| 155 |
+
with gr.Column():
|
| 156 |
+
depth_out = gr.Image(label="Depth Map", type="pil")
|
| 157 |
+
normal_out = gr.Image(label="Normal Map", type="pil")
|
| 158 |
+
status_out = gr.Textbox(label="Status", interactive=False)
|
| 159 |
+
|
| 160 |
+
run_btn.click(
|
| 161 |
+
fn=generate,
|
| 162 |
+
inputs=[input_img],
|
| 163 |
+
outputs=[depth_out, normal_out, status_out],
|
| 164 |
+
concurrency_limit=1,
|
| 165 |
+
api_name="generate",
|
| 166 |
+
)
|
| 167 |
|
| 168 |
+
demo.queue(default_concurrency_limit=1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 169 |
|
| 170 |
+
if __name__ == "__main__":
|
| 171 |
demo.launch(server_name="0.0.0.0", server_port=7860, show_error=True,
|
| 172 |
mcp_server=True, ssr_mode=False)
|
|
|
|
|
|
|
|
|
|
|
|