14 dec data

This commit is contained in:
Pritimay Sarkar
2023-12-14 21:03:09 +05:30
parent 6bd972276f
commit 7bcdbff123
18 changed files with 237 additions and 16 deletions

View File

@@ -0,0 +1,23 @@
import os
import shutil
import pandas as pd
# Assuming you have a DataFrame named df with columns 'id', 'class', and 'image_path'
# 'image_path' should contain the path to each image
# Example DataFrame creation (replace this with your actual data)
data = {'id': [1, 2, 3],
'class': ['A', 'B', 'A'],
'image_path': ['/path/to/img1.jpg', '/path/to/img2.jpg', '/path/to/img3.jpg']}
df = pd.DataFrame(data)
# Iterate through rows and move images
for index, row in df.iterrows():
class_folder = os.path.join(os.getcwd(), row['class'])
# Create subfolder if it doesn't exist
if not os.path.exists(class_folder):
os.makedirs(class_folder)
# Move image to subfolder
shutil.move(row['_id'], os.path.join(class_folder, f"{row['id']}.jpg"))