-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmove_sample_images.py
More file actions
60 lines (52 loc) · 1.25 KB
/
move_sample_images.py
File metadata and controls
60 lines (52 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# %%[markdown]
"""
# Move Sample Images
- We would like to move the images that we have sampled and saved in the csv file `styles_sample.csv` to different folders for each of the following categories:
- by `Topwear`, `Shoes`, `Bottomwear`, `Headwear`
- further categorized by `Men` & `Women`
"""
import os
import shutil
# %%
import pandas as pd
# %%
df = pd.read_csv(
os.path.join(
"dataset",
"database",
"item_catalogue_sample.csv",
),
index_col="id",
dtype={
"gender": "category",
"masterCategory": "category",
"subCategory": "category",
"articleType": "category",
"baseColour": "category",
"season": "category",
"productDisplayName": "category",
},
).sort_index(
ascending=True,
)
df.info()
# %%
for ind, row in df.iterrows():
source = os.path.join(
"dataset",
"images",
f"{ind}.jpg",
)
gender = row["gender"]
sub_catergory = row["subCategory"]
destination = os.path.join(
"dataset",
"database",
"item_catalogue_image_sample",
sub_catergory,
gender,
)
if not os.path.isdir(destination):
os.makedirs(destination)
shutil.copy(source, destination)
# %%