Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yolov5 Python package? #2481

Closed
sheromon opened this issue Mar 15, 2021 · 16 comments
Closed

yolov5 Python package? #2481

sheromon opened this issue Mar 15, 2021 · 16 comments
Labels
enhancement New feature or request Stale

Comments

@sheromon
Copy link

🚀 Feature

First of all, thanks for your great work on this object detector! I have started using it recently, and I found it very easy to get started with training and testing.

It would be nice to be able to pip install the yolov5 code and import yolov5 modules without having to add the code directory to the path, in the way that many Python packages work. I was going to request that this repo become a Python package on PyPI, but I found that now there is a yolov5 Python package there associated with this repo, and then I was confused that it appears to be maintained by someone who is not a contributor to this repo. Then I found #2240 where you tell someone that you were working on a PyPI package, but someone else did it first. That seems like not an appropriate thing to do without collaborating with the repository owners?

Were you all still planning to release a PyPI package? I was originally going to offer to help, which is why I checked PyPI first, and then I fell down this rabbit hole.

Motivation

I would like to be able to import modules without having to do custom set up steps like modifying EVs. I saw from past issues like #134 and #353 that other people have had the same issue. In addition to removing the requirement to update the path, another benefit is that if there were a yolov5 Python package with its own namespace, it would prevent potential collisions when importing, like if someone had a "models" or "utils" directory in their Python path. It would be clear if imports were something like "from yolov5.models.experimental import ..." instead of "from models.experimental import ...".

Pitch

I would like to have the yolov5 repository be its own Python package with its own namespace for importing modules.

Alternatives

I suppose the alternative is to leave things as they are.

@sheromon sheromon added the enhancement New feature or request label Mar 15, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Mar 15, 2021

👋 Hello @sheromon, 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://www.ultralytics.com or email Glenn Jocher at glenn.jocher@ultralytics.com.

Requirements

Python 3.8 or later with all requirements.txt dependencies installed, including torch>=1.7. To install run:

$ pip install -r requirements.txt

Environments

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

Status

CI CPU testing

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), testing (test.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu every 24 hours and on every commit.

@github-actions
Copy link
Contributor

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the Stale label Apr 15, 2021
@sheromon
Copy link
Author

I'm sad that my issue is stale. No one wants to talk about the pip package? :-(

@glenn-jocher
Copy link
Member

glenn-jocher commented Apr 15, 2021

@sheromon hi buddy, yes we wanted to create a yolov5 pip package, but the yolov5 package name was actually taken by another unrelated party before we were able to register a package, so we've gone ahead and registered the ultralytics package name for future work, including agent deployment for interfacing with our upcoming Ultralytics Hub platform at https://ultralytics.com

In the meantime I've advised the yolov5 package author that it would be ideal if they could mirror as closely as possible the PyTorch Hub usage and workflow with the pip package.

@fcakyon @sheromon if it were up to me, the yolov5 pip package would essentially be line-replaceable with torch.hub (for single-codebase maintenance and documentation, among other reasons) i.e.:

PyTorch Hub

import torch

# Model
model = torch.hub.load('ultralytics/yolov5', 'yolov5s')

# Image
img = 'https://github.com/ultralytics/yolov5/raw/master/data/images/zidane.jpg'

# Inference
results = model(img)

ideal yolov5 pip package

import yolov5

# Model
model = yolov5.load('yolov5s')

# Image
img = 'https://github.com/ultralytics/yolov5/raw/master/data/images/zidane.jpg'

# Inference
results = model(img)

@fcakyon
Copy link
Member

fcakyon commented Apr 15, 2021

@fcakyon @sheromon if it were up to me, the yolov5 pip package would essentially be line-replaceable with torch.hub (for single-codebase maintenance and documentation, among other reasons) i.e.:

PyTorch Hub

import torch

# Model
model = torch.hub.load('ultralytics/yolov5', 'yolov5s')

# Image
img = 'https://github.com/ultralytics/yolov5/raw/master/data/images/zidane.jpg'

# Inference
results = model(img)

ideal yolov5 pip package

import yolov5

# Model
model = yolov5.load('yolov5s')

# Image
img = 'https://github.com/ultralytics/yolov5/raw/master/data/images/zidane.jpg'

# Inference
results = model(img)

@glenn-jocher Sorry for the delay, I will make the interface similar to this as soon as possible.

@sheromon
Copy link
Author

Thanks for the response, @glenn-jocher and @fcakyon. I'll be honest and say that I'm actually not familiar with PyTorch Hub. My primary suggestion/request is just to include yolov5 in the import statements because that is what was causing import problems for me and for others. It might also make sense to have the setup.py file associated with making the PyPI package live in this repo as well?

I can submit a PR to just add yolov5 to all of the import statements, but it sounds like there are bigger changes afoot, so that probably doesn't make sense?

@fcakyon
Copy link
Member

fcakyon commented Apr 16, 2021

@glenn-jocher new release supports hub-like interface https://github.com/fcakyon/yolov5-pip/releases/tag/5.0.0

@glenn-jocher
Copy link
Member

@fcakyon wow awesome, nice work! Fast response too.

@glenn-jocher
Copy link
Member

@sheromon sure, PR is always welcome, and that way it makes it clear what update you are suggesting!

@sheromon
Copy link
Author

Wow, very nice, @fcakyon!

@glenn-jocher, I hopped over to https://github.com/fcakyon/yolov5-pip/tree/5.0.0 and took a quick look, and it looks like what I'd wanted to add is already incorporated over there.

Uhh... It is a bit confusing that the fcakyon/yolov5-pip repo has those changes, and the ultralytics/yolov5 repo doesn't. Any plans to consolidate or reasons why it makes sense to have them be separate?

@glenn-jocher
Copy link
Member

@sheromon hey buddy, feel free to submit PRs for any features or bug fixes you have in mind!

@sheromon
Copy link
Author

I mean... I could submit a PR with the changes in fcakyon/yolov5-pip to this repo... It feels like a weird thing to do, so I figured I'd ask about it first.

@sheromon
Copy link
Author

But yeah, I'll definitely submit a PR for a straightforward bug or enhancement.

@glenn-jocher
Copy link
Member

@sheromon sure sounds good! What changes did you have in mind exactly? If it's something specific and short a PR is probably a great idea. If it's more complex probably raising a feature request issue is a better idea to discuss.

@sheromon
Copy link
Author

@glenn-jocher, right, so what I was hoping for when I opened this issue is to have yolov5 be a Python package with its own namespace. I see that this has already been done in fcakyon/yolov5-pip. If you are not incorporating all of the changes from fcakyon/yolov5-pip into this repo, then I'd like to suggest at least a small subset of those changes, specifically including the yolov5 directory and namespace for import statements. I'm working on the changes and can open a PR soon.

@github-actions
Copy link
Contributor

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Stale
Projects
None yet
Development

No branches or pull requests

3 participants