Open buckeye17 opened 1 year ago
I eventually figured out my issues. Here's my final script to flush a dummy tensor through GaitGraph for inference:
import numpy as np
import torch
from common import get_model_resgcn
from datasets.graph import Graph
# define configuration options with custom class instead of using CLI & argument parser
class opt():
weights_path = "/app/Gait/GaitGraph/models/gaitgraph_resgcn-n39-r8_coco_seq_60.pth"
network_name = "resgcn-n39-r8"
embedding_layer_size = 128
temporal_kernel_size = 9
dropout = 0.4
use_multi_branch = False
# Config for dataset
graph = Graph("coco")
# Init model
model, model_args = get_model_resgcn(graph, opt)
if torch.cuda.is_available():
model.cuda()
# Load weights
checkpoint = torch.load(opt.weights_path)
model.load_state_dict(checkpoint["model"], strict=False)
model.eval()
# Load data
# Dim 1: batch components
# Dim 2: unknown
# Dim 3: coordinates (x, y, conf)
# Dim 4: sequence of 60 frames
# Dim 5: coordinate list (nose, left_eye, right_eye, etc)
data_arr = np.ones((1,1,3,60,17)).astype(float)
data_ten = torch.from_numpy(data_arr)
data_ten = data_ten.type(torch.cuda.FloatTensor)
# Calculate embeddings
with torch.no_grad():
bsz = data_ten.shape[0]
data_ten_flipped = torch.flip(data_ten, dims=[1])
data_ten = torch.cat([data_ten, data_ten_flipped], dim=0)
if torch.cuda.is_available():
data_ten = data_ten.cuda(non_blocking=True)
output = model(data_ten)
f1, f2 = torch.split(output, [bsz, bsz], dim=0)
output = torch.mean(torch.stack([f1, f2]), dim=0)
请问一下,你最终是否顺利运行出了代码。我目前也遇到了一些问题,想知道代码是否可行。希望能得到回答,不甚感激
I'm attempting to adapt
evaluate.py
into my owninfer.py
. Currently I'm just trying to flush a dummy tensor through but I'm getting an error. Any help would be appreciated!!!Here's my
infer.py
:Here's the error message I get: