File size: 1,538 Bytes
18b382b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env python3
# Copyright (c) Delanoe Pirard / Aedelon
# Licensed under the Apache License, Version 2.0
"""
Hugging Face Spaces entry point for awesome-depth-anything-3.

This file is the main entry point for the HF Spaces deployment.
It launches the Gradio web interface with optimized settings for cloud deployment.
"""

import os
import tempfile

# Disable analytics and configure for HF Spaces
os.environ["GRADIO_ANALYTICS_ENABLED"] = "False"
os.environ["DA3_LOG_LEVEL"] = "WARNING"

from depth_anything_3.app.gradio_app import DepthAnything3App


def main():
    """Launch the Gradio app for HF Spaces."""
    # Use DA3-LARGE for good balance of quality and speed
    workspace_dir = "/tmp/workspace"
    gallery_dir = "/tmp/gallery"

    # Create directories
    os.makedirs(workspace_dir, exist_ok=True)
    os.makedirs(gallery_dir, exist_ok=True)

    app = DepthAnything3App(
        model_dir="depth-anything/DA3-LARGE",
        workspace_dir=workspace_dir,
        gallery_dir=gallery_dir,
    )

    demo = app.create_app()

    # Build allowed paths for Gradio file access
    allowed_paths = [
        os.getcwd(),
        tempfile.gettempdir(),
        workspace_dir,
        gallery_dir,
        "/tmp",
    ]

    # Launch for HF Spaces (theme/css already set in create_app via gr.Blocks())
    demo.queue(max_size=10).launch(
        server_name="0.0.0.0",
        server_port=7860,
        share=True,
        show_error=True,
        allowed_paths=allowed_paths,
    )


if __name__ == "__main__":
    main()