Closed zglihs closed 2 years ago
👋 Hello @zglihs, thank you for your interest in YOLOv5 🚀! Please visit our ⭐️ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution.
If this is a 🐛 Bug Report, please provide screenshots and minimum viable code to reproduce your issue, otherwise we can not help you.
If this is a custom training ❓ Question, please provide as much information as possible, including dataset images, training logs, screenshots, and a public link to online W&B logging if available.
For business inquiries or professional support requests please visit https://ultralytics.com or email support@ultralytics.com.
Python>=3.7.0 with all requirements.txt installed including PyTorch>=1.7. To get started:
git clone https://github.com/ultralytics/yolov5 # clone
cd yolov5
pip install -r requirements.txt # install
YOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):
If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training (train.py), validation (val.py), inference (detect.py) and export (export.py) on macOS, Windows, and Ubuntu every 24 hours and on every commit.
There are no brothers with such a problem?
Correction: yolov5 version used is V6.1
I am facing the same issue how to remove this issue?
@zglihs @noreenanwar 👋 hi, thanks for letting us know about this possible problem with YOLOv5 🚀. We've created a few short guidelines below to help users provide what we need in order to start investigating a possible problem.
When asking a question, people will be better able to provide help if you provide code that they can easily understand and use to reproduce the problem. This is referred to by community members as creating a minimum reproducible example. Your code that reproduces the problem should be:
For Ultralytics to provide assistance your code should also be:
git pull
or git clone
a new copy to ensure your problem has not already been solved in master.If you believe your problem meets all the above criteria, please close this issue and raise a new one using the 🐛 Bug Report template with a minimum reproducible example to help us better understand and diagnose your problem.
Thank you! 😃
I am facing the same issue how to remove this issue?
me too, I got the same error
@yuerlong 👋 hi, thanks for letting us know about this possible problem with YOLOv5 🚀. We've created a few short guidelines below to help users provide what we need in order to start investigating a possible problem.
When asking a question, people will be better able to provide help if you provide code that they can easily understand and use to reproduce the problem. This is referred to by community members as creating a minimum reproducible example. Your code that reproduces the problem should be:
For Ultralytics to provide assistance your code should also be:
git pull
or git clone
a new copy to ensure your problem has not already been solved in master.If you believe your problem meets all the above criteria, please close this issue and raise a new one using the 🐛 Bug Report template with a minimum reproducible example to help us better understand and diagnose your problem.
Thank you! 😃
I am facing the same issue how to remove this issue?
I reverted back old commit and this error is gone. It seems that the latest has this issue.
This function is defined as follows: def attempt_load(weights, device=None, inplace=True, fuse=True):
So we need to change the ’map_location=‘ location to ’device=‘
@jxzddup yes that's correct. attempt_load() map_location
argument has been renamed to device
:
https://github.com/ultralytics/yolov5/blob/1ab23fc67f52d44d5f8ce67a895e73c7cbd7aec5/models/experimental.py#L74-L75
👋 Hello, this issue has been automatically marked as stale because it has not had recent activity. Please note it will be closed if no further activity occurs.
Access additional YOLOv5 🚀 resources:
Access additional Ultralytics ⚡ resources:
Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed!
Thank you for your contributions to YOLOv5 🚀 and Vision AI ⭐!
bumped into same issue. map_location -> device WAS model = attempt_load(modelpath, map_location=device) NOW model = attempt_load(modelpath, device=device)
how?
@fahad-2747 the map_location
parameter was renamed to device
in the attempt_load
function. So, to resolve the issue, simply replace map_location=device
with device=device
in the function call.
Here is an example: Before:
model = attempt_load(modelpath, map_location=device)
After:
model = attempt_load(modelpath, device=device)
By making this change, you can resolve the TypeError: attempt_load() got an unexpected keyword argument 'map_location'
issue.
Search before asking
Question
YOLOV5版本:V6.0
1、关于“TypeError: attempt_load() got an unexpected keyword argument 'map_location'”的提示,详细如下是执行和提示 (y5x11) D:\workspace\yolov5>python web_main.py [INFO] YOLOv5 Config: {'source': 'streams.txt', '@source': '为视频图像文件 地址', 'weights': 'runs/train/exp14/weights/best.pt', '@weights': '自己的 模型地址', 'device': '0', '@device': ' 使用的device类别,如是GPU,可填0', 'imgsz': 640, '@imgsz': '输入图像的大小', 'stride': 32, '@stride': ' 步长', 'conf_thres': 0.35, '@conf_thres': '置信值阈值', 'iou_thres': 0.45, '@iou_thres': ' iou阈值', 'augment': False, '@augment': '是否使用图像增强'}
fatal: Not a valid object name HEAD YOLOv5 2022-6-1 Python-3.8.13 torch-1.10.0+cu113 CUDA:0 (NVIDIA GeForce RTX 3060, 12288MiB)
Traceback (most recent call last): File "web_main.py", line 25, in
(y5x11) D:\workspace\yolov5>python web_main.py [INFO] YOLOv5 Config: {'source': 'streams.txt', '@source': '为视频图像文件 地址', 'weights': 'runs/train/exp14/weights/best.pt', '@weights': '自己的 模型地址', 'device': '0', '@device': ' 使用的device类别,如是GPU,可填0', 'imgsz': 640, '@imgsz': '输入图像的大小', 'stride': 32, '@stride': ' 步长', 'conf_thres': 0.35, '@conf_thres': '置信值阈值', 'iou_thres': 0.45, '@iou_thres': ' iou阈值', 'augment': False, '@augment': '是否使用图像增强'}
fatal: Not a valid object name HEAD YOLOv5 2022-6-1 Python-3.8.13 torch-1.10.0+cu113 CUDA:0 (NVIDIA GeForce RTX 3060, 12288MiB)
Traceback (most recent call last): File "web_main.py", line 25, in
darknet = Darknet(opt)
File "D:\workspace\yolov5\yolov5.py", line 20, in init
self.model = attempt_load(self.opt["weights"], map_location=self.device)
TypeError: attempt_load() got an unexpected keyword argument 'map_location'
2、代码如下:
web_main.py
import the necessary packages
from yolov5 import Darknet from camera import LoadStreams, LoadImages from utils.general import non_max_suppression, scale_coords, check_imshow from flask import Response from flask import Flask from flask import render_template import time import torch import json import cv2 import os
initialize a flask object
app = Flask(name)
initialize the video stream and allow the camera sensor to warmup
with open('yolov5_config.json', 'r', encoding='utf8') as fp: opt = json.load(fp) print('[INFO] YOLOv5 Config:', opt)
darknet = Darknet(opt) if darknet.webcam:
cudnn.benchmark = True # set True to speed up constant image size inference
else: dataset = LoadImages(darknet.source, img_size=opt["imgsz"], stride=darknet.stride) time.sleep(2.0)
@app.route("/") def index():
return the rendered template
def detect_gen(dataset, feed_type): view_img = check_imshow() t0 = time.time() for path, img, img0s, vid_cap in dataset: img = darknet.preprocess(img)
@app.route('/video_feed/')
def video_feed(feed_type):
"""Video streaming route. Put this in the src attribute of an img tag."""
if feed_type == 'Camera_0':
return Response(detect_gen(dataset=dataset, feed_type=feed_type),
mimetype='multipart/x-mixed-replace; boundary=frame')
if name == 'main': app.run(host='0.0.0.0', port="5000", threaded=True)
Additional
No response