Skip to content

Instantly share code, notes, and snippets.


Mahesh Deshwal deshwalmahesh

  • Vedantu
  • Noida, India
View GitHub Profile
deshwalmahesh /
Last active Apr 19, 2021
Generate Yolov4 Darknet type Annotations from Bounding Boxe given as (x,y,w,h) and Vice Versa. Also with Yolov4 weights and config file, it generates files for each image. You can use it to extend your data. Creates a classes.txt file in the same DIR as LabelImg can fetch that. Open LabelImg and open the DIR after executing code to verify. Calcu…
import cv2
from PIL import Image
import numpy as np
import glob
def select_box(results:np.ndarray,method:str)->int:
Select a Single BB based on Max Probability or Max area logic
results: Pass in the results by detection module in (classes, scores, boxes) format
View Top-K and Relative Accuracy
# Get top-K accuracy from results. Given a query and its related results, it'll find if any of the Ground Truth are in results.
# Or How many of the results are in Ground Truth
import numpy as np
def get_relative_acc(test_result_indices:[np.ndarray,list],similar_image_indices:[np.ndarray,list])->float:
Check HOW MANY similar images are in returned results for single test image
# because then only it'll be relative. If an image has 2,3,4 similar images, it won't matter. It'll normalize relative acc