FileNotFoundError while trying the code snippet
#2
by
Coder109
- opened
Is this dataset still available? If so, what should I do to download your dataset? Hope you can help me.
Code:
from datasets import load_dataset
from PIL import Image
import numpy as np
from huggingface_hub import login
login(token="my_huggingface_token")
def read_image(path_to_image):
with open(path_to_image, "rb") as file:
image = Image.open(file).convert("L").convert("RGB")
image = np.array(image)
return image
if __name__ == "__main__":
dataset = load_dataset("ragavsachdeva/popmanga_test", trust_remote_code=True) # the first time you run this, it will download the images from mangaplus
split = "seen" # "unseen"
for b, example in enumerate(dataset[split]):
image_path, magi_annotations, character_clusters, text_char_matches, text_tail_matches, text_classification, character_names = example.values()
image = read_image(image_path)
character_bboxes = [bbox for bbox, label in zip(magi_annotations["bboxes_as_x1y1x2y2"], magi_annotations["labels"]) if label == 0]
text_bboxes = [bbox for bbox, label in zip(magi_annotations["bboxes_as_x1y1x2y2"], magi_annotations["labels"]) if label == 1]
panel_bboxes = [bbox for bbox, label in zip(magi_annotations["bboxes_as_x1y1x2y2"], magi_annotations["labels"]) if label == 2] # these are generated by the model (included for convenience)
tail_bboxes = [bbox for bbox, label in zip(magi_annotations["bboxes_as_x1y1x2y2"], magi_annotations["labels"]) if label == 3]
Output:
Traceback (most recent call last):
File "C:\programs\test.py", line 15, in <module>
dataset = load_dataset("ragavsachdeva/popmanga_test", trust_remote_code=True) # the first time you run this, it will download the images from mangaplus
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Iwakura\AppData\Local\Programs\Python\Python312\Lib\site-packages\datasets\load.py", line 2084, in load_dataset
builder_instance.download_and_prepare(
File "C:\Users\Iwakura\AppData\Local\Programs\Python\Python312\Lib\site-packages\datasets\builder.py", line 925, in download_and_prepare
self._download_and_prepare(
File "C:\Users\Iwakura\AppData\Local\Programs\Python\Python312\Lib\site-packages\datasets\builder.py", line 1649, in _download_and_prepare
super()._download_and_prepare(
File "C:\Users\Iwakura\AppData\Local\Programs\Python\Python312\Lib\site-packages\datasets\builder.py", line 979, in _download_and_prepare
split_generators = self._split_generators(dl_manager, **split_generators_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Iwakura\.cache\huggingface\modules\datasets_modules\datasets\ragavsachdeva--popmanga_test\afe917c05b517fd61543262154b38a481f88d5837ec9ce410c2e2889b6b3212c\popmanga_test.py", line 25, in _split_generators
extracted_annotations_dir = dl_manager.download_and_extract("annotations.zip")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Iwakura\AppData\Local\Programs\Python\Python312\Lib\site-packages\datasets\download\download_manager.py", line 326, in download_and_extract
return self.extract(self.download(url_or_urls))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Iwakura\AppData\Local\Programs\Python\Python312\Lib\site-packages\datasets\download\download_manager.py", line 299, in extract
extracted_paths = map_nested(
^^^^^^^^^^^
File "C:\Users\Iwakura\AppData\Local\Programs\Python\Python312\Lib\site-packages\datasets\utils\py_utils.py", line 486, in map_nested
mapped = function(data_struct)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Iwakura\AppData\Local\Programs\Python\Python312\Lib\site-packages\datasets\download\download_manager.py", line 229, in _download_single
out = cached_path(url_or_filename, download_config=download_config)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Iwakura\AppData\Local\Programs\Python\Python312\Lib\site-packages\datasets\utils\file_utils.py", line 252, in cached_path
output_path = ExtractManager(cache_dir=download_config.cache_dir).extract(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Iwakura\AppData\Local\Programs\Python\Python312\Lib\site-packages\datasets\utils\extract.py", line 48, in extract
self.extractor.extract(input_path, output_path, extractor_format)
File "C:\Users\Iwakura\AppData\Local\Programs\Python\Python312\Lib\site-packages\datasets\utils\extract.py", line 332, in extract
return extractor.extract(input_path, output_path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Iwakura\AppData\Local\Programs\Python\Python312\Lib\site-packages\datasets\utils\extract.py", line 188, in extract
zip_file.extractall(output_path)
File "C:\Users\Iwakura\AppData\Local\Programs\Python\Python312\Lib\zipfile\__init__.py", line 1744, in extractall
self._extract_member(zipinfo, path, pwd)
File "C:\Users\Iwakura\AppData\Local\Programs\Python\Python312\Lib\zipfile\__init__.py", line 1801, in _extract_member
open(targetpath, "wb") as target:
^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\Iwakura\\.cache\\huggingface\\datasets\\downloads\\extracted\\18fdc45dd3b902639660d52adee50021d8c2fb41d5c2643b16882ce23037e183\\annotations\\Kuroko S Basketball\\Kuroko S Basketball - c001 (web) [Unknown]\\Kuroko S Basketball - c001 (web) - p034 [Unknown].jpg.json'