temporary remove threading

This commit is contained in:
Ali Abid 2020-12-10 14:31:16 -08:00
parent 256a8ad3a6
commit 3759124337
4 changed files with 13 additions and 7 deletions

View File

@ -645,7 +645,7 @@ class Image(InputComponent):
elif self.type == "numpy":
return np.array(im)
elif self.type == "file":
file_obj = tempfile.NamedTemporaryFile(suffix="."+fmt)
file_obj = tempfile.NamedTemporaryFile(suffix=("."+fmt.lower() if fmt is not None else ".png"))
im.save(file_obj.name)
return file_obj
else:

View File

@ -268,11 +268,13 @@ def start_server(interface, server_name, server_port=None):
log.setLevel(logging.ERROR)
if interface.save_to is not None:
interface.save_to["port"] = port
thread = threading.Thread(target=app.run,
kwargs={"port": port, "host": server_name},
daemon=True)
thread.start()
return port, app, thread
# thread = threading.Thread(target=app.run,
# kwargs={"port": port, "host": server_name},
# daemon=True)
# thread.start()
app.run(port=port, host=server_name)
return port, app, None
def close_server(process):
process.terminate()

View File

@ -170,6 +170,8 @@ class Image(OutputComponent):
dtype = "file"
elif isinstance(y, ModuleType):
dtype = "plot"
else:
raise ValueError("Unknown type. Please choose from: 'numpy', 'pil', 'file', 'plot'.")
else:
dtype = self.type
if dtype in ["numpy", "pil"]:

View File

@ -1,6 +1,6 @@
const image_output = {
html: `
<div class="interface_box">
<div class="view_holder_parent">
<div class="view_holders">
<div class="saliency_holder hide">
<canvas class="saliency"></canvas>
@ -15,6 +15,7 @@ const image_output = {
output: function(data) {
let io = this;
let [img_data, coord] = data;
this.target.find(".view_holder_parent").addClass("interface_box");
this.target.find(".output_image_holder").removeClass("hide");
img = this.target.find(".output_image").attr('src', img_data);
if (coord.length) {
@ -39,6 +40,7 @@ const image_output = {
}
},
clear: function() {
this.target.find(".view_holder_parent").removeClass("interface_box");
this.target.find(".output_image_holder").addClass("hide");
this.target.find(".saliency_holder").addClass("hide");
this.target.find(".output_image").attr('src', "")