create test set #2

Merged
s444409 merged 3 commits from test_set into main 2023-01-31 19:54:54 +01:00
Showing only changes of commit dac16b130b - Show all commits

46
load_test_data.py Normal file
View File

@ -0,0 +1,46 @@
import numpy as np
import os
from skimage.io import imread
import cv2 as cv
from pathlib import Path
def load_data(input_dir, newSize=(64,64)):

Jedna nowa linia więcej nad tą funkcją
PEP 8: E302 expected 2 blank lines, found 1

Jedna nowa linia więcej nad tą funkcją `PEP 8: E302 expected 2 blank lines, found 1`
image_path = Path(input_dir)
file_names = os.listdir(image_path)
categories_name = []
categories_count=[]
Review

categories_count = []

`categories_count = []`
count = 0
n = file_names[0]
for name in file_names:
if name != n:
categories_count.append(count)
n = name
count = 1
else:
count += 1
if not name in categories_name:
categories_name.append(name)
categories_count.append(count)
test_img = []
labels=[]
Review

labels = []

`labels = []`
for n in file_names:
p = image_path / n
img = imread(p) # zwraca ndarry postaci xSize x ySize x colorDepth
img = cv.resize(img, newSize, interpolation=cv.INTER_AREA) # zwraca ndarray
img = img / 255 # type: ignore #normalizacja
test_img.append(img)
labels.append(n)
X={}
Review

Hm, nie lepiej byłoby żeby ta struktura wyglądała w ten sposób?

[
	{
    	"name": "plik.jpg"
        "values": <np.ndarray>
    },
    ...
]
Hm, nie lepiej byłoby żeby ta struktura wyglądała w ten sposób? ```json [ { "name": "plik.jpg" "values": <np.ndarray> }, ... ] ```
X["values"] = np.array(test_img)
X["categories_name"] = categories_name
X["categories_count"] = categories_count
X["labels"]=labels
return X
data = load_data('test_set')
print(data['categories_name'])
print(data['categories_count'])
print(data['labels'])

To wszystko trzeba wyrzucić, bo przy imporcie będzie się to wszystko wykonywało niepotrzebnie

To wszystko trzeba wyrzucić, bo przy imporcie będzie się to wszystko wykonywało niepotrzebnie
print(list(data["values"]))