vkashko commited on
Commit
770f298
·
1 Parent(s): 775876e

feat: upload script

Browse files
Files changed (1) hide show
  1. printed_photos_attacks.py +32 -40
printed_photos_attacks.py CHANGED
@@ -1,9 +1,8 @@
1
  import datasets
2
- import pandas as pd
3
 
4
  _CITATION = """\
5
  @InProceedings{huggingface:dataset,
6
- title = {anti-spoofing_replay},
7
  author = {TrainingDataPro},
8
  year = {2023}
9
  }
@@ -14,7 +13,7 @@ The dataset consists of 40,000 videos and selfies with unique people. 15,000
14
  attack replays from 4,000 unique devices. 10,000 attacks with A4 printouts and
15
  10,000 attacks with cut-out printouts.
16
  """
17
- _NAME = 'anti-spoofing_replay'
18
 
19
  _HOMEPAGE = f"https://huggingface.co/datasets/TrainingDataPro/{_NAME}"
20
 
@@ -23,53 +22,46 @@ _LICENSE = "cc-by-nc-nd-4.0"
23
  _DATA = f"https://huggingface.co/datasets/TrainingDataPro/{_NAME}/resolve/main/data/"
24
 
25
 
26
- class AntiSpoofingReplay(datasets.GeneratorBasedBuilder):
27
 
28
  def _info(self):
29
- return datasets.DatasetInfo(
30
- description=_DESCRIPTION,
31
- features=datasets.Features({
32
- 'live_video_id': datasets.Value('string'),
33
- 'phone': datasets.Value('string'),
34
- 'video_file': datasets.Value('string'),
35
- 'phone_video_playback': datasets.Value('string'),
36
- 'worker_id': datasets.Value('string')
37
- }),
38
- supervised_keys=None,
39
- homepage=_HOMEPAGE,
40
- citation=_CITATION,
41
- license=_LICENSE)
42
 
43
  def _split_generators(self, dl_manager):
44
- videos = dl_manager.download(f"{_DATA}videos.tar.gz")
45
- annotations = dl_manager.download(f"{_DATA}{_NAME}.csv")
46
- videos = dl_manager.iter_archive(videos)
 
 
 
47
  return [
48
  datasets.SplitGenerator(name=datasets.Split.TRAIN,
49
  gen_kwargs={
50
- "videos": videos,
51
- 'annotations': annotations
 
52
  }),
53
  ]
54
 
55
- def _generate_examples(self, videos, annotations):
56
- annotations_df = pd.read_csv(annotations, sep=';')
57
- for idx, (video_path, video) in enumerate(videos):
58
- file_name = '/'.join(video_path.split('/')[-2:])
59
 
60
  yield idx, {
61
- 'live_video_id':
62
- annotations_df.loc[annotations_df['link'] == file_name]
63
- ['live_video_id'].values[0],
64
- 'phone':
65
- annotations_df.loc[annotations_df['link'] == file_name]
66
- ['phone'].values[0],
67
- 'video_file':
68
- video_path,
69
- 'phone_video_playback':
70
- annotations_df.loc[annotations_df['link'] == file_name]
71
- ['phone_video_playback'].values[0],
72
- 'worker_id':
73
- annotations_df.loc[annotations_df['link'] == file_name]
74
- ['worker_id'].values[0]
75
  }
 
1
  import datasets
 
2
 
3
  _CITATION = """\
4
  @InProceedings{huggingface:dataset,
5
+ title = {printed_photos_attacks},
6
  author = {TrainingDataPro},
7
  year = {2023}
8
  }
 
13
  attack replays from 4,000 unique devices. 10,000 attacks with A4 printouts and
14
  10,000 attacks with cut-out printouts.
15
  """
16
+ _NAME = 'printed_photos_attacks'
17
 
18
  _HOMEPAGE = f"https://huggingface.co/datasets/TrainingDataPro/{_NAME}"
19
 
 
22
  _DATA = f"https://huggingface.co/datasets/TrainingDataPro/{_NAME}/resolve/main/data/"
23
 
24
 
25
+ class PrintedPhotosAttacks(datasets.GeneratorBasedBuilder):
26
 
27
  def _info(self):
28
+ return datasets.DatasetInfo(description=_DESCRIPTION,
29
+ features=datasets.Features({
30
+ 'attack': datasets.Value('string'),
31
+ 'live_selfie': datasets.Image(),
32
+ 'live_video': datasets.Value('string')
33
+ }),
34
+ supervised_keys=None,
35
+ homepage=_HOMEPAGE,
36
+ citation=_CITATION,
37
+ license=_LICENSE)
 
 
 
38
 
39
  def _split_generators(self, dl_manager):
40
+ attacks = dl_manager.download(f"{_DATA}attack.tar.gz")
41
+ live_selfies = dl_manager.download(f"{_DATA}live_selfie.tar.gz")
42
+ live_videos = dl_manager.download(f"{_DATA}live_video.tar.gz")
43
+ attacks = dl_manager.iter_archive(attacks)
44
+ live_selfies = dl_manager.iter_archive(live_selfies)
45
+ live_videos = dl_manager.iter_archive(live_videos)
46
  return [
47
  datasets.SplitGenerator(name=datasets.Split.TRAIN,
48
  gen_kwargs={
49
+ 'attacks': attacks,
50
+ "live_selfies": live_selfies,
51
+ 'live_videos': live_videos
52
  }),
53
  ]
54
 
55
+ def _generate_examples(self, attacks, live_selfies, live_videos):
56
+ for idx, ((attack_path, attack), (live_selfie_path, live_selfie),
57
+ (live_video_path, live_video)) in enumerate(
58
+ zip(attacks, live_selfies, live_videos)):
59
 
60
  yield idx, {
61
+ 'attack': attack_path,
62
+ 'live_selfie': {
63
+ 'path': live_selfie_path,
64
+ 'bytes': live_selfie
65
+ },
66
+ 'live_video': live_video_path
 
 
 
 
 
 
 
 
67
  }