WIP
This commit is contained in:
parent
254a9e9561
commit
c11c3f7a48
31
longinus/longinus/utils/dataset.py
Normal file
31
longinus/longinus/utils/dataset.py
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
from longinus.wikimedia.loaders.pytorch import WikimediaCommonsLoader
|
||||||
|
from longinus.utils.image import Image
|
||||||
|
|
||||||
|
class DatasetLoader():
|
||||||
|
def __init__(self, dataset_size):
|
||||||
|
self.dataset = list()
|
||||||
|
self.dataset_size = dataset_size
|
||||||
|
tmp_dataset = WikimediaCommonsLoader(batch_size=32, resize_to=512, crop_to=512)
|
||||||
|
counter = 0
|
||||||
|
for image in tmp_dataset:
|
||||||
|
self.dataset.append(image)
|
||||||
|
counter+=1
|
||||||
|
if counter >= self.dataset_size:
|
||||||
|
break
|
||||||
|
|
||||||
|
|
||||||
|
def get_dataset(self):
|
||||||
|
return self.dataset
|
||||||
|
|
||||||
|
def get_dataset_size(self):
|
||||||
|
return self.dataset_size
|
||||||
|
|
||||||
|
class Dataset():
|
||||||
|
def __init__(self, dataset_loader: DatasetLoader, dataset_size: int):
|
||||||
|
self.dataset = dataset_loader(dataset_size).get_dataset()
|
||||||
|
self.dataset_converted = self.convert_images()
|
||||||
|
|
||||||
|
def convert_images(self) -> list[Image]:
|
||||||
|
for image in self.dataset:
|
||||||
|
new_image = Image.load_image_from_mem(image)
|
||||||
|
pass
|
@ -12,10 +12,15 @@ class Image:
|
|||||||
def read(self):
|
def read(self):
|
||||||
self.bgr_array = cv.imread(self.path, cv.IMREAD_GRAYSCALE)
|
self.bgr_array = cv.imread(self.path, cv.IMREAD_GRAYSCALE)
|
||||||
self.dct_array = cv.dct(np.float32(self.bgr_array))
|
self.dct_array = cv.dct(np.float32(self.bgr_array))
|
||||||
return self.bgr_array
|
|
||||||
|
|
||||||
def write(self, image_array):
|
def write(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def extract_coefficients(self):
|
def extract_coefficients(self):
|
||||||
pass
|
return self.dct_array
|
||||||
|
|
||||||
|
def load_image_from_mem(self, image_array):
|
||||||
|
self.bgr_array = image_array
|
||||||
|
|
||||||
|
def override_coefficients(self, new_dct_array):
|
||||||
|
self.dct_array = new_dct_array
|
||||||
|
1
longinus/longinus/wikimedia
Submodule
1
longinus/longinus/wikimedia
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 39fa5b4ee0ff12a7c9c36b656b389f3e3a6fddef
|
Loading…
Reference in New Issue
Block a user