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

你好,可以帮忙看看这个问题么 #2

Open
jiangtaoo2333 opened this issue Dec 10, 2024 · 4 comments
Open

你好,可以帮忙看看这个问题么 #2

jiangtaoo2333 opened this issue Dec 10, 2024 · 4 comments

Comments

@jiangtaoo2333
Copy link

root@8a9aai3284fgl-0:~/segment-anything-2/det_sam2_inference# python Det_SAM2_pipeline.py
Ultralytics YOLOv8.2.82 __ Python-3.10.8 torch-2.3.1+cu121 CUDA:0 (NVIDIA L40S, 45596MiB)
Setup complete __ (224 CPUs, 1007.3 GB RAM, 4362.2/14298.2 GB disk)
---:30,:30,:60,:60,:None,
________offload_video_to_cpu:True,offload_state_to_cpu:False
Exception in thread Thread-1 (process_video):
Traceback (most recent call last):
File "/root/miniconda3/lib/python3.10/threading.py", line 1016, in bootstrap_inner
self.run()
File "/root/miniconda3/lib/python3.10/threading.py", line 953, in run
self.target(*self.args, **self.kwargs)
File "/root/segment-anything-2/det_sam2_inference/Det_SAM2_pipeline.py", line 146, in process_video
self.video_processor.inference_state = self.video_processor.process_frame(self.video_processor.pre_frames + frame_idx, frame_rgb)
File "/root/segment-anything-2/det_sam2_inference/det_sam2_RT.py", line 431, in process_frame
self.Detect_and_SAM2_inference(frame_idx)
File "/root/segment-anything-2/det_sam2_inference/det_sam2_RT.py", line 388, in Detect_and_SAM2_inference
for out_frame_idx, out_obj_ids, out_mask_logits in self.predictor.propagate_in_video(
File "/root/miniconda3/lib/python3.10/site-packages/torch/utils/contextlib.py", line 35, in generator_context
response = gen.send(None)
File "/root/segment-anything-2/sam2/sam2_video_predictor.py", line 944, in propagate_in_video
raise RuntimeError("
_________")
RuntimeError: ______________________

@GoldenFishes
Copy link
Collaborator

单独运行的det_sam2_RT.py脚本吗?有VideoProcessor类更详细的参数设置可以提供吗?是在AutoDL镜像中运行的还是?看起来是环境的问题。
如果不是AutoDL镜像,可以建议使用AutoDL镜像安装,这样我可以同步复现你可能遇到的任何问题

@jiangtaoo2333
Copy link
Author

单独运行的det_sam2_RT.py脚本吗?有VideoProcessor类更详细的参数设置可以提供吗?是在AutoDL镜像中运行的还是?看起来是环境的问题。 如果不是AutoDL镜像,可以建议使用AutoDL镜像安装,这样我可以同步复现你可能遇到的任何问题

对的,直接用的镜像,只调整了输入视频路径。

@GoldenFishes
Copy link
Collaborator

GoldenFishes commented Dec 12, 2024

我刚刚试了一下镜像,能够正常跑。(使用的是示例视频)
root@autodl-container-a4d24a9043-94440a2d:~/segment-anything-2/det_sam2_inference# python det_sam2_RT.py
Ultralytics YOLOv8.2.82 🚀 Python-3.10.8 torch-2.3.1+cu121 CUDA:0 (NVIDIA GeForce RTX 4090 D, 24210MiB)
Setup complete ✅ (256 CPUs, 755.2 GB RAM, 12.4/30.0 GB disk)
---最大累积帧数:30,检测间隔:30,最大传播长度:60,推理保留帧数:60,预加载内存库:None,
初始化:offload_video_to_cpu:True,offload_state_to_cpu:False
propagate in video start:29,end:0: 100%|████████████████████████████████████████████████████████████| 30/30 [00:03<00:00, 7.57it/s]
propagate in video start:59,end:0: 100%|████████████████████████████████████████████████████████████| 60/60 [00:11<00:00, 5.37it/s]
propagate in video start:89,end:30: 100%|███████████████████████████████████████████████████████████| 60/60 [00:10<00:00, 5.73it/s]
propagate in video start:119,end:60: 100%|██████████████████████████████████████████████████████████| 60/60 [00:09<00:00, 6.11it/s]
propagate in video start:147,end:88: 82%|███████████████████████████████████████████████▎ | 49/60 [00:10<00:02, 5.22it/s]

有两个需要注意的点:
1.请确保如果您没有使用预加载记忆库时,视频第一帧必须为条件帧(即在Det-SAM2中第一帧必须能够被检测模型检测出类别,以自动添加初始条件提示)
2.视频格式(我觉得不太可能是这个问题),只要VideoProcessor中run函数的cv2.VideoCapture(video_path)能以视频流形式打开就没问题。

您应该用的是我提供的检测模型,,它只能检测球场上的台球,请确保你的视频第一帧能够被检测模型检出东西来,可以在det_sam2_RT.py中VideoProcessor.detect_predict()函数中解除注释:
frame_detections.append({
"coordinates": coords,
"class": cls,
"confidence": conf
})
# print if there is detection result
print(f"Frame index (excluding pre-loaded): {absolute_indices[i]-self.pre_frames}: Coordinates: {coords}, Class: {cls}, Confidence: {conf}")

@GoldenFishes
Copy link
Collaborator

能解决吗?是不是第一帧不是条件帧导致的?

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