jamescalam
commited on
Commit
•
352b162
1
Parent(s):
9dc041f
Update shrek-detection.py
Browse files- shrek-detection.py +6 -3
shrek-detection.py
CHANGED
@@ -27,6 +27,7 @@ class ImageSet(datasets.GeneratorBasedBuilder):
|
|
27 |
{
|
28 |
'text': datasets.Value("string"),
|
29 |
'image': datasets.Image(),
|
|
|
30 |
}
|
31 |
),
|
32 |
supervised_keys=None,
|
@@ -51,10 +52,12 @@ class ImageSet(datasets.GeneratorBasedBuilder):
|
|
51 |
|
52 |
for idx, (filepath, image) in enumerate(images):
|
53 |
filename = filepath.split('/')[-1][:-4]
|
54 |
-
cls =
|
55 |
-
|
|
|
|
|
56 |
yield idx, {
|
57 |
"image": {"path": filepath, "bytes": image.read()},
|
58 |
"text": description,
|
59 |
-
"is_shrek": cls
|
60 |
}
|
|
|
27 |
{
|
28 |
'text': datasets.Value("string"),
|
29 |
'image': datasets.Image(),
|
30 |
+
'is_shrek': datasets.Value("bool")
|
31 |
}
|
32 |
),
|
33 |
supervised_keys=None,
|
|
|
52 |
|
53 |
for idx, (filepath, image) in enumerate(images):
|
54 |
filename = filepath.split('/')[-1][:-4]
|
55 |
+
cls = filename[0] if filename[0] in ["0", "1"] else None
|
56 |
+
if cls:
|
57 |
+
filename = filename[1:]
|
58 |
+
description = filename.replace('_', ' ').replace('-', ' ')
|
59 |
yield idx, {
|
60 |
"image": {"path": filepath, "bytes": image.read()},
|
61 |
"text": description,
|
62 |
+
"is_shrek": True if cls == "1" else False
|
63 |
}
|