File size: 2,585 Bytes
3692ebf
 
 
 
 
 
d732111
3692ebf
 
 
 
 
 
 
 
129d0bd
 
3692ebf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
129d0bd
3692ebf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d25006f
 
 
 
 
 
129d0bd
d25006f
 
 
 
3692ebf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
"""Dataset class for image dataset."""

import datasets
import os
from datasets.tasks import ImageClassification

_URL = "http://https://huggingface.co/datasets/Racso777/AncientMortar/tree/main/metadata"

_HOMEPAGE = "http://https://huggingface.co/datasets/Racso777/AncientMortar"

_DESCRIPTION = (
    "This dataset consists of test dataset of ancient mortar and with only obsidian images as zip file in it"
)

_NAMES = [ 
    "Obsidian-1to2mm",
    
]
   
        
class AncientMortarConfig(datasets.BuilderConfig):
    """BuilderConfig for COCO cats image."""

    def __init__(
        self,
        data_url,
        url,
        task_templates=None,
        **kwargs,
    ):
        super(AncientMortarConfig, self).__init__(
            version=datasets.Version("1.9.0", ""), **kwargs
        )
        self.data_url = data_url
        self.url = url
        self.task_templates = task_templates
                         
class AncientMortar(datasets.GeneratorBasedBuilder):
    
    BUILDER_CONFIGS = [
        AncientMortarConfig(
            name="image",
            url="",
            data_url="",
        )
    ] 
    
              
   def _info(self):
        return datasets.DatasetInfo(
            description=_DESCRIPTION,
            features=datasets.Features(
                {
                    "image": datasets.Image(),
                    "label": datasets.ClassLabel(),
                }
            ),
            supervised_keys=("image", "label"),
            homepage=_HOMEPAGE,
            citation=_CITATION,
            task_templates=[ImageClassification(image_column="image", label_column="label")],
        )
     
    def _split_generators(self, dl_manager):
        #data_files = dl_manager.download_and_extract(_URL)

        archive_path = dl_manager.download_and_extract(_URLS)
        return [
            datasets.SplitGenerator(
                name=datasets.Split.TEST,
                gen_kwargs={"archive_path": archive_path},
            ),
        ]
    def _generate_examples(self, images, metadata_path):
    """Generate images and labels for splits."""
    with open(metadata_path, encoding="utf-8") as f:
        files_to_keep = set(f.read().split("\n"))
    for file_path, file_obj in images:
        if file_path.startswith(_IMAGES_DIR):
            if file_path[len(_IMAGES_DIR) : -len(".bmp")] in files_to_keep:
                label = file_path.split("/")[2]
                yield file_path, {
                    "image": {"path": file_path, "bytes": file_obj.read()},
                    "label": label,
                }