Object Detection Using YOLOv7 and Flask | Object Detection Web Application
Вставка
- Опубліковано 13 лют 2023
- Learn to Create AI Based Personal Protective Equipment Detection System for construction Site using YOLOv7 and Flask.
GitHub code: github.com/AarohiSingla/Objec...
For queries: You can comment in comment section or you can mail me at aarohisingla1987@gmail.com
An AI based inspection system can reliably identify complex situations in real-time and clearly identify previously trained features (e.g. safety helmets & vests) - even under difficult viewing angles, light situations, weather conditions.
In computer vision, real-time object detection is a very important task that is often a key component in computer vision systems.
An object detector is an object detection algorithm that performs image recognition tasks by taking an image as input and then predicting bounding boxes and class probabilities for each object in the image. Most algorithms use a convolutional neural network (CNN) to extract features from the image to predict the probability of learned classes.
What is YOLO in computer vision?
YOLO stands for “You Only Look Once”, it is a popular family of real-time object detection algorithms. The original YOLO object detector was first released in 2016. It was created by Joseph Redmon, Ali Farhadi, and Santosh Divvala. At release, this architecture was much faster than other object detectors and became state-of-the-art for real-time computer vision applications. Since then, different versions and variants of YOLO have been proposed, each providing a significant increase in performance and efficiency. The versions from YOLOv1 to the popular YOLOv3 were created by then-graduate student Joseph Redmon and advisor Ali Farhadi. YOLOv4 was introduced by Alexey Bochkovskiy, who continued the legacy since Redmon had stopped his computer vision research due to ethical concerns. YOLOv7 is the latest official YOLO version created by the original authors of the YOLO architecture. We expect that many commercial networks will move directly from YOLOv4 to v7, bypassing all the other numbers.
#objectdetection #python #flask #webapplicationdevelopment #webapp - Наука та технологія
The best video channel to learn new things.. Thank you for sharing🙏🙏
Glad you think so!
what is the minimum system requirements to use yolo v7?
It's an awesome learning.. Thank you mam, #codeWithAarohi
when i use this code doing 2 post and 2 get . when choose image ?
Thank you for sharing your knowledge!!
My pleasure!
can you guide about yolo8 for detection and counting objects in images.
As usual, a superb presentation.
Many thanks!
@@CodeWithAarohi you're welcome
Hello, after watching your video, I am learning django, and now I want to learn the deployment of deep learning, please can send the complete code, thanks
Thats an amazing video👍👍
Thank you! 👍
Very nice tutorial ma'am. Thank you so much
Keep watching
can you show me how to run this using google collab?
Thanks can you please explain how to deploy ML Model with Flask frontend hosted for free
Thank you so much, Nice tutorial Dear Aarohi.
You are welcome 😊
does yolo algorithm need graphics card pc's? or a particular versions of yolo need GC?
NO, You can also work using CPU. Use the command like this python detect.py --source --weights --device cpu
@@CodeWithAarohi thank you ma'am
I want to use multiple different yolo models on my web page, such as v5 v6 v7, is there any good way?
You can write a function where you can call all those models.
amazing video
i have a question
i have trained a model using detectron2 and i need to use that model to annotate a new images to add them to my train dataset, so is there any way i can do it please ?
Yes, you can use your trained model to annotate new images using Detectron2.
Load the trained model: You can use the detectron2.modeling.build_model function to build a new instance of the model and load the trained weights.
Prepare the new images: You will need to load the new images you want to annotate and convert them into the format expected by Detectron2. This typically involves resizing the images and converting them to the BGR format.
Run inference on the new images: Use the model object to perform inference on the new images. The model object takes as input a list of images and outputs the predicted object instances for each image.
Visualize the annotations: You can use the visualizer object to visualize the annotations on the images. The visualizer takes as input the image and the predicted object instances and outputs the annotated image.
Save the annotations: Finally, you can save the annotations to a format that can be used to update your train dataset. This could be a COCO-style JSON file or any other format that is compatible with your training pipeline.
@@CodeWithAarohi thank you so much
Good work Aarohi..carry on ..
Thank you!
Hello! First thanks so much for this video, I'm having trouble launching the web cam feature, seems like the code in the repo is diferent. I've tried multiple ways to run the web cam but i l keep getting error 500. Any advice or article to help me solve this?
Mail me, I will send you the solution there aarohisingla1987@gmail.com
Hi Aarohi! is there a way to get the class names by hovering over the bounding boxes or by clicking them, rather than displaying all the class names? Because with all the names of the classes the resulting image is really messy.
Yes, you can do that. After performing Object detection on the uploaded image, Send the detected objects to the frontend using AJAX or any other suitable method. Then Implement JAvascript event handlers for hover or click event. When a user hovers over or clicks on a bounding box, trigger an event. When the hover or click event is triggered, use the corresponding bounding box's class label to dynamically display the class name
This is just what I was looking for.
I have a one request, can I get the codes you used in this video please? Because the ones in your repo seem to be a little different. I want to create a similar web app to inference my yolo model on
This code is available for channel members ( Contribution level 2).
Hello, do we need test data folder path inside data.yaml file? as in most of the versions - I have not seen it. Also in your v8 and v5 video - this test path inside data.yaml file is not present ?
Yes, you can skip the test path in yaml file.
@@CodeWithAarohi Hi, in flask file - predict_img.imgpath = f.filename - shows attribute error every time. Could you assist as it is not defined in the code with function predict_img
thank you for this video.
My pleasure!
it seems the github code layout has been updated heavily, i was going to add webcam object detection with yolov7? the image and the video works fine. But this one gives Path and Detection issues
Yes, The design I have provided is the base design and you can work on that from index.html file and css
yolov8 and yolov7, What's the best?
There is no straightforward answer to which is the best between YOLOv7 and YOLOv8, as both are state-of-the-art object detection models that have their strengths and weaknesses.
YOLOv7 is not an official version of YOLO, but rather a community-driven implementation based on YOLOv5. It introduces several improvements over YOLOv5, such as better backbone networks, more advanced data augmentation techniques.
On the other hand, YOLOv8 is the latest official version of the YOLO series, and it introduces several improvements over YOLOv7. YOLOv8 uses a new backbone network, CSPDarknet53, which is faster and more accurate than the Darknet53 backbone used in YOLOv7. YOLOv8 also introduces a new architecture called Path Aggregation Network (PANet), which improves the model's ability to detect objects at different scales.
both YOLOv7 and YOLOv8 are advanced object detection models with their unique features and benefits. The choice of which model to use will depend on various factors, such as the specific application requirements, available computational resources, and desired accuracy and speed trade-offs.
Hello,
Thanks for your video. i'm trying to run the code but i have this error
filename = predict_img.imgpath
AttributeError: 'function' object has no attribute 'imgpath'
predict_img is a function and imgpath is a variable declared inside that function. This variable is storing the filepath on which we want to perform detection. If you are getting error then you can use some other way to get the path of the file(image).
do you have any source of solar panel defect dataset??
No
Can you send me your one kindly? again there is showing an error no attribute called imgpath in predict_img... why is it showing?
predict_img is a function and imgpath is a variable declared inside that function. This variable is storing the filepath on which we want to perform detection. If you are getting error then you can use some other way to get the path of the file(image).
Your videos are always amazing. This is just what I wanted.
I have a kind request, can I get the codes you used in this video please? Because the ones in your repo seem to be a little different. I want to create a similar web app to inference my yolo model on.
Emailed.
Can I get the code ? Please reply 😢
Code is available for channel members ( Contribution level 2)
Can i use pretrained model yolov5 in the code?
Yes
Can you pls share the weights file?
Nice tutorial ma'am. Please give dataset reference as well.
universe.roboflow.com/roboflow-universe-projects/construction-site-safety
If training Yolo v8 rather than v7, will the weight file be the same after training? And also can you pls share the steps on how to set up the flask App? Got an error when I tried to run the project.
The weight file may not be the same as the YOLOv7 weight file after training because the architecture and hyperparameters of the YOLOv8 model may differ from those of the YOLOv7 model, resulting in different weight values.
Can you tell me the version of flask you used whil running the code?
Name: Flask
Version: 2.2.2
@@CodeWithAarohi thanks
Hello mam, i am confused regarding environment setup and running code locally can you please send me step wise instructions and which ide to use.
python -m virtualenv myvenv
myvenv\Scripts\activate
python -m pip install --upgrade pip
git clone github.com/WongKinYiu/yolov7
cd yolov7
pip install -r requirements.txt
Can you create a video explaining the training results and curves of performance
Will try to cover
please,give me function that do real time.
Mam, could you please make a tutorial about object detection using Mask-RCNN and flask | object detection web application
The Mask-RCNN method uses the latest version of tensorflow
ua-cam.com/video/28tadp0Elck/v-deo.html
mam can we modify webapp,py file to send alert message in telegram after object detection
Yes
Here's a general approach to achieve this:
Set up a Telegram bot:
Create a new bot in Telegram by following the instructions provided by the BotFather.
Obtain the bot token that will be used to authenticate your bot.
Install the required packages:
Install the 'telegram-send' package using pip or another package manager.
Modify the Flask application:
Import the 'telegram-send' module in your Flask application (webapp.py file).
After the object detection has been performed, write a function that sends a message to your Telegram bot using the 'telegram-send' package.
Within this function, include the details of the object detection, such as the name of the object detected and the confidence score.
Call this function after the object detection is complete.
Can i do the same process with yolo v5 weights file. Please do reply and Thank you so much for uploading such a informative video
Yes, You can
@@CodeWithAarohi Can u pls help me with what and which places i have to replace in order to get yolo v5
@@vikasm1872 Where I am uploading the yolov8 model. Replace that with your yolov5 model.
Hello, I was looking at the code, I am interested in learning a little more, can you please provide me with the code that you have in the video, it is for my learning.
Send me an email at aarohisingla1987@gmail.com
how can i capture real time window instead of real time webcam ... plz help me mam
you can use a screen capture library such as PyAutoGUI or mss (multiple screen capture).
Can you make detection using yolov8 and django?
Will try after finishing my pipelined videos.
hello, I am level 2 membership of this channel. Would you please share the code including flask and notebook to me ? The code in the Github is not completed yet. I am looking forward to receiving a kind reply from you.
Sure, I will share. Mail me at aarohisingla1987@gmail.com
Can you make video with front end with angular or react ?
I don't have experience in angular or react
Cant we add more objects i need this project for minors i am helpess anyone help me here
Yes, You can add as many objects you want to add. Add images in your dataset and there corresponding txt annotations. After that modify your data.yaml file according to that
@@CodeWithAarohi thank you mam
Mam, It was a Great Video. But mam the Github Code is not complete so can you share the link of your full code.
It will be very helpfull, Thank you
I have provided the base design for this web app. If yo want to modify that then you can do changes in index.html as per your requirement.
rtsp_feed is not opening after running and not in github. can you share new code? please reply
what is the exact error you are getting while using rtsp_stream
@@CodeWithAarohi after clicking icon website don't respond
how to make a webpage for real-time object detection using webcam?
camera = cv2.VideoCapture(0)
def detect_objects(frame):
# Modify this function to detect objects in the frame
# You can use any object detection library or algorithm here
# The output should be an annotated frame with bounding boxes or other visualizations
@app.route('/')
def index():
return render_template('index.html')
def generate_frames():
while True:
success, frame = camera.read()
if not success:
break
else:
frame = detect_objects(frame)
ret, buffer = cv2.imencode('.jpg', frame)
frame = buffer.tobytes()
yield (b'--frame
'
b'Content-Type: image/jpeg
' + frame + b'
')
@app.route('/video_feed')
def video_feed():
return Response(generate_frames(), mimetype='multipart/x-mixed-replace; boundary=frame')
set_logging(verbose=verbose)
TypeError: set_logging() got an unexpected keyword argument 'verbose'
Getting this error while running app
Check the Flask version you are using by running pip show flask. Make sure you are using the latest version of Flask or at least version 1.1.0, which introduced support for the verbose parameter.
how to use this for yolov5 custom model?
Only replace the yolo v7 model with yolov5 model. And modify few lines which are responsible to show bounding boxes of yolov5
@@CodeWithAarohi can you please make the tutorial on how to make yolov5 object detection web application
Can you help me how to do it in flutter, please ?
Never tried that. So can't help you. Sorry
👋
Hi
I need to know how to track workers
As the workers are Person and there are various tracking pretrained models. You can use any of them.
Aarohi please create a video on deploying the yolov7 tflite to an android studio to get apk
I will try
Hi mam, I have taken 2nd level subscription. Can you provide me the code of this video please.
Please email me at aarohisingla1987@gmail.com
Will you kindly share me the design code.. It is not coming like as it is shown in the video...kindly share please.
You can modify the designing files as per your design requirements
@@CodeWithAarohi Can you send me your one kindly? again there is showing an error no attribute called imgpath in predict_img... why is it showing?
Hello Mam, How to reach you?
aarohisingla1987@gmail.com
maam please provide exact html code in your github account
This code is for Level 2 members of my channel.
please share the jupyter notebook mam
This code is for Level 2 members of my channel.
Hi Mam, I have 2nd level subscription. Can you please share me code of this video.
Done
Dear aarohi,
Please upload requirements.txt 🙏🙏
python -m virtualenv myvenv or py -3.9 -m venv myvenv
myvenv\Scripts\activate
python -m pip install --upgrade pip
git clone github.com/WongKinYiu/yolov7
cd yolov7
pip install -r requirements.txt
#after this getting pytorch compatible with cuda. So installed pytorch again with cuda 11.6
pip install torch==1.12.1+cu116 torchvision==0.13.1+cu116 torchaudio==0.12.1 --extra-index-url download.pytorch.org/whl/cu116
Also. Take the requirements.txt from official yolov7 repo
Can't we do this without cuda
@@nit8826 you have to compile the pytorch with cuda if you want to use GPU. Otherwise just run the official yolov7 requirements.txt and you will have the setup which will work with cpu
where is 'best_246.pt' file
This is your custom model. You have to paste it in your flask app directory manually.
Webcam not working internal server error. The server encountered an error and was unable to complete your request. Either the server is overloaded or there is error in the application
i want to join level 2 member, please
You can click on "Join" button and then choose Contribution Level-2
i already pay, hopefully can get yr kind reply on email🥺
Its not working for webcam
Please share the error
hello, I am level 2 membership of this channel. Would you please share the code including flask and notebook to me ? The code in the Github is not completed yet. I am looking forward to receiving a kind reply from you.
Email sent.