Pulling of easy_deploy_tool
Cloning into './sam2_cpp/easy_deploy_tool'...
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
fatal: clone of '[email protected]:zz990099/EasyDeployTool.git' into submodule path 'D:/Tictag/sam2_cpp/easy_deploy_tool' failed
Failed to clone 'easy_deploy_tool'. Retry scheduled
Cloning into './sam2_cpp/easy_deploy_tool'...
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
fatal: clone of '[email protected]:zz990099/EasyDeployTool.git' into submodule path './sam2_cpp/easy_deploy_tool' failed
Failed to clone 'easy_deploy_tool' a second time, aborting
When I try to run git submodule init && git submodule update, it shows the above issue. I've tried to pull the repo from EasyDeployTool and then rerun the command. And then I'm able to build with bash easy_deploy_tool/docker/easy_deploy_startup.sh and able to build the docker images:
=> [8/8] RUN cd /usr/src/tensorrt/samples && make -j
=> exporting to image
=> => exporting layers
=> => writing image sha256:7e8d8cf3c6652e33d6cd712b026c567f9f51803dda85638073bef3bba3375693
=> => naming to docker.io/library/easy_deploy_base_dev:nvidia_gpu_tensorrt_trt8_u2204
REPOSITORY TAG IMAGE ID CREATED SIZE
easy_deploy_base_dev nvidia_gpu_tensorrt_trt8_u2204 7e8d8cf3c665 23 minutes ago 13.7GB
However, if I run bash easy_deploy_tool/docker/into_docker.sh, I encountered the following error. Even I try to run docker run -it easy_deploy_base_dev:nvidia_gpu_tensorrt_trt8_u2204, I cannot find dir of /workspace. It would be appreciated if you can give some suggestions! Thanks!
Error response from daemon: No such container: easy_deploy_sam2_cpp
Error: failed to start containers: easy_deploy_sam2_cpp
Error response from daemon: No such container: easy_deploy_sam2_cpp
Hi! It looks like you're encountering two separate issues. Let me address them individually for you:
- The issue cloning the
EasyDeployToolrepository: This happens because our submodule uses an SSH URL ([email protected]:...). The errorPermission denied (publickey)indicates that your machine doesn't have the correct SSH key configured and linked to your GitHub account for authentication. - The issue after building the image: The script
bash easy_deploy_tool/docker/easy_deploy_startup.shdoes two main things: it builds the Docker image, and then it creates and starts a container using docker run. The name of this container follows the formateasy_deploy_xxx, wherexxxis derived from the name of yoursam2_cppproject directory. Did you download the main project (sam2_cpp) directly via HTTPS (e.g., as a ZIP file)? If so, the folder name might not match the expected pattern, causing the container creation step to fail. Solutions:
- Set up SSH Key for GitHub:
- Generate an SSH key pair on your machine using:
ssh-keygen -t rsa -C "[email protected]"(use your GitHub email). - Add the publickey (the contents of ~/.ssh/id_rsa.pub) to your GitHub account settings under "SSH and GPG keys".
- After setting this up, try cloning the repository again using the SSH method (git clone [email protected]:...). You should then be able to run git submodule init && git submodule updatesuccessfully.
- Check Folder Name & Container:
- Verify the exact name of your
sam2_cppproject folder. - Run
docker ps -ato list all containers (including stopped ones). Look for any existing containers related to this project (their names might start witheasy_deploy_). - If you find an existing container (e.g.,
easy_deploy_sam2_cpp) that seems incorrect or failed, remove it usingdocker rm <container_name>. - Once any conflicting containers are removed, run the
bash easy_deploy_tool/docker/easy_deploy_startup.shscript again. - After the script completes successfully, run
docker ps -aagain. You should now see a container namedeasy_deploy_sam2_cpp(or similar, based on your folder name) in the list.
Hi, thanks for the prompt reply! I solved the first issue and I clone the repo according to readme. The project dir indeed has the same name as the repo, but after running below:
git clone [email protected]:zz990099/sam2_cpp.git
cd sam2_cpp
git submodule init && git submodule update
bash easy_deploy_tool/docker/easy_deploy_startup.sh
# Select `nvidia_gpu` -> `trt8_u2204`
Dcoker images list after running bash easy_deploy_tool/docker/easy_deploy_startup.sh
Could you run docker ps -a and see if there is a container named easy_deploy_sam2_cpp ?
Yes, I checked there's no containers running. I only can see the images.
Okay. I think it is the docker run command went wrong. Could you check if there is the nvidia-container-runtime exists on your host machine? (run cat /etc/docker/daemon.json) Did any error log output when running easy_deploy_startup.sh script?
NAME:
runc - Open Container Initiative runtime
runc is a command line client for running applications packaged according to
the Open Container Initiative (OCI) format and is a compliant implementation of the
Open Container Initiative specification.
runc integrates well with existing process supervisors to provide a production
container runtime environment for applications. It can be used with your
existing process monitoring tools and the container will be spawned as a
direct child of the process supervisor.
Containers are configured using bundles. A bundle for a container is a directory
that includes a specification file named "config.json" and a root filesystem.
The root filesystem contains the contents of the container.
To start a new instance of a container:
# runc run [ -b bundle ] <container-id>
So I suppose there's nvidia-container for the bash script? But if I run the bash script again, it shows that I have no nvidia container?
Image: easy_deploy_base_dev:nvidia_gpu_tensorrt_trt8_u2204 exists! Skip image building process ...
docker: Error response from daemon: unknown or invalid runtime name: nvidia.
See 'docker run --help'.
it shows that I have no nvidia container?
Yes. The easy_deploy_startup.sh script supposes there is a runtime named nvidia on the host machine. It is an old way to utilize gpus in docker container. If you already have the nvidia-container-runtime installed on your host machine, you could write the config into /etc/docker/daemon.json.
user@ubuntu:~$ cat /etc/docker/daemon.json
{
"default-runtime": "nvidia",
"runtimes": {
"nvidia": {
"path": "/usr/bin/nvidia-container-runtime",
"runtimeArgs": []
}
}
}
Sorry, I copied the json and check there's nvidia-container-runtime in /usr/bin, but still get the same error.
Run these commands to reload the docker daemon configuration:
sudo systemctl daemon-reload
sudo systemctl restart docker
Ya, I just released I forgot to reload! I will keep this issue open for few more days, if no issue anymore I will just close it. Thanks!
Okay! Good luck! 😊
Thanks for all the suggestions! Just one more question, I've tried your onnx model and also export from SAM2Export, but the results seem much better using your model. May I know that if you get any tricks in onnx conversion? My exported model is from SAM2 Base+. I checked the script; it used point prompt for masking. Would it be possible that I can use box as prompt?
Also, may I know that if you try to do like prompt a new mask while tracking existing masks? (i.e., MOT like simple tracker)
Base+ V.S. your model
I recall that SAM2 uniformly uses points as prompts, and bounding boxes are converted into points as input. I might be a bit unclear about which model I used (my bad 😣), but it should be the SAM2-small model. The inconsistent tracking performance you observed in the example might be an isolated case. We did not apply any special processing, nor did we use additional prompts or strategies during tracking.
Thanks for instance response! So it means that either I use center of point or bounding boxes (should be center + WH if I'm not wrong), it should be all converted into points as input, right? If let say there's a new object in Nth frame, you think possible that it can prompt a new mask and keep tracking along with existing masks? I may try with MOT if possible tho it would be quite challenging as I went through the codes.
So it means that either I use center of point or bounding boxes (should be center + WH if I'm not wrong), it should be all converted into points as input, right?
Yes. This conversion should been handled automatically by our SAM2TrackModel through its standardized interfaces. However I haven't implemented the code for registering prompts using bounding boxes yet (sorry 😅).
Regarding your requirement of adding a new tracking target at the Nth frame (if I understood correctly), I did consider this when starting the project, and it is indeed possible. However, there are currently some issues that require partial code refactoring and interface optimization. I will work on that! The update will be available soon!
However I haven't implemented the code for registering prompts using bounding boxes yet (sorry 😅).
Thanks a lot, but I think I can solve it myself.
Regarding your requirement of adding a new tracking target at the Nth frame (if I understood correctly), I did consider this when starting the project, and it is indeed possible. However, there are currently some issues that require partial code refactoring and interface optimization.
I've tried to add part of code below in sam2_track.cpp and test it out with second function pasted, it seems work, but it is hardcoded into frame 10 to give a new prompt though.
newly added function sam2_track.cpp
bool Sam2::Track(const std::vector<std::pair<int, int>> &points,
const std::vector<int> &labels,
std::unordered_map<size_t, cv::Mat> &results)
{
CHECK_STATE(points.size() >= 1 && labels.size() == points.size(),
"[Sam2] Track with prompts got invalid points & labels input!");
current_package_->points = points;
current_package_->labels = labels;
current_package_->current_mode = Sam2Mode::Track;
current_package_->current_obj_id = ++obj_id_;
MESSURE_DURATION_AND_CHECK_STATE(PromptPointPreProcessTrackMode(current_package_),
"[Sam2-Track] Prompt-preprocess execute failed!!!");
MESSURE_DURATION_AND_CHECK_STATE(
image_decoder_core_->SyncInfer(current_package_->GetInferBuffer()),
"[Sam2-Track] Register image_decoder sync infer failed!!!");
MESSURE_DURATION_AND_CHECK_STATE(MaskPostProcess(current_package_),
"[Sam2-Track] Mask-postprocess execute failed!!!");
MESSURE_DURATION_AND_CHECK_STATE(RunMemoryEncoderAndRecord(current_package_),
"[Sam2-Track] Mask-postprocess execute failed!!!");
results.insert({obj_id_, current_package_->mask});
return true;
}
new testing function
void sam2_test_track_with_added_prompt_correctness(
const std::shared_ptr<BaseSam2TrackModel> &sam2_model,
const std::string &test_images_dir_path,
const std::vector<std::pair<int, int>> &initial_points,
const std::pair<int, int> &added_point,
const std::string &test_result_dir_path)
{
auto rgb_paths = get_files_in_directory(test_images_dir_path);
std::sort(rgb_paths.begin(), rgb_paths.end());
std::unordered_map<size_t, cv::Mat> masks;
for (size_t i = 0; i < rgb_paths.size(); ++i)
{
cv::Mat image = cv::imread(rgb_paths[i].string());
CHECK(!image.empty());
CHECK(sam2_model->SetImage(image));
if (i == 0)
{
CHECK(sam2_model->Register({initial_points[0]}, std::vector<int>{1}, masks));
} else if (i == 10)
{
// *** FIX: Use Register to add the new object on frame 10 ***
CHECK(sam2_model->Register({added_point}, std::vector<int>{1}, masks));
} else
{
sam2_model->Track(masks);
}
// Add checks for the number of masks
// if (i < 10) {
// CHECK(masks.size() == 1);
// } else {
// CHECK(masks.size() == 2);
// }
if (!test_result_dir_path.empty())
{
if (!std::filesystem::exists(test_result_dir_path))
{
std::filesystem::create_directory(test_result_dir_path);
}
ImageDrawHelper helper(std::make_shared<cv::Mat>(image.clone()));
for (const auto &p_id_mask : masks)
{
helper.addRedMaskToForeground(p_id_mask.second);
}
cv::imwrite(test_result_dir_path / rgb_paths[i].filename(), *helper.getImage());
}
}
}
Thank you for sharing. My concern is that calling Register followed by Track on the Nth frame would cause the target to be calculated twice. This might not significantly impact the tracking performance, but it is indeed an aspect that requires optimization.
Yes, you're right, doing it is not really difficult but optimisation might be challenging part. I'll open another issue when I encounter others. So I close this for now. Thanks a lot for help!