test_submission / script.py
LennartMaack's picture
Update script.py
a2bcb7c verified
## load necessary modules and libaries
import os
## Set Path to test images from folder (image shape is: 360x640x3)
TEST_IMAGE_PATH = "/tmp/data/test_images"
## Set Path to your model weights (stored in your model directory)
# MODEL_WEIGHTS_PATH = 'yolov5s.pt'
## load model
#model = load_model(MODEL_WEIGHTS_PATH) # the load_model function needs to be created by yourself
## run inference on test images to create submission.csv file
# run_inference(model, TEST_IMAGE_PATH) # the run_inference function needs to be created by yourself
### Code to create a sample submission.csv file ###
import csv
data = [
['file_name', 'bbox', 'category_id', 'split'],
['0000.jpg', '[[101.83, 148.06, 127.11, 111.12]]', '[1]', 'public'],
['0229.jpg', '[[230.0, 0.0, 65.33, 158.71]]', '[1]', 'public'],
['0232.jpg', '[[286.8, 110.04, 89.47, 125.36]]', '[2]', 'public'],
['0248.jpg', '[[59.59, 66.05, 211.59, 166.51]]', '[2]', 'public'],
['0586.jpg', '[[317.17, 177.91, 103.36, 78.59], [100.88, 104.64, 7.88, 9.75]]', '[1, 1]', 'public'],
['0765.jpg', '[[428.82, 145.57, 72.78, 77.05]]', '[3]', 'public']
]
filename = 'submission.csv'
with open(filename, 'w', newline='') as file:
writer = csv.writer(file)
writer.writerows(data)
print("Created submission.csv")