Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import torch
|
2 |
+
from huggingface_hub import hf_hub_download
|
3 |
+
|
4 |
+
# Download the model file from Hugging Face Hub
|
5 |
+
repo_name = "roughness_model"
|
6 |
+
downloaded_file = hf_hub_download(
|
7 |
+
repo_id=f"Pra-tham/{repo_name}", # Replace with your Hugging Face username
|
8 |
+
filename="roughness_model.pth"
|
9 |
+
)
|
10 |
+
print(f"Model downloaded from Hugging Face Hub: {downloaded_file}")
|
11 |
+
|
12 |
+
|
13 |
+
|
14 |
+
# Initialize the model and load the state_dict
|
15 |
+
|
16 |
+
model.load_state_dict(torch.load(downloaded_file))
|
17 |
+
model.eval() # Set to evaluation mode
|
18 |
+
print("Model loaded successfully from Hugging Face Hub!")
|
19 |
+
|
20 |
+
|
21 |
+
# Set the computation device
|
22 |
+
device0 = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
23 |
+
|
24 |
+
# Load the pretrained model checkpoint
|
25 |
+
load_path = "/kaggle/working/metric_depth_vit_large_800k.pth"
|
26 |
+
checkpoint = torch.load(load_path, map_location="cpu")
|
27 |
+
|
28 |
+
# Load the model configuration
|
29 |
+
cfg_large = Config.fromfile('/kaggle/working/Texture_training/training/mono/configs/RAFTDecoder/vit.raft5.large.py')
|
30 |
+
|
31 |
+
# Initialize the DepthModel
|
32 |
+
model = DepthModel(cfg_large, None)
|
33 |
+
|
34 |
+
# Load the model's state dictionary
|
35 |
+
ckpt_state_dict = checkpoint['model_state_dict']
|
36 |
+
model.load_state_dict(ckpt_state_dict, strict=False)
|
37 |
+
|
38 |
+
# Print the model architecture
|
39 |
+
#print(model)
|