JAWCF commited on
Commit
e2821d1
·
1 Parent(s): 9079446

Update characters.py

Browse files
Files changed (1) hide show
  1. characters.py +5 -14
characters.py CHANGED
@@ -17,6 +17,8 @@
17
  """Dream!n character datasets"""
18
 
19
  import datasets
 
 
20
 
21
  _CITATION = """
22
  """
@@ -26,19 +28,8 @@ _DESCRIPTION = "Dream!n character datasets"
26
 
27
  _DATASET_URL = "https://huggingface.co/datasets/JAWCF/characters/resolve/main/images.tar.gz"
28
 
29
- DICT_DESC = {
30
- "./images/apprentice.png": "An apprentice from Star Wars who has white markers on face and a tribe hat",
31
- "./images/bounty.PNG": "A bounty hunter from Star Wars who wears green armor",
32
- "./images/harry.PNG": "Harry Potter from Harry Potter",
33
- "./images/hermione.PNG": "Hermione Granger from Harry Potter",
34
- "./images/jawa.PNG": "A Jawa from Star Wars",
35
- "./images/malfoy.PNG" : "Draco Malfoy from Harry Potter",
36
- "./images/mandalorian.png" : "A Mandalorian from Star Wars",
37
- "./images/moaning.PNG" : "Moaning Myrtle from Harry Potter",
38
- "./images/neville.PNG" : "A male Hogwarts student who has medium length black hair",
39
- "./images/slytherin.PNG": "A Slytherin student who is wearing a hat and has gray hair",
40
- "./images/snape.PNG": "Professor Snape from Harry Potter"
41
- }
42
 
43
  class Characters(datasets.GeneratorBasedBuilder):
44
 
@@ -80,6 +71,6 @@ class Characters(datasets.GeneratorBasedBuilder):
80
  for filepath, image in images:
81
  yield idx, {
82
  "image": {"path": filepath, "bytes": image.read()},
83
- "text" : DICT_DESC[filepath],
84
  }
85
  idx+=1
 
17
  """Dream!n character datasets"""
18
 
19
  import datasets
20
+ import json
21
+ import urllib
22
 
23
  _CITATION = """
24
  """
 
28
 
29
  _DATASET_URL = "https://huggingface.co/datasets/JAWCF/characters/resolve/main/images.tar.gz"
30
 
31
+ json_url = urllib.request.urlopen("https://huggingface.co/datasets/JAWCF/maps/resolve/main/maps.json")
32
+ DICT_DESC = json.loads(json_url.read())
 
 
 
 
 
 
 
 
 
 
 
33
 
34
  class Characters(datasets.GeneratorBasedBuilder):
35
 
 
71
  for filepath, image in images:
72
  yield idx, {
73
  "image": {"path": filepath, "bytes": image.read()},
74
+ "text" : DICT_DESC[filepath.split("/")[-1].lower()],
75
  }
76
  idx+=1