Update script.py
Browse files
script.py
CHANGED
|
@@ -1,32 +1,20 @@
|
|
|
|
|
|
|
|
| 1 |
import os
|
| 2 |
-
from PIL import Image
|
| 3 |
-
import pandas as pd
|
| 4 |
|
| 5 |
-
def get_image_data(folder_path):
|
| 6 |
-
image_data = []
|
| 7 |
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
if os.path.isfile(file_path) and filename.lower().endswith(('.png', '.jpg', '.jpeg', '.gif', '.bmp')):
|
| 14 |
-
try:
|
| 15 |
-
with Image.open(file_path) as img:
|
| 16 |
-
width, _ = img.size
|
| 17 |
-
image_data.append({'id': filename, 'pred': width})
|
| 18 |
-
except IOError:
|
| 19 |
-
print(f"Error opening {filename}. Skipping this file.")
|
| 20 |
-
|
| 21 |
-
return image_data
|
| 22 |
|
| 23 |
-
# Specify the folder path
|
| 24 |
-
folder_path = "/tmp/data/data"
|
| 25 |
|
| 26 |
-
#
|
| 27 |
-
|
| 28 |
|
| 29 |
-
#
|
| 30 |
-
|
| 31 |
|
| 32 |
-
|
|
|
|
|
|
| 1 |
+
## load necessary modules and libaries
|
| 2 |
+
import cv2
|
| 3 |
import os
|
|
|
|
|
|
|
| 4 |
|
|
|
|
|
|
|
| 5 |
|
| 6 |
+
## Set Path to test images from folder (image shape is: 360x640x3)
|
| 7 |
+
TEST_IMAGE_PATH = "/tmp/data/test_images"
|
| 8 |
+
print()
|
| 9 |
+
print(os.listdir(TEST_IMAGE_PATH))
|
| 10 |
+
print()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
|
|
|
|
|
|
| 12 |
|
| 13 |
+
## Set Path to your model weights (stored in your model directory)
|
| 14 |
+
# MODEL_WEIGHTS_PATH = 'yolov5s.pt'
|
| 15 |
|
| 16 |
+
## load model
|
| 17 |
+
#model = load_model(MODEL_WEIGHTS_PATH) # the load_model function needs to be created by yourself
|
| 18 |
|
| 19 |
+
## run inference on test images to create submission.csv file
|
| 20 |
+
# run_inference(model, TEST_IMAGE_PATH) # the run_inference function needs to be created by yourself
|