SahilChachra/Video-Analytics-Dashboard

What changes to make to run in using our own yolov5 moels?

joel5638 opened this issue · 10 comments

Do we have to change the deepsort checkpoint?
We can replace the yolov5s.pt with our custom model. But what else changes do we have to make?

For DeepSort checkpoint file
The path for checkpoint is - deep_sort_pytorch/deep_sort/deep/checkpoint
Refer to this to know to train and use your DeepSort weight file - https://github.com/nwojke/deep_sort

For Yolov5s weight file
In app.py,
I am passing model path in line number 92, 162 and 226 for local video, webcam and RTSP source respectively.
It looks like this detect(weights="yolov5s.pt", ...

To use your own model,
Copy the model to the Video-Analytics-Dashboard folder and update the model name.
For example, if your model name -> yolov5_custom.pt
then modify weights variable

detect(weights="yolov5_custom.pt", ...

Do I need to replace both the deepsort checkpoint and the custom yolov5s.pt file to check results of my custom model?
I already have my own custom yolov5 model. Do i need to train a deepsort to create my own chckpt again?

First try replacing with your Yolov5 weight file. Most probably it'll get the job done.

If, after passing your own Yolov5 weight file, you don't see tracking then I think you will have to see how to train and work with DeepSort checkpoint file.

But I think, just by replacing with your Yolov5 file, it will work without any issues.

Great! One last question. Can we deploy this on AWS and use it there? If yes, do you have any tutorials or any steps?

If you are thinking to deploy this Streamlit app to AWS, then

  1. Create an EC2 instance with GPU and drivers installed (Probably Ubuntu EC2 instance with Tensorflow/PyTorch installed with CUDA)
  2. Setup a conda environment, take your streamlit code to VM with model weight files. Install dependencies.
  3. Open your EC2 instance port to public. (This might help - https://stackoverflow.com/questions/17161345/how-to-open-a-web-server-port-on-ec2-instance)
  4. Run streamlit app. You will get two URLs, 1 IP address and another will be local host.
  5. Copy the IP address URL and paste it on your browser. You should see your streamlit app loading.

I have worked on a similar thing so the above approach should work as per my experience. If not, I think you can check in Streamlit docs.

NOTE - There is a bug in Streamlit. When running any Streamlit app in any cloud VM (OR even local, when passing video/image from some different folder), when you pass video/image via file uploader in Streamlit, the code won't be able to read the image/video because Streamlit doesn't capture the path of file uploaded. Solution - download the video/image, pass it via Streamlit file uploader to a temporary folder and then pass this path to the code.

any docker file instructions to be added in the dockerfile?
Like the
FROM and RUN commands to deploy this on docker. an you help me with dockerfile for deployment? If possible.

Yeah sure. I will try to add it to this repo by end of the day.

Sure Thank you

@SahilChachra Hi, any docker image created?

@joel5638 Hey. I'm busy with few things for few more days. Sorry for late reply. Will upload the docker file as soon as it's possible.
Thanks!