mkalia commited on
Commit
33485a1
1 Parent(s): 22f2ad4

Update depth_app.py

Browse files
Files changed (1) hide show
  1. depth_app.py +22 -7
depth_app.py CHANGED
@@ -1,5 +1,4 @@
1
  import streamlit as st
2
- import subprocess
3
  import numpy as np
4
  import PIL.Image as pil
5
  import torch
@@ -11,6 +10,26 @@ import matplotlib.cm as cm
11
 
12
  from resnet_encoder import ResnetEncoder
13
  from depth_decoder import DepthDecoder
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  # from pose_decoder import PoseDecoder
15
  # from pose_cnn import PoseCNN
16
 
@@ -66,12 +85,8 @@ def main():
66
  st.title("Monodepth2 Depth Estimation")
67
  st.write("Upload a PNG image to get depth estimation")
68
 
69
- if not os.path.exists("depth.pth"):
70
- subprocess.run(["wget", "https://github.com/meghakalia/depthEstimationColonoscopy/releases/download/0.0.1/depth.pth"])
71
-
72
- if not os.path.exists("encoder.pth"):
73
- subprocess.run(["wget", "https://github.com/meghakalia/depthEstimationColonoscopy/releases/download/0.0.1/encoder.pth"])
74
-
75
  uploaded_file = st.file_uploader("Choose a PNG file", type="png")
76
  if uploaded_file is not None:
77
  image = pil.open(uploaded_file).convert('RGB')
 
1
  import streamlit as st
 
2
  import numpy as np
3
  import PIL.Image as pil
4
  import torch
 
10
 
11
  from resnet_encoder import ResnetEncoder
12
  from depth_decoder import DepthDecoder
13
+
14
+ import os
15
+ import subprocess
16
+ import requests
17
+
18
+ def download_model_files():
19
+ depth_url = "https://github.com/meghakalia/depthEstimationColonoscopy/releases/download/0.0.1/depth.pth"
20
+ encoder_url = "https://github.com/meghakalia/depthEstimationColonoscopy/releases/download/0.0.1/encoder.pth"
21
+
22
+ if not os.path.exists("depth.pth"):
23
+ response = requests.get(depth_url)
24
+ with open("depth.pth", "wb") as f:
25
+ f.write(response.content)
26
+
27
+ if not os.path.exists("encoder.pth"):
28
+ response = requests.get(encoder_url)
29
+ with open("encoder.pth", "wb") as f:
30
+ f.write(response.content)
31
+
32
+
33
  # from pose_decoder import PoseDecoder
34
  # from pose_cnn import PoseCNN
35
 
 
85
  st.title("Monodepth2 Depth Estimation")
86
  st.write("Upload a PNG image to get depth estimation")
87
 
88
+ download_model_files()
89
+
 
 
 
 
90
  uploaded_file = st.file_uploader("Choose a PNG file", type="png")
91
  if uploaded_file is not None:
92
  image = pil.open(uploaded_file).convert('RGB')