sharifIslam commited on
Commit
5409d91
·
1 Parent(s): 5dd0b96

Restore full MV3DR app with model loading and custom UI

Browse files
Files changed (2) hide show
  1. app.py +49 -5
  2. requirements.txt +1 -1
app.py CHANGED
@@ -1,9 +1,53 @@
1
- import gradio as gr
 
 
 
 
2
 
3
- def greet(name):
4
- return f"Hello, {name}!"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
- interface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
 
8
  if __name__ == "__main__":
9
- interface.launch(server_name="0.0.0.0", server_port=7860)
 
1
+ import os
2
+ import sys
3
+ import torch
4
+ import subprocess
5
+ import logging
6
 
7
+ logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
8
+ logger = logging.getLogger(__name__)
9
+
10
+ logger.info("="*50)
11
+ logger.info("Starting MV3DR Application")
12
+ logger.info("="*50)
13
+
14
+ if not os.path.exists('dust3r/.git'):
15
+ logger.info("Initializing dust3r submodule...")
16
+ subprocess.run(['git', 'submodule', 'update', '--init', '--recursive'], check=False)
17
+
18
+ logger.info("Adding dust3r to Python path...")
19
+ sys.path.append(os.path.join(os.path.dirname(__file__), 'dust3r'))
20
+
21
+ logger.info("Importing model initialization module...")
22
+ from model import initialize
23
+
24
+ logger.info("Importing UI builder...")
25
+ from gradio_ui import build_ui
26
+
27
+ logger.info("Importing configuration...")
28
+ from config import WEIGHTS_PATH, OUTPUT_DIR
29
+
30
+
31
+ def main():
32
+ logger.info("Creating output directory...")
33
+ os.makedirs(OUTPUT_DIR, exist_ok=True)
34
+
35
+ device = "cuda" if torch.cuda.is_available() else "cpu"
36
+ logger.info(f"Using device: {device}")
37
+
38
+ logger.info("Loading DUSt3R model...")
39
+ logger.info(f"Model weights path: {WEIGHTS_PATH}")
40
+ model = initialize(WEIGHTS_PATH, device)
41
+ logger.info("Model loaded successfully!")
42
+
43
+ logger.info("Building Gradio UI...")
44
+ app = build_ui(OUTPUT_DIR, model, device)
45
+ logger.info("UI built successfully!")
46
+
47
+ logger.info("Launching application...")
48
+ app.queue().launch(show_api=False)
49
+ logger.info("Application started!")
50
 
 
51
 
52
  if __name__ == "__main__":
53
+ main()
requirements.txt CHANGED
@@ -1,7 +1,7 @@
1
  torch
2
  torchvision
3
  roma
4
- gradio==4.44.0
5
  huggingface_hub==0.26.2
6
  einops
7
  trimesh
 
1
  torch
2
  torchvision
3
  roma
4
+ gradio==5.0.1
5
  huggingface_hub==0.26.2
6
  einops
7
  trimesh