LennartMaack commited on
Commit
184ecb1
·
verified ·
1 Parent(s): 5b171ff

Update script.py

Browse files
Files changed (1) hide show
  1. script.py +13 -25
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
- # Iterate through all files in the folder
9
- for filename in os.listdir(folder_path):
10
- file_path = os.path.join(folder_path, filename)
11
-
12
- # Check if the file is an image
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
- # Get image data
27
- image_data = get_image_data(folder_path)
28
 
29
- # Create DataFrame
30
- df = pd.DataFrame(image_data)
31
 
32
- df.to_csv("solution.csv", index=False)
 
 
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