Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -7,14 +7,14 @@ from tensorflow.keras.datasets import mnist
|
|
7 |
import cv2
|
8 |
|
9 |
# I/O image dimensions for display
|
10 |
-
DIMS = (100,100)
|
11 |
# Load the trained model
|
12 |
model = load_model('mnist_model.h5')
|
13 |
|
14 |
# Load MNIST examples
|
15 |
(x_train, y_train), (x_test, y_test) = mnist.load_data()
|
16 |
mnist_examples = [[x_test[i]] for i in range(10)] # Select first 10 examples and format as nested list
|
17 |
-
#
|
18 |
mnist_examples = [[cv2.resize(x_test[i], DIMS)] for i in range(10)]
|
19 |
|
20 |
# Function to preprocess the image
|
@@ -73,14 +73,7 @@ def gradio_mask(image, steps, increment):
|
|
73 |
|
74 |
class GradioInterface:
|
75 |
def __init__(self):
|
76 |
-
self.preloaded_examples =
|
77 |
-
|
78 |
-
def preload_examples(self):
|
79 |
-
preloaded = {}
|
80 |
-
for model_name, example_dir in Config.EXAMPLES.items():
|
81 |
-
examples = [os.path.join(example_dir, img) for img in os.listdir(example_dir)]
|
82 |
-
preloaded[model_name] = examples
|
83 |
-
return preloaded
|
84 |
|
85 |
def create_interface(self):
|
86 |
app_styles = """
|
|
|
7 |
import cv2
|
8 |
|
9 |
# I/O image dimensions for display
|
10 |
+
DIMS = (100, 100)
|
11 |
# Load the trained model
|
12 |
model = load_model('mnist_model.h5')
|
13 |
|
14 |
# Load MNIST examples
|
15 |
(x_train, y_train), (x_test, y_test) = mnist.load_data()
|
16 |
mnist_examples = [[x_test[i]] for i in range(10)] # Select first 10 examples and format as nested list
|
17 |
+
# Resize the examples to 100 by 100
|
18 |
mnist_examples = [[cv2.resize(x_test[i], DIMS)] for i in range(10)]
|
19 |
|
20 |
# Function to preprocess the image
|
|
|
73 |
|
74 |
class GradioInterface:
|
75 |
def __init__(self):
|
76 |
+
self.preloaded_examples = mnist_examples
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
|
78 |
def create_interface(self):
|
79 |
app_styles = """
|