GithubHelp home page GithubHelp logo

Comments (9)

glenn-jocher avatar glenn-jocher commented on June 3, 2024 2

您好!😊

看起来问题仍然存在,可能是因为torch.hub在查找模型时遇到了一些困难。这种情况下,一个可行的解决方案是直接从GitHub克隆YOLOv3的仓库,并使用本地版本运行模型。这样可以避开torch.hub.load可能遇到的问题。请按照以下步骤操作:

  1. 从GitHub克隆YOLOv3仓库到您的本地环境。
  2. 使用本地代码加载模型及权重。

下面的代码示例假设您已经将YOLOv3仓库克隆到本地,并在相应的环境中运行:

import torch
from models import *  # 确保这是从您克隆的YOLOv3仓库中导入的
from utils import *   # 同上

# 初始化模型
model = Darknet('path/to/your/yolov3.cfg').cuda()  # 配置文件路径
model.load_weights('path/to/your/yolov3-tiny.pt')  # 权重文件路径

# 加载图片
img_path = 'path/to/your/test.png'
img = load_images(img_path)  # 使用YOLOv3仓库中的utils函数或自定义的加载图片方法

# 推理
results = model(img)
results.print()  # 或使用其他方式处理结果

请确保替换所有的'path/to/...'为您的实际文件路径。

希望这个方法对您有所帮助!如果还有其他问题,请随时告诉我们。

from yolov3.

github-actions avatar github-actions commented on June 3, 2024

👋 Hello @Pandoravirus-N-T, thank you for your interest in YOLOv3 🚀! 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 a minimum reproducible example to help us debug it.

If this is a custom training ❓ Question, please provide as much information as possible, including dataset image examples and training logs, and verify you are following our Tips for Best Training Results.

Requirements

Python>=3.7.0 with all requirements.txt installed including PyTorch>=1.7. To get started:

git clone https://github.com/ultralytics/yolov3  # clone
cd yolov3
pip install -r requirements.txt  # install

Environments

YOLOv3 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):

Status

YOLOv3 CI

If this badge is green, all YOLOv3 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv3 training, validation, inference, export and benchmarks on macOS, Windows, and Ubuntu every 24 hours and on every commit.

Introducing YOLOv8 🚀

We're excited to announce the launch of our latest state-of-the-art (SOTA) object detection model for 2023 - YOLOv8 🚀!

Designed to be fast, accurate, and easy to use, YOLOv8 is an ideal choice for a wide range of object detection, image segmentation and image classification tasks. With YOLOv8, you'll be able to quickly and accurately detect objects in real-time, streamline your workflows, and achieve new levels of accuracy in your projects.

Check out our YOLOv8 Docs for details and get started with:

pip install ultralytics

from yolov3.

glenn-jocher avatar glenn-jocher commented on June 3, 2024

您好!👋

看起来您在尝试通过 torch.hub.load 加载YOLOv3时遇到了问题。这个错误可能是因为您尝试加载的模型名称不正确,或者是使用方式有所偏差。

确保您正在使用的Torch版本与YOLOv3兼容。对于这个具体的问题,建议使用以下代码示例正确加载模型:

import torch

# 确保模型名称是正确的
model = torch.hub.load('ultralytics/yolov3', 'yolov3', pretrained=True)

如果您仍然遇到问题,请参考我们的官方文档 https://docs.ultralytics.com/ 获取更多帮助和指导。

祝编码愉快!如果有进一步的问题,我们一直在这里帮助您。

from yolov3.

Pandoravirus-N-T avatar Pandoravirus-N-T commented on June 3, 2024

你好这是我的代码
import torch
from torchvision.models import detection

Model

model = torch.hub.load("ultralytics/yolov3", "yolov3", trust_repo=True)
model.load_state_dict(torch.load(r"\yolov3-tiny.pt")) # Load pretrained weights from local file

Images

img = r"results\test.png" # or file, Path, PIL, OpenCV, numpy, list

Inference

results = model(img)

Results

results.print() # or .show(), .save(), .crop(), .pandas(), etc.
我的报错为
RuntimeError: Cannot find callable yolov3 in hubconf
我不知道如何修改了,我的理解是位置变动或者因为网络不好造成的,有没有比如调包的方式在本地运行

from yolov3.

glenn-jocher avatar glenn-jocher commented on June 3, 2024

您好!😊

遇到的问题可能是由于尝试用torch.hub.load直接加载"yolov3"模型时发生的一些混淆,以及在加载本地权重文件时的用法上有点小错误。给您提供一下建议:

确保模型正确加载,后续再用本地权重更新模型,可以使用以下代码:

import torch

# 正确加载模型
model = torch.hub.load('ultralytics/yolov3', 'yolov3', pretrained=True, trust_repo=True)

# 加载本地权重文件(如果你有YOLOv3的权重,并希望用它来更新模型)
weights_path = "path/to/your/yolov3-tiny.pt"  # 请确保这里的路径是正确的
model.load_state_dict(torch.load(weights_path))

注意,请替换 "path/to/your/yolov3-tiny.pt" 为您本地权重文件的实际路径。

如果您要处理的是本地图片文件,可以这样使用:

img_path = "path/to/your/test.png"  # 确保这里的路径是正确的
results = model(img_path)
results.print()  # 或其他结果处理方式,如.show(), .save()等

希望这能帮到您!如果仍有疑问,请随时向我们反馈。👍

from yolov3.

Pandoravirus-N-T avatar Pandoravirus-N-T commented on June 3, 2024

按您的方法修改后还是报错
import torch

正确加载模型

model = torch.hub.load('ultralytics/yolov3', 'yolov3', pretrained=True, trust_repo=True)

加载本地权重文件(如果你有YOLOv3的权重,并希望用它来更新模型)

weights_path = r“\yolov3-tiny.pt" # 请确保这里的路径是正确的
model.load_state_dict(torch.load(weights_path))
img_path = r"test_kindle.png" # 确保这里的路径是正确的
results = model(img_path)
results.print() # 或其他结果处理方式,如.show(), .save()等
报错为
Using cache found in C:\Users\Lenovo/.cache\torch\hub\ultralytics_yolov3_master
Traceback (most recent call last):
File "C:\Users\Lenovo\Desktop\pythonProject\main.py", line 4, in
model = torch.hub.load('ultralytics/yolov3', 'yolov3', pretrained=True, trust_repo=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\python\Lib\site-packages\torch\hub.py", line 566, in load
model = _load_local(repo_or_dir, model, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\python\Lib\site-packages\torch\hub.py", line 594, in _load_local
entry = _load_entry_from_hubconf(hub_module, model)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\python\Lib\site-packages\torch\hub.py", line 348, in _load_entry_from_hubconf
raise RuntimeError(f'Cannot find callable {model} in hubconf')
RuntimeError: Cannot find callable yolov3 in hubconf
好像还是不太行,有没有办法单独把框架下载下来,是不是只能把项目拉下来在本地运行了

from yolov3.

Pandoravirus-N-T avatar Pandoravirus-N-T commented on June 3, 2024

嗯好的,谢谢作者您的答复。我在下载模型和参数时发现都是v5的模型,影响吗,因为我的python解释器是3.7版本的

from yolov3.

glenn-jocher avatar glenn-jocher commented on June 3, 2024

您好!😊

非常高兴能帮到您。使用v5模型在Python 3.7上是没问题的,只要确保您的环境中安装了兼容的Torch版本即可。YOLOv5是YOLO系列中的最新版,提供了许多改进和新功能,应该能够很好地满足您的需求。

如果您的项目特定需要使用YOLOv3并且您已经下载了YOLOv5的模型,建议您访问YOLOv3的GitHub页面或使用YOLOv3的直接下载链接来获取YOLOv3模型和权重文件。

祝您编码愉快!如果还有其他问题,请随时联系。

from yolov3.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.