Open YuhaoYeSteve opened 6 years ago
hi, i had the same problem, to solve it i had to change the following code part in the yolo_video.py: def detect_video(yolo, video_path, output_path=""): import cv2 vid = cv2.VideoCapture(video_path) if not vid.isOpened():
with this part: def detect_video(yolo, video_path, output_path=""): import cv2 import os
VIDEO_NAME = 'VIDEONAME.flv'
# Grab path to current working directory
CWD_PATH = os.getcwd()
PATH_TO_VIDEO = os.path.join(CWD_PATH,VIDEO_NAME)
vid = cv2.VideoCapture(PATH_TO_VIDEO)
if not vid.isOpened():
with the code the video have to be in the same folder as the yolo_video.py After this u can start with python yolo_video.py agafefkjvne(or anything else ;-)
also u can change
def detect_video(yolo, video_path, output_path=""): import cv2 vid = cv2.VideoCapture(video_path) if not vid.isOpened():
to this:
def detect_video(yolo, video_path, output_path=""): import cv2
pfad="C:/FOLDERNAME/NEXTFOLDERNAME/VIDEONAME.flv"
vid = cv2.VideoCapture(pfad)
so ur videofile can lay where ever u want it to lay :-D
PS: sorry for my english
Thanks a lot! MartinWeniger You really help me a lot!
I made a small demo by using this library and a street dance video. See here: https://www.youtube.com/watch?v=XyInRQF3mq4
nice it looks good. By the Way, i have something similar to yours. When im done i post it too. ;-)
haha, thanks for your help with the initial read in video problem, can't make it without your help
You are welcome
any idea where I can find it?
@YasserTahaSW the Error comes from line 176 in the yolo.py file. There u have to make the changes
@MartinWeniger Thanks a lot! I wrote these lines as you mentioned: def detect_video(yolo, video_path, output_path=""): import cv2 pfad='path_to_my_video.mp4' vid = cv2.VideoCapture(pfad) if not vid.isOpened(): but the problem was still there. because the ."VideoCapture" didn't work.
I then had to install opencv-python (not supported by opencv dev team) and then run again with your code and it worked fine.
Thanks again
sounds good :-D
@MartinWeniger @YuhaoYeSteve I modified it according to your code, while there is an error. def detect_video(yolo, video_path, output_path=""): import cv2 VIDEO_NAME = 'video1.mp4' CWD_PATH = os.getcwd() PATH_TO_VIDEO = os.path.join(CWD_PATH,VIDEO_NAME) vid = cv2.VideoCapture(PATH_TO_VIDEO)
# vid = cv2.VideoCapture(pfad)
if not vid.isOpened():
raise IOError("Couldn't open webcam or video")
my order is python yolo_video.py [video1.mp4] or python yolo_video.py [1.jpg] I have tried this error many times and I am grateful for your help.
@nuannuan1991 i need a little bit more information to help u -which error do u get? -is your video file in the same folder?
hi @MartinWeniger my order is:python yolo_video.py [video1.mp4] yolo_video.py: error: unrecognized arguments: [video1.mp4]
if my changed to:python yolo_video.py [model_data/yolo_face.h5][model_data/face_anchors.txt][model_data/face_classes.txt][video1.mp4] it has the same error: yolo_video.py: error: unrecognized arguments: [model_data/yolo_face.h5][model_data/face_anchors.txt][model_data/face_classes.txt][video1.mp4] My video and yolo_video.py are in the main folder. I have no idea
Have you solved your problem? I encounter the same error @nuannuan1991 yolo_video.py: error: unrecognized arguments:
Have you solved your problem? I encounter the same error @nuannuan1991 @Richardkang1992 yolo_video.py: error: unrecognized arguments:
I got same error. How to solve the issue?
I updated opencv to 3.4.1 and that solved the problem.
Thanks for your sharing!
发件人: VivecLou notifications@github.com 发送时间: 2018年12月2日 12:43 收件人: qqwweee/keras-yolo3 keras-yolo3@noreply.github.com 抄送: Kang, Hao/康 昊 kanghao@cn.fujitsu.com; Mention mention@noreply.github.com 主题: Re: [qqwweee/keras-yolo3] Couldn't open webcam or video problem (#149)
I updated opencv to 3.4.1 and that solved the problem.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/qqwweee/keras-yolo3/issues/149#issuecomment-443481126, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AqA0NjQo0oz8nrke9YyR8d20Tt392bmVks5u01pVgaJpZM4VChPr. {"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/qqwweee/keras-yolo3","title":"qqwweee/keras-yolo3","subtitle":"GitHub repository","main_image_url":"https://assets-cdn.github.com/images/email/message_cards/header.png","avatar_image_url":"https://assets-cdn.github.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/qqwweee/keras-yolo3"}},"updates":{"snippets":[{"icon":"PERSON","message":"@VivecLou in #149: I updated opencv to 3.4.1 and that solved the problem."}],"action":{"name":"View Issue","url":"https://github.com/qqwweee/keras-yolo3/issues/149#issuecomment-443481126"}}} [ { "@context": "http://schema.org", "@type": "EmailMessage", "potentialAction": { "@type": "ViewAction", "target": "https://github.com/qqwweee/keras-yolo3/issues/149#issuecomment-443481126", "url": "https://github.com/qqwweee/keras-yolo3/issues/149#issuecomment-443481126", "name": "View Issue" }, "description": "View this Issue on GitHub", "publisher": { "@type": "Organization", "name": "GitHub", "url": "https://github.com" } }, { "@type": "MessageCard", "@context": "http://schema.org/extensions", "hideOriginalBody": "false", "originator": "AF6C5A86-E920-430C-9C59-A73278B5EFEB", "title": "Re: [qqwweee/keras-yolo3] Couldn't open webcam or video problem (#149)", "sections": [ { "text": "", "activityTitle": "VivecLou", "activityImage": "https://assets-cdn.github.com/images/email/message_cards/avatar.png", "activitySubtitle": "@VivecLou", "facts": [ ] } ], "potentialAction": [ { "name": "Add a comment", "@type": "ActionCard", "inputs": [ { "isMultiLine": true, "@type": "TextInput", "id": "IssueComment", "isRequired": false } ], "actions": [ { "name": "Comment", "@type": "HttpPOST", "target": "https://api.github.com", "body": "{\n\"commandName\": \"IssueComment\",\n\"repositoryFullName\": \"qqwweee/keras-yolo3\",\n\"issueId\": 149,\n\"IssueComment\": \"{{IssueComment.value}}\"\n}" } ] }, { "name": "Close issue", "@type": "HttpPOST", "target": "https://api.github.com", "body": "{\n\"commandName\": \"IssueClose\",\n\"repositoryFullName\": \"qqwweee/keras-yolo3\",\n\"issueId\": 149\n}" }, { "targets": [ { "os": "default", "uri": "https://github.com/qqwweee/keras-yolo3/issues/149#issuecomment-443481126" } ], "@type": "OpenUri", "name": "View on GitHub" }, { "name": "Unsubscribe", "@type": "HttpPOST", "target": "https://api.github.com", "body": "{\n\"commandName\": \"MuteNotification\",\n\"threadId\": 352981995\n}" } ], "themeColor": "26292E" } ]
hi, i had the same problem, to solve it i had to change the following code part in the yolo_video.py: def detect_video(yolo, video_path, output_path=""): import cv2 vid = cv2.VideoCapture(video_path) if not vid.isOpened():
with this part: def detect_video(yolo, video_path, output_path=""): import cv2 import os
VIDEO_NAME = 'VIDEONAME.flv' # Grab path to current working directory CWD_PATH = os.getcwd() PATH_TO_VIDEO = os.path.join(CWD_PATH,VIDEO_NAME) vid = cv2.VideoCapture(PATH_TO_VIDEO) if not vid.isOpened():
with the code the video have to be in the same folder as the yolo_video.py After this u can start with python yolo_video.py agafefkjvne(or anything else ;-)
I use the method solve my problem,thank you.
Thanks a lot for your sharing!
发件人: Mrsunshunli notifications@github.com 发送时间: 2018年12月9日 22:20 收件人: qqwweee/keras-yolo3 keras-yolo3@noreply.github.com 抄送: Kang, Hao/康 昊 kanghao@cn.fujitsu.com; Mention mention@noreply.github.com 主题: Re: [qqwweee/keras-yolo3] Couldn't open webcam or video problem (#149)
hi, i had the same problem, to solve it i had to change the following code part in the yolo_video.py: def detect_video(yolo, video_path, output_path=""): import cv2 vid = cv2.VideoCapture(video_path) if not vid.isOpened():
with this part: def detect_video(yolo, video_path, output_path=""): import cv2 import os
VIDEO_NAME = 'VIDEONAME.flv'
CWD_PATH = os.getcwd()
PATH_TO_VIDEO = os.path.join(CWD_PATH,VIDEO_NAME)
vid = cv2.VideoCapture(PATH_TO_VIDEO)
if not vid.isOpened():
with the code the video have to be in the same folder as the yolo_video.py After this u can start with python yolo_video.py agafefkjvne(or anything else ;-)
I use the method solve my problem,thank you.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHubhttps://github.com/qqwweee/keras-yolo3/issues/149#issuecomment-445541915, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AqA0NtZB7VeXSbxQuDlaH_8Xe8MnG0Wbks5u3RwQgaJpZM4VChPr.
{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/qqwweee/keras-yolo3","title":"qqwweee/keras-yolo3","subtitle":"GitHub repository","main_image_url":"https://assets-cdn.github.com/images/email/message_cards/header.png","avatar_image_url":"https://assets-cdn.github.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/qqwweee/keras-yolo3"}},"updates":{"snippets":[{"icon":"PERSON","message":"@Mrsunshunli in #149: \u003e hi, i had the same problem, to solve it i had to change the following code part in the yolo_video.py:\r\n\u003e def detect_video(yolo, video_path, output_path=\"\"):\r\n\u003e import cv2\r\n\u003e vid = cv2.VideoCapture(video_path)\r\n\u003e if not vid.isOpened():\r\n\u003e \r\n\u003e with this part:\r\n\u003e def detect_video(yolo, video_path, output_path=\"\"):\r\n\u003e import cv2\r\n\u003e import os\r\n\u003e \r\n\u003e \r\n\u003e VIDEO_NAME = 'VIDEONAME.flv'\r\n\u003e # Grab path to current working directory\r\n\u003e CWD_PATH = os.getcwd()\r\n\u003e PATH_TO_VIDEO = os.path.join(CWD_PATH,VIDEO_NAME)\r\n\u003e vid = cv2.VideoCapture(PATH_TO_VIDEO)\r\n\u003e if not vid.isOpened():\r\n\u003e
\r\n\u003e with the code the video have to be in the same folder as the yolo_video.py\r\n\u003e After this u can start with python yolo_video.py agafefkjvne(or anything else ;-)\r\n\r\nI use the method solve my problem,thank you."}],"action":{"name":"View Issue","url":"https://github.com/qqwweee/keras-yolo3/issues/149#issuecomment-445541915"}}} [ { "@context": "http://schema.org", "@type": "EmailMessage", "potentialAction": { "@type": "ViewAction", "target": "https://github.com/qqwweee/keras-yolo3/issues/149#issuecomment-445541915", "url": "https://github.com/qqwweee/keras-yolo3/issues/149#issuecomment-445541915", "name": "View Issue" }, "description": "View this Issue on GitHub", "publisher": { "@type": "Organization", "name": "GitHub", "url": "https://github.com" } }, { "@type": "MessageCard", "@context": "http://schema.org/extensions", "hideOriginalBody": "false", "originator": "AF6C5A86-E920-430C-9C59-A73278B5EFEB", "title": "Re: [qqwweee/keras-yolo3] Couldn't open webcam or video problem (#149)", "sections": [ { "text": "", "activityTitle": "Mrsunshunli", "activityImage": "https://assets-cdn.github.com/images/email/message_cards/avatar.png", "activitySubtitle": "@Mrsunshunli", "facts": [ ] } ], "potentialAction": [ { "name": "Add a comment", "@type": "ActionCard", "inputs": [ { "isMultiLine": true, "@type": "TextInput", "id": "IssueComment", "isRequired": false } ], "actions": [ { "name": "Comment", "@type": "HttpPOST", "target": "https://api.github.com", "body": "{\n\"commandName\": \"IssueComment\",\n\"repositoryFullName\": \"qqwweee/keras-yolo3\",\n\"issueId\": 149,\n\"IssueComment\": \"{{IssueComment.value}}\"\n}" } ] }, { "name": "Close issue", "@type": "HttpPOST", "target": "https://api.github.com", "body": "{\n\"commandName\": \"IssueClose\",\n\"repositoryFullName\": \"qqwweee/keras-yolo3\",\n\"issueId\": 149\n}" }, { "targets": [ { "os": "default", "uri": "https://github.com/qqwweee/keras-yolo3/issues/149#issuecomment-445541915" } ], "@type": "OpenUri", "name": "View on GitHub" }, { "name": "Unsubscribe", "@type": "HttpPOST", "target": "https://api.github.com", "body": "{\n\"commandName\": \"MuteNotification\",\n\"threadId\": 352981995\n}" } ], "themeColor": "26292E" } ]
when i change the code as you mentionned i get this error
Hi @cyrineee, The Error message says that u used ur tabs and spaces inconsistent. Python is really strict with using tabs and spaces, so i think the solution for ur Problem is the use it correctly. Maybe ur using a tab and a space at an Line in ur code, or u have used an tab on one line and on an other line u have used spaces.
Thanks for sharing! My code is working now. I changed my code to:
def detect_video(yolo, video_path, output_path=""): import cv2 pfad = r"C:\code\tensorflow\keras-yolo3-master-video\video1.mp4" vid = cv2.VideoCapture(pfad) if not vid.isOpened():
and in CMD command, write: python yolo_video.py --input
@YuhaoYeSteve @MartinWeniger @YasserTahaSW @nuannuan1991 @MartinWeniger88 @ellezhang @cyrineee this YOLOv3 tutorial may help you: https://github.com/ultralytics/yolov3/wiki/Train-Custom-Data
The accompanying repository works on MacOS, Windows and Linux, includes multigpu and multithreading, performs inference on images, videos, webcams, and an iOS app. It also tests to slightly higher mAPs than darknet, including on the latest YOLOv3-SPP.weights
(60.7 COCO mAP), and offers the ability to train custom datasets from scratch to darknet performance, all using PyTorch :)
https://github.com/ultralytics/yolov3
|
---|
hello. i am a primary learner.when i did what you said,it occur a new problem. AttributeError:'YOLO' obeject has no attribute 'sess' thank you!
I've got a solution here: in file yolo_video.py Line55, just replace the path to your full path, remember, full path!
for example:
parser.add_argument(
"--input", nargs='?', type=str,required=False,default='D:/keras-yolo3-master/video/0.mp4',
help = "Video input path"
)
or in commond line in your env:
python yolo_video.py --input D:/keras-yolo3-master/video/0.mp4
@MartinWeniger Thanks a lot! I wrote these lines as you mentioned: def detect_video(yolo, video_path, output_path=""): import cv2 pfad='path_to_my_video.mp4' vid = cv2.VideoCapture(pfad) if not vid.isOpened(): but the problem was still there. because the ."VideoCapture" didn't work.
I then had to install opencv-python (not supported by opencv dev team) and then run again with your code and it worked fine.
Thanks again
hey! I got the same problem TAT,have you solved it?
For example, I type: python yolo_video.py [1.mp4] or python yolo_video.py [C:\Users\keras-yolo3\1.mp4] response is : model_data/yolo.h5 model, anchors, and classes loaded. warning: Error opening file (/build/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:808) warning: [1.mp4] (/build/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:809) Traceback (most recent call last): File "yolo_video.py", line 16, in detect_video(YOLO(), video_path) File "C:\Users\keras-yolo3\yolo.py", line 167, in detect_video raise IOError("Couldn't open webcam or video") OSError: Couldn't open webcam or video