mirror of
https://github.com/gradio-app/gradio.git
synced 2024-12-21 02:19:59 +08:00
4.6 KiB
4.6 KiB
In [ ]:
import tensorflow as tf import gradio
In [ ]:
(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
In [3]:
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'])
In [4]:
model.fit(x_train, y_train, epochs=1)
Epoch 1/1 60000/60000 [==============================] - 24s 407us/step - loss: 0.2171 - acc: 0.9355
Out[4]:
<tensorflow.python.keras.callbacks.History at 0x23bf7b1ae10>
In [5]:
iface = gradio.Interface(inputs="sketchpad", outputs="label", model=model, model_type='keras')
In [6]:
iface.launch(inline=True, share=False)
No validation samples for this interface... skipping validation. NOTE: Gradio is in beta stage, please report all bugs to: contact.gradio@gmail.com Model is running locally at: http://localhost:7860/ To create a public link, set `share=True` in the argument to `launch()`
Out[6]:
(<gradio.networking.serve_files_in_background.<locals>.HTTPServer at 0x23bf9174b70>, 'http://localhost:7860/', None)
Error in connection handler Traceback (most recent call last): File "C:\Users\islam\Anaconda3\envs\tensorflow\lib\site-packages\websockets\server.py", line 169, in handler yield from self.ws_handler(self, path) File "C:\Users\islam\Repos\gradio\gradio\interface.py", line 114, in communicate msg = json.loads(await websocket.recv()) File "C:\Users\islam\Anaconda3\envs\tensorflow\lib\json\__init__.py", line 354, in loads return _default_decoder.decode(s) File "C:\Users\islam\Anaconda3\envs\tensorflow\lib\json\decoder.py", line 339, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "C:\Users\islam\Anaconda3\envs\tensorflow\lib\json\decoder.py", line 357, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)