Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -16,7 +16,6 @@ import pandas as pd
|
|
| 16 |
from PIL import Image
|
| 17 |
import torch
|
| 18 |
from torchvision.transforms import Compose, Resize, ToTensor, Normalize
|
| 19 |
-
from segment_anything import SamPredictor, sam_model_registry
|
| 20 |
|
| 21 |
# Set Streamlit configuration
|
| 22 |
st.set_page_config(page_title="Volume Estimator", layout="wide")
|
|
@@ -25,8 +24,8 @@ st.title("📦 Volume Estimation using SAM Segmentation + MiDaS Depth")
|
|
| 25 |
# Load SAM and MiDaS models
|
| 26 |
@st.cache_resource
|
| 27 |
def load_models():
|
| 28 |
-
sam_checkpoint = "sam_vit_b_01ec64.pth"
|
| 29 |
-
sam = sam_model_registry["
|
| 30 |
predictor = SamPredictor(sam)
|
| 31 |
|
| 32 |
midas = torch.hub.load("intel-isl/MiDaS", "DPT_Large")
|
|
|
|
| 16 |
from PIL import Image
|
| 17 |
import torch
|
| 18 |
from torchvision.transforms import Compose, Resize, ToTensor, Normalize
|
|
|
|
| 19 |
|
| 20 |
# Set Streamlit configuration
|
| 21 |
st.set_page_config(page_title="Volume Estimator", layout="wide")
|
|
|
|
| 24 |
# Load SAM and MiDaS models
|
| 25 |
@st.cache_resource
|
| 26 |
def load_models():
|
| 27 |
+
sam_checkpoint = "sam_vit_b_01ec64.pth" # Make sure this file is present in the same folder
|
| 28 |
+
sam = sam_model_registry["vit_b"](checkpoint=sam_checkpoint).to("cuda" if torch.cuda.is_available() else "cpu")
|
| 29 |
predictor = SamPredictor(sam)
|
| 30 |
|
| 31 |
midas = torch.hub.load("intel-isl/MiDaS", "DPT_Large")
|