Ocean / FishDetection-FasterRCNN-project /create_sample_data.py
Srijan-Upadhyay's picture
Add files using upload-large-folder tool
c8b3252 verified
Raw
History Blame Contribute Delete
1.9 kB
"""
Create minimal sample data for the Fish Detection project to run end-to-end.
This creates dummy images and CSV files that match the expected format.
"""
import os
import pandas as pd
from PIL import Image
import numpy as np
# Create directory structure
os.makedirs("./data/images", exist_ok=True)
os.makedirs("./data/output", exist_ok=True)
# Create 5 dummy images (100x100 RGB)
num_images = 5
for i in range(num_images):
img = Image.fromarray(np.random.randint(0, 255, (100, 100, 3), dtype=np.uint8))
img.save(f"./data/images/image_{i}.jpg")
# Create dummy CSVs with the expected format
# Columns: image_name, x1, y1, x2, y2, label
# The columns x1, y1, x2, y2, label contain lists (literal strings)
data_train = {
'image_name': ['image_0.jpg', 'image_1.jpg'],
'x1': ['[10, 30]', '[20]'],
'y1': ['[15, 35]', '[25]'],
'x2': ['[40, 60]', '[50]'],
'y2': ['[45, 65]', '[55]'],
'label': ['[1, 2]', '[1]']
}
data_val = {
'image_name': ['image_2.jpg'],
'x1': ['[10]'],
'y1': ['[15]'],
'x2': ['[40]'],
'y2': ['[45]'],
'label': ['[2]']
}
data_test = {
'image_name': ['image_3.jpg', 'image_4.jpg'],
'x1': ['[10, 30]', '[20]'],
'y1': ['[15, 35]', '[25]'],
'x2': ['[40, 60]', '[50]'],
'y2': ['[45, 65]', '[55]'],
'label': ['[1, 2]', '[1]']
}
df_train = pd.DataFrame(data_train)
df_val = pd.DataFrame(data_val)
df_test = pd.DataFrame(data_test)
df_train.to_csv('./data/output/style_train.csv', index=False)
df_val.to_csv('./data/output/validation.csv', index=False)
df_test.to_csv('./data/output/test.csv', index=False)
print("✓ Created sample data:")
print(" - ./data/images/ with 5 dummy images")
print(" - ./data/output/style_train.csv (2 samples)")
print(" - ./data/output/validation.csv (1 sample)")
print(" - ./data/output/test.csv (2 samples)")