diff --git a/build/lib/gradio/interface.py b/build/lib/gradio/interface.py
index 4a06b54fc9..4e625bd903 100644
--- a/build/lib/gradio/interface.py
+++ b/build/lib/gradio/interface.py
@@ -58,6 +58,9 @@ class Interface:
self.output_interfaces = [get_output_instance(i) for i in outputs]
else:
self.output_interfaces = [get_output_instance(outputs)]
+ if not isinstance(fn, list):
+ fn = [fn]
+ self.output_interfaces *= len(fn)
self.predict = fn
self.verbose = verbose
self.status = "OFF"
@@ -71,6 +74,7 @@ class Interface:
config = {
"input_interfaces": [iface.__class__.__name__.lower() for iface in self.input_interfaces],
"output_interfaces": [iface.__class__.__name__.lower() for iface in self.output_interfaces],
+ "function_count": len(self.predict),
"live": self.live,
"show_input": self.show_input,
"show_output": self.show_output,
diff --git a/build/lib/gradio/networking.py b/build/lib/gradio/networking.py
index b6f3353d5d..c833c957ba 100644
--- a/build/lib/gradio/networking.py
+++ b/build/lib/gradio/networking.py
@@ -137,10 +137,14 @@ def serve_files_in_background(interface, port, directory_to_serve=None):
msg = json.loads(data_string)
raw_input = msg["data"]
processed_input = [input_interface.preprocess(raw_input[i]) for i, input_interface in enumerate(interface.input_interfaces)]
- prediction = interface.predict(*processed_input)
- if len(interface.input_interfaces) == 1:
- prediction = [prediction]
- processed_output = [output_interface.postprocess(prediction[i]) for i, output_interface in enumerate(interface.output_interfaces)]
+ predictions = []
+ for predict_fn in interface.predict:
+ prediction = predict_fn(*processed_input)
+ if len(interface.output_interfaces) == 1:
+ prediction = [prediction]
+ predictions.extend(prediction)
+ print(predictions)
+ processed_output = [output_interface.postprocess(predictions[i]) for i, output_interface in enumerate(interface.output_interfaces)]
output = {"action": "output", "data": processed_output}
if interface.saliency is not None:
import numpy as np
diff --git a/build/lib/gradio/static/css/gradio.css b/build/lib/gradio/static/css/gradio.css
index 64119993f2..872608f9f9 100644
--- a/build/lib/gradio/static/css/gradio.css
+++ b/build/lib/gradio/static/css/gradio.css
@@ -12,15 +12,17 @@
text-transform: uppercase;
font-family: Arial;
color: #888;
- padding: 6px;
+ padding: 6px 6px 0;
font-size: 14px;
font-weight: bold;
display: flex;
}
+.input_interfaces, .output_interfaces {
+ margin-bottom: 16px;
+}
.interface {
height: 360px;
- margin-bottom: 16px;
- padding: 0 6px 6px;
+ padding: 8px;
display: flex;
flex-flow: column;
}
@@ -33,6 +35,10 @@
}
.panel_buttons {
display: flex;
+ margin-left: -8px;
+}
+.panel_buttons > * {
+ margin-left: 8px;
}
.submit {
display: none;
@@ -58,9 +64,6 @@
padding: 8px !important;
background-color: #EEEEEE !important;
}
-.clear, .flag {
- margin-left: 8px;
-}
.upload_zone {
font-weight: bold;
diff --git a/build/lib/gradio/static/js/load_interfaces.js b/build/lib/gradio/static/js/load_interfaces.js
index 66e04e8df7..181fba8818 100644
--- a/build/lib/gradio/static/js/load_interfaces.js
+++ b/build/lib/gradio/static/js/load_interfaces.js
@@ -41,6 +41,9 @@ $.getJSON("static/config.json", function(data) {
_id++;
}
for (let i = 0; i < config["output_interfaces"].length; i++) {
+ if (i != 0 && i % (config["output_interfaces"].length / config.function_count) == 0) {
+ $(".output_interfaces").append("
");
+ }
output_interface = Object.create(output_to_object_map[
config["output_interfaces"][i]]);
$(".output_interfaces").append(`
diff --git a/demo/flip_image.py b/demo/flip_image.py
index fc0beae0d8..78a0a7d669 100644
--- a/demo/flip_image.py
+++ b/demo/flip_image.py
@@ -1,7 +1,14 @@
import gradio as gr
import numpy as np
+from time import time
def flip(image):
- return np.flipud(image)
+ start = time()
+ return np.flipud(image), time() - start
-gr.Interface(flip, "imagein", "image").launch()
\ No newline at end of file
+def flip2(image):
+ start = time()
+ return np.fliplr(image), time() - start
+
+
+gr.Interface([flip, flip2], "imagein", ["image", "textbox"]).launch()
\ No newline at end of file
diff --git a/dist/gradio-0.9.0-py3.7.egg b/dist/gradio-0.9.0-py3.7.egg
index 9f0b99790a..c7cd522963 100644
Binary files a/dist/gradio-0.9.0-py3.7.egg and b/dist/gradio-0.9.0-py3.7.egg differ
diff --git a/gradio/interface.py b/gradio/interface.py
index 4a06b54fc9..4e625bd903 100644
--- a/gradio/interface.py
+++ b/gradio/interface.py
@@ -58,6 +58,9 @@ class Interface:
self.output_interfaces = [get_output_instance(i) for i in outputs]
else:
self.output_interfaces = [get_output_instance(outputs)]
+ if not isinstance(fn, list):
+ fn = [fn]
+ self.output_interfaces *= len(fn)
self.predict = fn
self.verbose = verbose
self.status = "OFF"
@@ -71,6 +74,7 @@ class Interface:
config = {
"input_interfaces": [iface.__class__.__name__.lower() for iface in self.input_interfaces],
"output_interfaces": [iface.__class__.__name__.lower() for iface in self.output_interfaces],
+ "function_count": len(self.predict),
"live": self.live,
"show_input": self.show_input,
"show_output": self.show_output,
diff --git a/gradio/networking.py b/gradio/networking.py
index b6f3353d5d..c833c957ba 100644
--- a/gradio/networking.py
+++ b/gradio/networking.py
@@ -137,10 +137,14 @@ def serve_files_in_background(interface, port, directory_to_serve=None):
msg = json.loads(data_string)
raw_input = msg["data"]
processed_input = [input_interface.preprocess(raw_input[i]) for i, input_interface in enumerate(interface.input_interfaces)]
- prediction = interface.predict(*processed_input)
- if len(interface.input_interfaces) == 1:
- prediction = [prediction]
- processed_output = [output_interface.postprocess(prediction[i]) for i, output_interface in enumerate(interface.output_interfaces)]
+ predictions = []
+ for predict_fn in interface.predict:
+ prediction = predict_fn(*processed_input)
+ if len(interface.output_interfaces) == 1:
+ prediction = [prediction]
+ predictions.extend(prediction)
+ print(predictions)
+ processed_output = [output_interface.postprocess(predictions[i]) for i, output_interface in enumerate(interface.output_interfaces)]
output = {"action": "output", "data": processed_output}
if interface.saliency is not None:
import numpy as np
diff --git a/gradio/static/css/gradio.css b/gradio/static/css/gradio.css
index 64119993f2..872608f9f9 100644
--- a/gradio/static/css/gradio.css
+++ b/gradio/static/css/gradio.css
@@ -12,15 +12,17 @@
text-transform: uppercase;
font-family: Arial;
color: #888;
- padding: 6px;
+ padding: 6px 6px 0;
font-size: 14px;
font-weight: bold;
display: flex;
}
+.input_interfaces, .output_interfaces {
+ margin-bottom: 16px;
+}
.interface {
height: 360px;
- margin-bottom: 16px;
- padding: 0 6px 6px;
+ padding: 8px;
display: flex;
flex-flow: column;
}
@@ -33,6 +35,10 @@
}
.panel_buttons {
display: flex;
+ margin-left: -8px;
+}
+.panel_buttons > * {
+ margin-left: 8px;
}
.submit {
display: none;
@@ -58,9 +64,6 @@
padding: 8px !important;
background-color: #EEEEEE !important;
}
-.clear, .flag {
- margin-left: 8px;
-}
.upload_zone {
font-weight: bold;
diff --git a/gradio/static/js/load_interfaces.js b/gradio/static/js/load_interfaces.js
index 66e04e8df7..181fba8818 100644
--- a/gradio/static/js/load_interfaces.js
+++ b/gradio/static/js/load_interfaces.js
@@ -41,6 +41,9 @@ $.getJSON("static/config.json", function(data) {
_id++;
}
for (let i = 0; i < config["output_interfaces"].length; i++) {
+ if (i != 0 && i % (config["output_interfaces"].length / config.function_count) == 0) {
+ $(".output_interfaces").append("
");
+ }
output_interface = Object.create(output_to_object_map[
config["output_interfaces"][i]]);
$(".output_interfaces").append(`