mirror of
https://github.com/gradio-app/gradio.git
synced 2025-03-01 11:45:36 +08:00
fix unit test, remove h5 files
This commit is contained in:
parent
5f24b6cb54
commit
afa1944570
@ -22,9 +22,7 @@ def encode_array_to_base64(image_array):
|
||||
PIL_image = Image.fromarray(skimage.img_as_ubyte(image_array))
|
||||
PIL_image.save(output_bytes, 'PNG')
|
||||
bytes_data = output_bytes.getvalue()
|
||||
|
||||
base64_str = str(base64.b64encode(bytes_data), 'utf-8')
|
||||
|
||||
return "data:image/png;base64," + base64_str
|
||||
|
||||
|
||||
|
@ -2,30 +2,20 @@ import tensorflow as tf
|
||||
import gradio
|
||||
|
||||
|
||||
#CREATE INTERFACE USING 'GOOD' MNIST MODEL
|
||||
(x_train, y_train),(x_test, y_test) = tf.keras.datasets.mnist.load_data()
|
||||
model = tf.keras.models.load_model('MNIST_9344.h5')
|
||||
input = gradio.inputs.Sketchpad(sample_inputs=x_train[:10])
|
||||
iface = gradio.Interface(inputs=input, outputs="label", model=model, model_type='keras')
|
||||
iface.launch(inline=False, share=False, inbrowser=True);
|
||||
x_train, x_test = x_train / 255.0, x_test / 255.0
|
||||
|
||||
model = tf.keras.models.Sequential([
|
||||
tf.keras.layers.Flatten(),
|
||||
tf.keras.layers.Dense(512, activation=tf.nn.relu),
|
||||
tf.keras.layers.Dropout(0.2),
|
||||
tf.keras.layers.Dense(10, activation=tf.nn.softmax)
|
||||
])
|
||||
|
||||
#CREATE INTERFACE BY TRAINING MSNIST MODEL
|
||||
|
||||
# (x_train, y_train),(x_test, y_test) = tf.keras.datasets.mnist.load_data()
|
||||
# x_train, x_test = x_train / 255.0, x_test / 255.0
|
||||
#
|
||||
# model = tf.keras.models.Sequential([
|
||||
# tf.keras.layers.Flatten(),
|
||||
# tf.keras.layers.Dense(512, activation=tf.nn.relu),
|
||||
# tf.keras.layers.Dropout(0.2),
|
||||
# tf.keras.layers.Dense(10, activation=tf.nn.softmax)
|
||||
# ])
|
||||
#
|
||||
# model.compile(optimizer='adam',
|
||||
# loss='sparse_categorical_crossentropy',
|
||||
# metrics=['accuracy'])
|
||||
# model.fit(x_train, y_train, epochs=1)
|
||||
# inp = gradio.inputs.Sketchpad(sample_inputs=x_train[:10])
|
||||
# iface = gradio.Interface(inputs=inp, outputs="label", model=model, model_type='keras')
|
||||
# iface.launch(inline=False, share=False, inbrowser=True);
|
||||
model.compile(optimizer='adam',
|
||||
loss='sparse_categorical_crossentropy',
|
||||
metrics=['accuracy'])
|
||||
model.fit(x_train, y_train, epochs=1)
|
||||
inp = gradio.inputs.Sketchpad(sample_inputs=x_train[:10])
|
||||
iface = gradio.Interface(inputs=inp, outputs="label", model=model, model_type='keras')
|
||||
iface.launch(inline=False, share=False, inbrowser=True);
|
@ -41,7 +41,7 @@ class TestSetSampleData(unittest.TestCase):
|
||||
config_file = os.path.join(temp_dir, 'static/config.json')
|
||||
with open(config_file) as json_file:
|
||||
data = json.load(json_file)
|
||||
self.assertFalse(test_array == data["sample_inputs"])
|
||||
self.assertTrue(test_array == data["sample_inputs"])
|
||||
|
||||
# class TestCopyFiles(unittest.TestCase):
|
||||
# def test_copy_files(self):
|
||||
|
Loading…
Reference in New Issue
Block a user