pablovela5620 commited on
Commit
20fff88
β€’
1 Parent(s): 14788de

add rerun viewer

Browse files
Files changed (1) hide show
  1. app.py +34 -6
app.py CHANGED
@@ -1,14 +1,42 @@
1
  import gradio as gr
2
  import spaces
3
  import torch
 
 
 
4
 
5
- zero = torch.Tensor([0]).cuda()
6
- print(zero.device) # <-- 'cpu' πŸ€”
 
 
 
 
 
 
7
 
8
  @spaces.GPU
9
- def greet(n):
10
- print(zero.device) # <-- 'cuda:0' πŸ€—
11
- return f"Hello {zero + n} Tensor"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
- demo = gr.Interface(fn=greet, inputs=gr.Number(), outputs=gr.Text())
 
 
 
 
14
  demo.launch()
 
1
  import gradio as gr
2
  import spaces
3
  import torch
4
+ from gradio_rerun import Rerun
5
+ import rerun as rr
6
+ from pathlib import Path
7
 
8
+
9
+ from mini_dust3r.api import OptimizedResult, inferece_dust3r, log_optimized_result
10
+ from mini_dust3r.model import AsymmetricCroCo3DStereo
11
+
12
+ DEVICE = 'cuda' if torch.cuda.is_available() else 'cpu'
13
+ model = AsymmetricCroCo3DStereo.from_pretrained(
14
+ "naver/DUSt3R_ViTLarge_BaseDecoder_512_dpt"
15
+ ).to(DEVICE)
16
 
17
  @spaces.GPU
18
+ def predict(image_dir: str):
19
+ rr.init("my data")
20
+ optimized_results: OptimizedResult = inferece_dust3r(
21
+ image_dir=image_dir,
22
+ model=model,
23
+ device=DEVICE,
24
+ batch_size=1,
25
+ )
26
+ log_optimized_result(optimized_results, Path("world"))
27
+ rr.save("dust3r.rrd")
28
+ return "dust3r.rrd"
29
+
30
+ with gr.Blocks(css=""".gradio-container {margin: 0 !important; min-width: 100%};""", title="DUSt3R Demo") as demo:
31
+ # scene state is save so that you can change conf_thr, cam_size... without rerunning the inference
32
+ gr.HTML('<h2 style="text-align: center;">DUSt3R Demo</h2>')
33
+ with gr.Column():
34
+ inputfiles = gr.File(file_count="multiple")
35
+ rerun_viewer = Rerun(height=900)
36
 
37
+ run_btn = gr.Button("Run")
38
+ run_btn.click(fn=predict,
39
+ inputs=[inputfiles],
40
+ outputs=[rerun_viewer])
41
+
42
  demo.launch()