ultralytics / yolov3

YOLOv3 in PyTorch > ONNX > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
10.25k stars 3.45k forks source link

Invalid Syntax error while Normal Training :yolov4 #1613

Closed anusha657 closed 3 years ago

anusha657 commented 3 years ago

a ) I cloned https://github.com/ultralytics/yolov3

b) I m using yolov4.weights and yolov4.cfg from " !git clone https://github.com/AlexeyAB/darknet "

c) I m in step 1 - Normal Training command used - python3 /content/yolov3/train.py --data /content/darknet/cfg/obj_coco.data --batch-size 16 -pt --weights /content/darknet/weights/yolov4.weights --cfg /content/darknet/cfg/yolov4.cfg

d) Error occured : File "", line 1 python3 /content/yolov3/train.py --data /content/darknet/cfg/obj_coco.data --batch-size 16 -pt --weights /content/darknet/weights/yolov4.weights --cfg /content/darknet/cfg/yolov4.cfg ^ SyntaxError: invalid syntax

github-actions[bot] commented 3 years ago

Hello @anusha657, 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 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

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

CI CPU testing

If this badge is green, all YOLOv3 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv3 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.

anusha657 commented 3 years ago

Thanks for the Response , Currently I m stuck in another issue.

Step 1. I m doing the Sparsity Training Using the repository - https://github.com/PengyiZhang/SlimYOLOv3/ and went to Step 2.

Step 2. README.md NOTICE:

TO run sparsity training and channel pruning, ultralytics/yolov3 is required. We only provide the pruning method for channel pruning (prune.py) and subgradient method for sparsity training (sparsity.py). Sparsity training can be done by using updateBN() in sparsity.py before optimizer.step() in train.py. The channel pruning can be done by prune.py.

Step 3. Cloned the repository ultralytics/yolov3
Command Used - ! python3 /content/archived_yolov3/yolov3/train.py --cfg /content/darknet/cfg/yolov4.cfg --data /content/objcoco.data --weights /content/darknet/weights/yolov4.weights

Please find Attachment Error.txt of the Error

glenn-jocher commented 3 years ago

@anusha657 you may want to see the Pruning/Sparsity Tutorial in YOLOv5, which also works in this repo: https://github.com/ultralytics/yolov5#tutorials

anusha657 commented 3 years ago

Thanks @glenn-jocher for replying to my query . That issue is resolved now. I m stuck in another issue .

Sparsity Training - for yolov4

command used - ! python3 /content/archived_yolov3/yolov3/train.py --cfg /content/darknet/cfg/yolov4.cfg --data /content/objcoco.data --weights /content/darknet/weights/yolov4.weights

Apex recommended for faster mixed precision training: https://github.com/NVIDIA/apex Namespace(adam=False, batch_size=16, bucket='', cache_images=False, cfg='/content/darknet/cfg/yolov4.cfg', data='/content/objcoco.data', device='', epochs=300, evolve=False, freeze_layers=False, img_size=[320, 640], multi_scale=False, name='', nosave=False, notest=False, rect=False, resume=False, single_cls=False, weights='/content/darknet/weights/yolov4.weights') Using CUDA device0 _CudaDeviceProperties(name='Tesla T4', total_memory=15079MB)

Start Tensorboard with "tensorboard --logdir=runs", view at http://localhost:6006/ 2020-12-17 18:51:53.613694: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudart.so.10.1 Model Summary: 327 layers, 6.43631e+07 parameters, 6.43631e+07 gradients Optimizer groups: 110 .bias, 110 Conv2d.weight, 107 other Reading image shapes: 0% 0/14 [00:00<?, ?it/s]Traceback (most recent call last): File "/content/archived_yolov3/yolov3/utils/datasets.py", line 298, in init with open(sp, 'r') as f: # read existing shapefile FileNotFoundError: [Errno 2] No such file or directory: '/content/darknet/data/train_coco.shapes'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/content/archived_yolov3/yolov3/train.py", line 432, in train(hyp) # train normally File "/content/archived_yolov3/yolov3/train.py", line 198, in train single_cls=opt.single_cls) File "/content/archived_yolov3/yolov3/utils/datasets.py", line 302, in init s = [exif_size(Image.open(f)) for f in tqdm(self.img_files, desc='Reading image shapes')] File "/content/archived_yolov3/yolov3/utils/datasets.py", line 302, in s = [exif_size(Image.open(f)) for f in tqdm(self.img_files, desc='Reading image shapes')] File "/usr/local/lib/python3.6/dist-packages/PIL/Image.py", line 2809, in open fp = builtins.open(filename, "rb") FileNotFoundError: [Errno 2] No such file or directory: 'data/obj/COCO_train2014_000000000009.jpg' Reading image shapes: 0% 0/14 [00:00<?, ?it/s]

How can we resolve this issue ?

glenn-jocher commented 3 years ago

@anusha657 archive branch is no longer maintained, I would recommend master branch.

anusha657 commented 3 years ago

Thanks for your reply @glenn-jocher , However I have query Is the master branch compatible with yolov4 in case if we use the darknet weights and darknet cfg file ?

glenn-jocher commented 3 years ago

@anusha657 master branch does not support older darknet style cfg and weight files.

BRANCH NOTICE: The ultralytics/yolov3 repository is now divided into two branches:

github-actions[bot] commented 3 years ago

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.