Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

about fps #437

Open
1999zsh opened this issue Aug 27, 2024 · 1 comment
Open

about fps #437

1999zsh opened this issue Aug 27, 2024 · 1 comment
Assignees

Comments

@1999zsh
Copy link

1999zsh commented Aug 27, 2024

Star RTDETR
请先在RTDETR主页点击star以支持本项目
Star RTDETR to help more people discover this project.


Describe the bug
A clear and concise description of what the bug is.
If applicable, add screenshots to help explain your problem.

To Reproduce
Steps to reproduce the behavior.

Dear author.
here is my method of computing fps:

from src.nn.backbone import PResNet
from src.zoo.rtdetr import HybridEncoder, RTDETRTransformer, RTDETR, RTDETRPostProcessor
from PIL import Image
from torchvision import transforms
import cv2
import os
import time

device = "cuda"
backbone = PResNet(depth=18, freeze_norm=False, pretrained=False, return_idx=[1, 2, 3])
encoder = HybridEncoder(in_channels=[128, 256, 512], enc_act='gelu', expansion=0.5, eval_spatial_size=[640, 640])
decoder = RTDETRTransformer(num_classes=10, eval_idx=-1, num_decoder_layers=3, num_denoising=100, 
                            feat_channels=[256, 256, 256], feat_strides=[8, 16, 32],
                            hidden_dim=256, num_levels=3, num_queries=300, eval_spatial_size=[640, 640])
model = RTDETR(backbone=backbone, encoder=encoder, decoder=decoder, 
               multi_scale=[480, 512, 544, 576, 608, 640, 640, 640, 672, 704, 736, 768, 800]).to(device)

postprocessor = RTDETRPostProcessor(num_classes=10, remap_mscoco_category=True)

weights = torch.load("/home/zsh/rtdetr/checkpoint0071.pth")
model.load_state_dict(weights['model'])
model.eval()

font = cv2.FONT_HERSHEY_SIMPLEX

transform = transforms.Compose([
    transforms.ToTensor(),
    transforms.Resize(size=(640, 640), antialias=True)
])

xs = []
oris = []
for file in os.listdir("/home/zsh/datasets/rtdetr_visdrone/VisDrone2019-DET-val/images/"):
    x = Image.open(f"/home/zsh/datasets/rtdetr_visdrone/VisDrone2019-DET-val/images/{file}").convert("RGB")
    ori_size = torch.tensor(x.size, dtype=torch.int).to(device)
    x = transform(x)
    x = x.unsqueeze(0).to(device)
    xs.append(x)
    oris.append(ori_size)

b = time.time()
for x, ori in zip(xs, oris):
    y = model(x)
    result = postprocessor(y, ori)[0]
e = time.time()
print(e-b, len(xs), len(xs)/(e-b))```

fps is 40 on rtx4060. Its different from the paper. So, what's wrong with my code, thank you
@lyuwenyu
Copy link
Owner

lyuwenyu commented Aug 27, 2024


We test the speed on T4 GPU with TensorRT FP16.


image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants