Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
model = Sequential()
layer_1_size = 10
epochs = 3
model.add(Conv2D(10, (5, 5), input_shape=(img_width, img_height, 1), activation="relu"))
model.add(MaxPooling2D(pool_size=(2, 2)))
# model.add(Conv2D(config.layer_2_size, (5, 5), input_shape=(img_width, img_height,1), activation='relu'))
# model.add(MaxPooling2D(pool_size=(2, 2)))
# model.add(Dropout(0.2))
model.add(Flatten())
model.add(Dense(8, activation="relu"))
model.add(Dense(num_classes, activation="softmax"))
model.compile(loss="categorical_crossentropy", optimizer=sgd, metrics=["accuracy"])
show_terminal_output = not config.get_option("server.liveSave")
model.fit(
x_train,
y_train,
validation_data=(x_test, y_test),
epochs=epochs,
verbose=show_terminal_output,
callbacks=[MyCallback(x_test)],
)
st.success("Finished training!")
def _print_url():
title_message = "You can now view your Streamlit app in your browser."
named_urls = []
if config.is_manually_set("browser.serverAddress"):
named_urls = [
("URL", Report.get_url(config.get_option("browser.serverAddress")))
]
elif config.get_option("server.headless"):
named_urls = [
("Network URL", Report.get_url(net_util.get_internal_ip())),
("External URL", Report.get_url(net_util.get_external_ip())),
]
else:
named_urls = [
("Local URL", Report.get_url("localhost")),
("Network URL", Report.get_url(net_util.get_internal_ip())),
]
click.secho("")
click.secho(" %s" % title_message, fg="blue", bold=True)
def _save_final_report(self, progress_coroutine=None):
files = self._report.serialize_final_report_to_files()
url = yield self._get_storage().save_report_files(
self._report.report_id, files, progress_coroutine
)
if config.get_option("server.liveSave"):
url_util.print_url("Saved final app", url)
raise tornado.gen.Return(url)
return
self._sent_initialize_message = True
msg = ForwardMsg()
imsg = msg.initialize
imsg.config.sharing_enabled = config.get_option("global.sharingMode") != "off"
imsg.config.gather_usage_stats = config.get_option("browser.gatherUsageStats")
imsg.config.max_cached_message_age = config.get_option(
"global.maxCachedMessageAge"
)
imsg.config.mapbox_token = config.get_option("mapbox.token")
LOGGER.debug(
"New browser connection: "
"gather_usage_stats=%s, "
"sharing_enabled=%s, "
"max_cached_message_age=%s",
imsg.config.gather_usage_stats,
imsg.config.sharing_enabled,
imsg.config.max_cached_message_age,
)
imsg.environment_info.streamlit_version = __version__
imsg.environment_info.python_version = ".".join(map(str, sys.version_info))
imsg.session_state.run_on_save = self._run_on_save
imsg.session_state.report_is_running = (
self.name = name
# The number of the bytes in the hash.
self.size = 0
# An ever increasing counter.
self._counter = 0
if hasher:
self.hasher = hasher
else:
self.hasher = hashlib.new(name)
self._folder_black_list = FolderBlackList(
config.get_option("server.folderWatchBlacklist")
)
self.hash_funcs = hash_funcs or {}
Returns
-------
StaticManifest
A StaticManifest protobuf message
"""
manifest = StaticManifest()
manifest.name = self.name
manifest.server_status = status
if status == StaticManifest.RUNNING:
manifest.external_server_ip = external_server_ip
manifest.internal_server_ip = internal_server_ip
manifest.configured_server_address = config.get_option(
"browser.serverAddress"
)
# Don't use _get_browser_address_bar_port() here, since we want the
# websocket port, not the web server port. (These are the same in
# prod, but different in dev)
manifest.server_port = config.get_option("browser.serverPort")
manifest.server_base_path = config.get_option("server.baseUrlPath")
else:
manifest.num_messages = num_messages
return manifest
table = _with_dg(_DeltaGenerator.table) # noqa: E221
text = _with_dg(_DeltaGenerator.text) # noqa: E221
text_area = _with_dg(_DeltaGenerator.text_area) # noqa: E221
text_input = _with_dg(_DeltaGenerator.text_input) # noqa: E221
time_input = _with_dg(_DeltaGenerator.time_input) # noqa: E221
title = _with_dg(_DeltaGenerator.title) # noqa: E221
vega_lite_chart = _with_dg(_DeltaGenerator.vega_lite_chart) # noqa: E221
video = _with_dg(_DeltaGenerator.video) # noqa: E221
warning = _with_dg(_DeltaGenerator.warning) # noqa: E221
_native_chart = _with_dg(_DeltaGenerator._native_chart) # noqa: E221
_text_exception = _with_dg(_DeltaGenerator._text_exception) # noqa: E221
# Config
set_option = _config.set_option
get_option = _config.get_option
# Special methods:
_DATAFRAME_LIKE_TYPES = (
'DataFrame', # pandas.core.frame.DataFrame
'Index', # pandas.core.indexes.base.Index
'Series', # pandas.core.series.Series
'Styler', # pandas.io.formats.style.Styler
'ndarray', # numpy.ndarray
)
_HELP_TYPES = (
_types.BuiltinFunctionType,
_types.BuiltinMethodType,
_types.FunctionType,
_types.MethodType,
def _lauch_web_client(self, name):
"""Launches a web browser to connect to the proxy to get the named
report.
Args
----
name : string
The name of the report to which the web browser should connect.
"""
if config.get_option('proxy.useNode'):
host, port = 'localhost', '3000'
else:
host = config.get_option('proxy.server')
port = config.get_option('proxy.port')
quoted_name = urllib.parse.quote_plus(name)
url = f'http://{host}:{port}/?name={quoted_name}'
webbrowser.open(url)
def _allow_cross_origin_requests():
"""True if cross-origin requests are allowed.
We only allow cross-origin requests when using the Node server. This is
only needed when using the Node server anyway, since in that case we
have a dev port and the prod port, which count as two origins.
"""
return not config.get_option("server.enableCORS") or config.get_option(
"global.useNode"
)
def _launch_proxy(self):
"""Launch the proxy server."""
wait_for_proxy_secs = config.get_option('client.waitForProxySecs')
process_runner.run_python_module('streamlit.proxy')
LOGGER.debug(
'Sleeping %f seconds while waiting Proxy to start',
wait_for_proxy_secs)
yield gen.sleep(wait_for_proxy_secs)