Spaces:
Runtime error
Runtime error
change the test images from test set, forct K to int
Browse files
app.py
CHANGED
@@ -35,11 +35,11 @@ import os
|
|
35 |
def get_sample_images(num_images):
|
36 |
sample_images = []
|
37 |
for i in range(num_images):
|
38 |
-
|
39 |
-
|
40 |
|
41 |
# Make it unsigned integers:
|
42 |
-
data =
|
43 |
|
44 |
outdir = "images_folder"
|
45 |
img_path = os.path.join(outdir, 'local_%05d.png' % (i,))
|
@@ -47,7 +47,7 @@ def get_sample_images(num_images):
|
|
47 |
os.mkdir(outdir)
|
48 |
cv2.imwrite(img_path, data)
|
49 |
|
50 |
-
sample_images.append([img_path,int(np.random.choice([7,9,11,13]))]) # ["image path", "K"]
|
51 |
return sample_images
|
52 |
|
53 |
# EXTRA: adapted from https://github.com/ageron/handson-ml2/blob/master/03_classification.ipynb
|
|
|
35 |
def get_sample_images(num_images):
|
36 |
sample_images = []
|
37 |
for i in range(num_images):
|
38 |
+
test_feature = X_test[i]
|
39 |
+
test_feature_2d =test_feature.reshape(28,28)
|
40 |
|
41 |
# Make it unsigned integers:
|
42 |
+
data = test_feature_2d.astype(np.uint8)
|
43 |
|
44 |
outdir = "images_folder"
|
45 |
img_path = os.path.join(outdir, 'local_%05d.png' % (i,))
|
|
|
47 |
os.mkdir(outdir)
|
48 |
cv2.imwrite(img_path, data)
|
49 |
|
50 |
+
sample_images.append([img_path,int(np.random.choice([7,9,11,13,15,24]))]) # ["image path", "K"]
|
51 |
return sample_images
|
52 |
|
53 |
# EXTRA: adapted from https://github.com/ageron/handson-ml2/blob/master/03_classification.ipynb
|