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

add __init__.py #3126

Closed
KC-Zhang opened this issue May 11, 2021 · 18 comments · Fixed by #3127 or #3217
Closed

add __init__.py #3126

KC-Zhang opened this issue May 11, 2021 · 18 comments · Fixed by #3127 or #3217
Assignees
Labels
enhancement New feature or request

Comments

@KC-Zhang
Copy link
Contributor

KC-Zhang commented May 11, 2021

🚀 Feature

add an empty __init__.py in the base folder.

Motivation

This way, the yolov5 folder can be installed as a package within our own projects as a git-submodule, and install everything using a setup.py. Since it is not clean to modify contents of a submodule (including adding __init__.py), it's better if the repo already has __init__.py.

Pitch

Alternatives

Additional context

@KC-Zhang KC-Zhang added the enhancement New feature or request label May 11, 2021
@github-actions
Copy link
Contributor

github-actions bot commented May 11, 2021

👋 Hello @KC-Zhang, 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.

@KC-Zhang KC-Zhang reopened this May 11, 2021
@fcakyon
Copy link
Member

fcakyon commented May 12, 2021

@KC-Zhang You can utilize torch hub or use this pypi package for this purpose.

@KC-Zhang
Copy link
Contributor Author

@fcakyon torch hub or PyPI is less flexible. I need to rewrite detection.py to take custom input/output flow from my own project, which depends on utils and models, which is only importable with init.py.

@fcakyon
Copy link
Member

fcakyon commented May 12, 2021

@KC-Zhang You can simply pip install yolov5 and prepare a single detect.py file that uses imports from yolov5. I'm using it this way in my projects.

@KC-Zhang
Copy link
Contributor Author

@fcakyon That could work, let me try that. Is the pip package as good as the github in terms of performance?

@fcakyon
Copy link
Member

fcakyon commented May 12, 2021

@KC-Zhang it is exact copy of this repo, only difference is its pip installable. You can check the source code here.

@glenn-jocher glenn-jocher linked a pull request May 12, 2021 that will close this issue
@glenn-jocher
Copy link
Member

glenn-jocher commented May 12, 2021

@KC-Zhang good news 😃! Your original issue may now been fixed ✅ in PR #3127. To receive this update you can:

  • git pull from within your yolov5/ directory
  • git clone https://github.com/ultralytics/yolov5 again
  • Force-reload PyTorch Hub: model = torch.hub.load('ultralytics/yolov5', 'yolov5s', force_reload=True)
  • View our updated notebooks: Open In Colab Open In Kaggle

Thank you for spotting this issue and informing us of the problem. Please let us know if this update resolves the issue for you, and feel free to inform us of any other issues you discover or feature requests that come to mind. Happy trainings with YOLOv5 🚀!

@KC-Zhang
Copy link
Contributor Author

Heyy Glenn,
I tried using the pip package. But I got error during pip install. It basically says fail to install cocotool. Is there a way to do pip install without cocotool?
pycocotools/_mask.c:6:20: fatal error: Python.h: No such file or directory compilation terminated. error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

@glenn-jocher
Copy link
Member

@KC-Zhang if you're trying to package-ize this repo, you can simply comment it from requirements.txt. If you're talking about the PyPi package then no I think it's baked in as a requirement.

What happens if you just run pip install pycocotools?

@fcakyon
Copy link
Member

fcakyon commented May 17, 2021

@KC-Zhang here are the solutions for your problem: cocodataset/cocoapi#172. It is related with pycocotools package.

@glenn-jocher
Copy link
Member

@fcakyon ah good catch. Perhaps we should add Cython to the requirements.txt here ahead of pycocotools.

@glenn-jocher glenn-jocher reopened this May 17, 2021
@glenn-jocher glenn-jocher linked a pull request May 17, 2021 that will close this issue
@glenn-jocher
Copy link
Member

@KC-Zhang @fcakyon see #3217

@KC-Zhang
Copy link
Contributor Author

Thanks @glenn-jocher @fcakyon for looking into this.

Unfortunately I tried installing cpython and it didn't solve the problem. I am running a python3.8 venv on Ubuntu 16.04.

I tried all combination of pip install Cpython; pip2 install Cpython; pip3 install Cpython; pip install cpython; pip2 install cpython; pip3 install cpython;

@KC-Zhang
Copy link
Contributor Author

KC-Zhang commented May 18, 2021

I think I might have solved the problem a while ago on my local computer by messing with gcc following search result for " error: command 'x86_64-linux-gnu-gcc' failed with exit status 1" on google like this one. But I threw in a lot of command into terminal and not sure what was the exact command that helped.

@fcakyon
Copy link
Member

fcakyon commented May 18, 2021

@KC-Zhang most probably you fixed it by : apt-get install build-essential libffi-dev

@KC-Zhang
Copy link
Contributor Author

@fcakyon thank you for pointing it out. I will confirm it in a new virtual machine when I got some time and confirm it here if it fixes the problem.

@glenn-jocher
Copy link
Member

@KC-Zhang I think you might have a misspelling in your command, the package that pycocotools needs in Cython, not 'cpython'. Use this command:

pip install Cython pycocotools

@KC-Zhang
Copy link
Contributor Author

@glenn-jocher Thank you for pointing it out. I did make a typo and didn't notice haha. I tried the correct spelling this time and it still didn't work unfortunately. What I tried:
pip install Cython pycocotools
pip2 install Cython && pip install pycocotools
pip3 install Cython && pip install pycocotools
pip2 install cython && pip install pycocotools
pip3 install cython && pip install pycocotools

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

Successfully merging a pull request may close this issue.

3 participants