Skip to content

Commit 22e4bf2

Browse files
authored
Merge pull request #1 from AdaptiveMotorControlLab/MMathisLab/fmpose3d
Update project name; fix env errors;
2 parents 0ede0cf + 8403bed commit 22e4bf2

81 files changed

Lines changed: 116 additions & 114 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 20 additions & 10 deletions

animals/README.md

Lines changed: 2 additions & 2 deletions

animals/demo/vis_animals.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
from PIL import Image
2323
import matplotlib.gridspec as gridspec
2424
import imageio
25-
from fmpose.animals.common.arguments import opts as parse_args
26-
from fmpose.common.camera import normalize_screen_coordinates, camera_to_world
25+
from fmpose3d.animals.common.arguments import opts as parse_args
26+
from fmpose3d.common.camera import normalize_screen_coordinates, camera_to_world
2727

2828
sys.path.append(os.getcwd())
2929

@@ -46,7 +46,7 @@
4646
CFM = getattr(module, "Model")
4747
else:
4848
# Load model from installed fmpose package
49-
from fmpose.models import Model as CFM
49+
from fmpose3d.models import Model as CFM
5050

5151
from deeplabcut.pose_estimation_pytorch.apis import superanimal_analyze_images
5252

animals/demo/vis_animals.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ sh_file='vis_animals.sh'
77
# n_joints=26
88
# out_joints=26
99

10-
model_path='../../fmpose/animals/models/model_animal3d.py'
10+
model_path='../pre_trained_models/animal3d_pretrained_weights/model_animal3d.py'
1111
saved_model_path='../pre_trained_models/animal3d_pretrained_weights/CFM_154_4403_best.pth'
1212

1313
# path='./images/image_00068.jpg' # single image

animals/models/model_animals.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from einops import rearrange
1616
from timm.models.layers import DropPath
1717

18-
from fmpose.animals.models.graph_frames import Graph
18+
from fmpose3d.animals.models.graph_frames import Graph
1919

2020

2121
class TimeEmbedding(nn.Module):
@@ -148,7 +148,7 @@ def forward(self, x):
148148
x = res2 + self.drop_path(x)
149149
return x
150150

151-
class FMPose(nn.Module):
151+
class FMPose3D(nn.Module):
152152
def __init__(self, depth, embed_dim, channels_dim, tokens_dim, adj, drop_rate=0.10, length=27):
153153
super().__init__()
154154
drop_path_rate = 0.2
@@ -220,7 +220,7 @@ def __init__(self, args):
220220
self.encoder_pose_2d = encoder(2, args.channel//2, args.channel//2-self.t_embed_dim//2)
221221
self.encoder_y_t = encoder(3, args.channel//2, args.channel//2-self.t_embed_dim//2)
222222

223-
self.FMPose = FMPose(args.layers, args.channel, args.d_hid, args.token_dim, self.A, length=args.n_joints) # 256
223+
self.FMPose3D = FMPose3D(args.layers, args.channel, args.d_hid, args.token_dim, self.A, length=args.n_joints) # 256
224224
self.pred_mu = decoder(args.channel, args.channel//2, 3)
225225

226226
def forward(self, pose_2d, y_t, t):
@@ -239,7 +239,7 @@ def forward(self, pose_2d, y_t, t):
239239
in_emb = rearrange(in_emb, 'b f j c -> (b f) j c').contiguous() # (B*F,J,in)
240240

241241
# encoder -> model -> regression head
242-
h = self.FMPose(in_emb)
242+
h = self.FMPose3D(in_emb)
243243
v = self.pred_mu(h) # (B*F,J,3)
244244

245245
v = rearrange(v, '(b f) j c -> b f j c', b=b, f=f).contiguous() # (B,F,J,3)

animals/scripts/main_animal3d.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
import numpy as np
1616
from tqdm import tqdm
1717
import torch.optim as optim
18-
from fmpose.animals.common.arguments import opts as parse_args
19-
from fmpose.animals.common.utils import *
20-
from fmpose.animals.common.animal3d_dataset import TrainDataset
18+
from fmpose3d.animals.common.arguments import opts as parse_args
19+
from fmpose3d.animals.common.utils import *
20+
from fmpose3d.animals.common.animal3d_dataset import TrainDataset
2121
import time
2222

2323
args = parse_args().parse()
@@ -39,7 +39,7 @@
3939
CFM = getattr(module, "Model")
4040
else:
4141
# Load model from installed fmpose package
42-
from fmpose.animals.models import Model as CFM
42+
from fmpose3d.animals.models import Model as CFM
4343

4444
def train(opt, actions, train_loader, model, optimizer, epoch):
4545
return step('train', opt, actions, train_loader, model, optimizer, epoch)

animals/scripts/test_animal3d.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ n_joints=26
1111
out_joints=26
1212
epochs=300
1313
# model_path='models/model_animals.py'
14-
model_path="" # when the path is empty, the model will be loaded from the installed fmpose package
14+
model_path='./pre_trained_models/animal3d_pretrained_weights/model_animal3d.py' # when the path is empty, the model will be loaded from the installed fmpose package
1515
saved_model_path='./pre_trained_models/animal3d_pretrained_weights/CFM_154_4403_best.pth'
1616
# root path denotes the path to the original dataset
1717
root_path="./dataset/"

dataset/readme.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Download the preprocessed datasets from [here](https://drive.google.com/drive/folders/112GPdRC9IEcwcJRyrLJeYw9_YV4wLdKC?usp=sharing) and place them in this folder.

demo/vis_in_the_wild.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
sys.path.append(os.getcwd())
2020

2121
# Auto-download checkpoint files if missing
22-
from fmpose.lib.checkpoint.download_checkpoints import ensure_checkpoints
22+
from fmpose3d.lib.checkpoint.download_checkpoints import ensure_checkpoints
2323
ensure_checkpoints()
2424

25-
from fmpose.lib.preprocess import h36m_coco_format, revise_kpts
26-
from fmpose.lib.hrnet.gen_kpts import gen_video_kpts as hrnet_pose
27-
from fmpose.common.arguments import opts as parse_args
25+
from fmpose3d.lib.preprocess import h36m_coco_format, revise_kpts
26+
from fmpose3d.lib.hrnet.gen_kpts import gen_video_kpts as hrnet_pose
27+
from fmpose3d.common.arguments import opts as parse_args
2828

2929
args = parse_args().parse()
3030
os.environ["CUDA_VISIBLE_DEVICES"] = args.gpu
@@ -39,7 +39,7 @@
3939
spec.loader.exec_module(module)
4040
CFM = getattr(module, 'Model')
4141

42-
from fmpose.common.camera import *
42+
from fmpose3d.common.camera import *
4343

4444
import matplotlib
4545
import matplotlib.pyplot as plt

fmpose/animals/__init__.py

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)