mariosasko
commited on
Commit
·
a268b9e
1
Parent(s):
aa23eaa
Fix script
Browse files
Action-Effect.py
CHANGED
@@ -1,8 +1,7 @@
|
|
1 |
import json
|
2 |
import datasets
|
3 |
import os
|
4 |
-
|
5 |
-
from numpy import asarray
|
6 |
|
7 |
_CITATION = """\
|
8 |
@inproceedings{gao-etal-2018-action,
|
@@ -30,7 +29,7 @@ _URL = "https://huggingface.co/datasets/sled-umich/Action-Effect"
|
|
30 |
|
31 |
JSON_URL = "http://162.212.153.129/action_effect_info.json"
|
32 |
|
33 |
-
IMGS_URL = "action_effect_image_rs.
|
34 |
|
35 |
class Action_Effect(datasets.GeneratorBasedBuilder):
|
36 |
"""
|
@@ -47,10 +46,8 @@ class Action_Effect(datasets.GeneratorBasedBuilder):
|
|
47 |
"verb noun": datasets.Value("string"),
|
48 |
"effect_sentence_list": datasets.features.Sequence(datasets.Value("string")),
|
49 |
"effect_phrases_list": datasets.features.Sequence(datasets.features.Sequence(datasets.Value("string"))),
|
50 |
-
"positive_image_list": datasets.features.Sequence(datasets.
|
51 |
-
"negative_image_list": datasets.features.Sequence(datasets.
|
52 |
-
# "positive_image_list": datasets.features.Sequence(datasets.Image()),
|
53 |
-
# "negative_image_list": datasets.features.Sequence(datasets.Image()),
|
54 |
}
|
55 |
),
|
56 |
homepage=_URL,
|
@@ -75,22 +72,22 @@ class Action_Effect(datasets.GeneratorBasedBuilder):
|
|
75 |
with open(action_effect_info_path) as f:
|
76 |
action_effect_info = json.load(f)
|
77 |
# img_zip = tarfile.open(img_zip_path)
|
78 |
-
img_root = img_zip_path
|
79 |
for idx, this_ae_info in enumerate(action_effect_info):
|
80 |
this_ae_info['positive_image_list'] = []
|
81 |
this_ae_info['negative_image_list'] = []
|
82 |
vn = this_ae_info["verb noun"]
|
83 |
-
this_image_root_positive = img_root
|
84 |
-
this_image_root_negative = img_root
|
85 |
for img_name in os.listdir(this_image_root_positive):
|
86 |
-
|
87 |
# img_pil = Image.open(this_image_root_positive + img_name)
|
88 |
# img_np = asarray(img_pil)
|
89 |
-
this_ae_info["positive_image_list"].append(
|
90 |
for img_name in os.listdir(this_image_root_negative):
|
91 |
# img_pil = Image.open(this_image_root_negative + img_name)
|
92 |
# img_np = asarray(img_pil)
|
93 |
-
|
94 |
-
this_ae_info["negative_image_list"].append(
|
95 |
yield idx, this_ae_info
|
96 |
|
|
|
1 |
import json
|
2 |
import datasets
|
3 |
import os
|
4 |
+
|
|
|
5 |
|
6 |
_CITATION = """\
|
7 |
@inproceedings{gao-etal-2018-action,
|
|
|
29 |
|
30 |
JSON_URL = "http://162.212.153.129/action_effect_info.json"
|
31 |
|
32 |
+
IMGS_URL = "action_effect_image_rs.zip"
|
33 |
|
34 |
class Action_Effect(datasets.GeneratorBasedBuilder):
|
35 |
"""
|
|
|
46 |
"verb noun": datasets.Value("string"),
|
47 |
"effect_sentence_list": datasets.features.Sequence(datasets.Value("string")),
|
48 |
"effect_phrases_list": datasets.features.Sequence(datasets.features.Sequence(datasets.Value("string"))),
|
49 |
+
"positive_image_list": datasets.features.Sequence(datasets.Image()),
|
50 |
+
"negative_image_list": datasets.features.Sequence(datasets.Image()),
|
|
|
|
|
51 |
}
|
52 |
),
|
53 |
homepage=_URL,
|
|
|
72 |
with open(action_effect_info_path) as f:
|
73 |
action_effect_info = json.load(f)
|
74 |
# img_zip = tarfile.open(img_zip_path)
|
75 |
+
img_root = os.path.join(img_zip_path, "action_effect_image_rs")
|
76 |
for idx, this_ae_info in enumerate(action_effect_info):
|
77 |
this_ae_info['positive_image_list'] = []
|
78 |
this_ae_info['negative_image_list'] = []
|
79 |
vn = this_ae_info["verb noun"]
|
80 |
+
this_image_root_positive = os.path.join(img_root, vn.replace(" ", "+"), "positive")
|
81 |
+
this_image_root_negative = os.path.join(img_root, vn.replace(" ", "+"), "negative")
|
82 |
for img_name in os.listdir(this_image_root_positive):
|
83 |
+
img_path = os.path.join(this_image_root_positive, img_name)
|
84 |
# img_pil = Image.open(this_image_root_positive + img_name)
|
85 |
# img_np = asarray(img_pil)
|
86 |
+
this_ae_info["positive_image_list"].append(img_path)
|
87 |
for img_name in os.listdir(this_image_root_negative):
|
88 |
# img_pil = Image.open(this_image_root_negative + img_name)
|
89 |
# img_np = asarray(img_pil)
|
90 |
+
img_path = os.path.join(this_image_root_negative, img_name)
|
91 |
+
this_ae_info["negative_image_list"].append(img_path)
|
92 |
yield idx, this_ae_info
|
93 |
|
action_effect_image_rs.tar.gz → action_effect_image_rs.zip
RENAMED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:fc37bf74a261f3bae70ec3f5652d22a07713936a17145574b531739465946edb
|
3 |
+
size 407655986
|