Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,39 +1,7 @@
|
|
1 |
-
import numpy as np
|
2 |
-
import matplotlib.pyplot as plt
|
3 |
-
from tensorflow.keras.datasets import mnist
|
4 |
-
from tensorflow import keras
|
5 |
-
import keras.backend as K
|
6 |
-
from tensorflow.keras.layers import Dense, Flatten, Reshape, Input, Lambda, BatchNormalization, Dropout
|
7 |
-
|
8 |
-
(x_train, y_train), (x_test, y_test) = mnist.load_data()
|
9 |
-
|
10 |
-
x_train = x_train / 255
|
11 |
-
x_test = x_test / 255
|
12 |
-
|
13 |
-
y_train = keras.utils.to_categorical(y_train, 10)
|
14 |
-
|
15 |
-
input_img = Input((28, 28))
|
16 |
-
x = Flatten()(input_img)
|
17 |
-
x = Dense(256, activation='relu')(x)
|
18 |
-
x = Dense(128, activation='relu')(x)
|
19 |
-
x = Dense(64, activation='relu')(x)
|
20 |
-
Classif = Dense(10, activation='softmax')(x)
|
21 |
-
|
22 |
-
model = keras.Model(input_img, Classif)
|
23 |
-
|
24 |
-
model.compile(optimizer='adam', loss='categorical_crossentropy')
|
25 |
-
|
26 |
-
model.fit(x_train, y_train, epochs=5, batch_size=30, shuffle=True)
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
import gradio as gr
|
32 |
import numpy as np
|
33 |
|
34 |
-
|
35 |
-
|
36 |
-
model = from_pretrained_keras("ISYS/MyNewModel")
|
37 |
|
38 |
def greet(img):
|
39 |
img = np.expand_dims(img, axis=0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
import numpy as np
|
3 |
|
4 |
+
model = keras.models.load_model('my_model')
|
|
|
|
|
5 |
|
6 |
def greet(img):
|
7 |
img = np.expand_dims(img, axis=0)
|