vkashko commited on
Commit
58653e4
·
1 Parent(s): 64d2476

refactor: script and readme

Browse files
Files changed (2) hide show
  1. README.md +34 -0
  2. selfie_and_video.py +18 -14
README.md CHANGED
@@ -1,5 +1,39 @@
1
  ---
2
  license: cc-by-nc-nd-4.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
4
  # Selfies and video dataset
5
  4000 people in this dataset. Each person took a selfie on a webcam, took a selfie on a mobile phone. In addition, people recorded video from the phone and from the webcam, on which they pronounced a given set of numbers.
 
1
  ---
2
  license: cc-by-nc-nd-4.0
3
+ dataset_info:
4
+ features:
5
+ - name: photo_1
6
+ dtype: image
7
+ - name: photo_2
8
+ dtype: image
9
+ - name: video_3
10
+ dtype: string
11
+ - name: video_4
12
+ dtype: string
13
+ - name: photo_5
14
+ dtype: image
15
+ - name: photo_6
16
+ dtype: image
17
+ - name: video_7
18
+ dtype: string
19
+ - name: video_8
20
+ dtype: string
21
+ - name: set_id
22
+ dtype: string
23
+ - name: worker_id
24
+ dtype: string
25
+ - name: age
26
+ dtype: int8
27
+ - name: country
28
+ dtype: string
29
+ - name: gender
30
+ dtype: string
31
+ splits:
32
+ - name: train
33
+ num_bytes: 49771508
34
+ num_examples: 10
35
+ download_size: 829589647
36
+ dataset_size: 49771508
37
  ---
38
  # Selfies and video dataset
39
  4000 people in this dataset. Each person took a selfie on a webcam, took a selfie on a mobile phone. In addition, people recorded video from the phone and from the webcam, on which they pronounced a given set of numbers.
selfie_and_video.py CHANGED
@@ -52,7 +52,7 @@ class SelfieAndVideo(datasets.GeneratorBasedBuilder):
52
  )
53
 
54
  def _split_generators(self, dl_manager):
55
- images = dl_manager.download(f"{_DATA}images.tar.gz")
56
  annotations = dl_manager.download(f"{_DATA}{_NAME}.csv")
57
  images = dl_manager.iter_archive(images)
58
  return [
@@ -64,7 +64,7 @@ class SelfieAndVideo(datasets.GeneratorBasedBuilder):
64
  ]
65
 
66
  def _generate_examples(self, images, annotations):
67
- annotations_df = pd.read_csv(annotations, sep=',')
68
  images_data = pd.DataFrame(columns=['Link', 'Bytes'])
69
  for idx, (image_path, image) in enumerate(images):
70
  if image_path.lower().endswith('.jpg'):
@@ -73,28 +73,32 @@ class SelfieAndVideo(datasets.GeneratorBasedBuilder):
73
  'Bytes': image.read()
74
  }
75
 
76
- annotations_df = pd.merge(annotations_df, images_data)
 
 
 
77
  for idx, worker_id in enumerate(pd.unique(annotations_df['WorkerId'])):
78
  annotation = annotations_df.loc[annotations_df['WorkerId'] ==
79
  worker_id]
80
  annotation = annotation.sort_values(['Link'])
81
  data = {
82
- (f'photo_{row[6][37]}' if row[6].lower().endswith('.jpg') else f'video_{row[6][37]}'):
83
  ({
84
- 'path': row[6],
85
- 'bytes': row[7]
86
- } if row[6].lower().endswith('.jpg') else row[6])
87
  for row in annotation.itertuples()
88
  }
 
89
 
90
- age = annotation.loc[annotation['Link'].endswith(
91
  '1.jpg')]['Age'].values[0]
92
- country = annotation.loc[annotation['Link'].endswith(
93
- '1.jpg')]['Country'].values[0]
94
- gender = annotation.loc[annotation['Link'].endswith(
95
- '1.jpg')]['Gender'].values[0]
96
- set_id = annotation.loc[annotation['Link'].endswith(
97
- '1.jpg')]['SetId'].values[0]
98
 
99
  data['worker_id'] = worker_id
100
  data['age'] = age
 
52
  )
53
 
54
  def _split_generators(self, dl_manager):
55
+ images = dl_manager.download(f"{_DATA}data.tar.gz")
56
  annotations = dl_manager.download(f"{_DATA}{_NAME}.csv")
57
  images = dl_manager.iter_archive(images)
58
  return [
 
64
  ]
65
 
66
  def _generate_examples(self, images, annotations):
67
+ annotations_df = pd.read_csv(annotations, sep=';')
68
  images_data = pd.DataFrame(columns=['Link', 'Bytes'])
69
  for idx, (image_path, image) in enumerate(images):
70
  if image_path.lower().endswith('.jpg'):
 
73
  'Bytes': image.read()
74
  }
75
 
76
+ annotations_df = pd.merge(annotations_df,
77
+ images_data,
78
+ on=['Link'],
79
+ how='left')
80
  for idx, worker_id in enumerate(pd.unique(annotations_df['WorkerId'])):
81
  annotation = annotations_df.loc[annotations_df['WorkerId'] ==
82
  worker_id]
83
  annotation = annotation.sort_values(['Link'])
84
  data = {
85
+ (f'photo_{row[7][37]}' if row[7].lower().endswith('.jpg') else f'video_{row[7][37]}'):
86
  ({
87
+ 'path': row[7],
88
+ 'bytes': row[8]
89
+ } if row[7].lower().endswith('.jpg') else row[7])
90
  for row in annotation.itertuples()
91
  }
92
+ print(annotation.head(8))
93
 
94
+ age = annotation.loc[annotation['Link'].str.lower().str.endswith(
95
  '1.jpg')]['Age'].values[0]
96
+ country = annotation.loc[annotation['Link'].str.lower().str.
97
+ endswith('1.jpg')]['Country'].values[0]
98
+ gender = annotation.loc[annotation['Link'].str.lower().str.
99
+ endswith('1.jpg')]['Gender'].values[0]
100
+ set_id = annotation.loc[annotation['Link'].str.lower().str.
101
+ endswith('1.jpg')]['SetId'].values[0]
102
 
103
  data['worker_id'] = worker_id
104
  data['age'] = age