Skip to content

Steps Taken to Solve Issues and Run the Yolov4 repositary : #579

@SurajSanap

Description

@SurajSanap

1. Environment Setup
Action: Created a virtual environment and installed dependencies using:
pip install -r requirements.txt

Error: numpy==1.18.2 failed to install due to build issues (ModuleNotFoundError: No module named 'distutils.msvccompiler').
Solution: Removed version restrictions in requirements.txt to allow the latest compatible versions of dependencies to install.

2. Weights Missing
Error: FileNotFoundError: No such file or directory: 'weights/yolov4.weights'.
Solution:
Downloaded yolov4.weights from the official source.
Saved the file in the weights/ directory.

3. CUDA-Related Issue
Error: AssertionError: Torch not compiled with CUDA enabled.
Solution:
Updated the script to run on the CPU by replacing all .cuda() calls with .cpu().

4. OpenCV Coordinate Type Issue
Error: cv2.error: Can't parse 'pt2'. Sequence item with index 0 has a wrong type.
Cause: cv2.rectangle and cv2.putText require integer coordinates, but the script used np.float32.
Solution:
Updated the plot_boxes_cv2 function in the script:
Replaced all occurrences of np.float32 with int for rectangle and text coordinates.

5. Running the Script
Command Used:
python demo.py -cfgfile cfg/yolov4.cfg -weightfile weights/yolov4.weights -imgfile dataset/image_1.jpg

  1. Viewing the Output
    Output File: The annotated image with predictions was saved as created the new directory which name is prediction_outputs and storing the following format : {image_1}_predictions.json in the project directory.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions