mirror of
https://github.com/gradio-app/gradio.git
synced 2025-03-07 11:46:51 +08:00
updated to 0.9.4
This commit is contained in:
parent
a2276a19df
commit
18c489db55
@ -31,7 +31,7 @@ class Interface:
|
|||||||
def __init__(self, fn, inputs, outputs, saliency=None, verbose=False, examples=None,
|
def __init__(self, fn, inputs, outputs, saliency=None, verbose=False, examples=None,
|
||||||
live=False, show_input=True, show_output=True,
|
live=False, show_input=True, show_output=True,
|
||||||
load_fn=None, capture_session=False, title=None, description=None,
|
load_fn=None, capture_session=False, title=None, description=None,
|
||||||
server_name=LOCALHOST_IP):
|
thumbnail=None, server_name=LOCALHOST_IP):
|
||||||
"""
|
"""
|
||||||
:param fn: a function that will process the input panel data from the interface and return the output panel data.
|
:param fn: a function that will process the input panel data from the interface and return the output panel data.
|
||||||
:param inputs: a string or `AbstractInput` representing the input interface.
|
:param inputs: a string or `AbstractInput` representing the input interface.
|
||||||
@ -68,8 +68,6 @@ class Interface:
|
|||||||
fn = [fn]
|
fn = [fn]
|
||||||
self.output_interfaces *= len(fn)
|
self.output_interfaces *= len(fn)
|
||||||
self.predict = fn
|
self.predict = fn
|
||||||
self.load_fn = load_fn
|
|
||||||
self.context = None
|
|
||||||
self.verbose = verbose
|
self.verbose = verbose
|
||||||
self.status = "OFF"
|
self.status = "OFF"
|
||||||
self.saliency = saliency
|
self.saliency = saliency
|
||||||
@ -82,6 +80,7 @@ class Interface:
|
|||||||
self.server_name = server_name
|
self.server_name = server_name
|
||||||
self.title = title
|
self.title = title
|
||||||
self.description = description
|
self.description = description
|
||||||
|
self.thumbnail = thumbnail
|
||||||
self.examples = examples
|
self.examples = examples
|
||||||
|
|
||||||
def get_config_file(self):
|
def get_config_file(self):
|
||||||
@ -98,46 +97,34 @@ class Interface:
|
|||||||
"show_output": self.show_output,
|
"show_output": self.show_output,
|
||||||
"title": self.title,
|
"title": self.title,
|
||||||
"description": self.description,
|
"description": self.description,
|
||||||
|
"thumbnail": self.thumbnail
|
||||||
}
|
}
|
||||||
|
|
||||||
def process(self, raw_input):
|
def process(self, raw_input):
|
||||||
processed_input = [input_interface.preprocess(
|
processed_input = [input_interface.preprocess(
|
||||||
raw_input[i]) for i, input_interface in enumerate(self.input_interfaces)]
|
raw_input[i]) for i, input_interface in
|
||||||
|
enumerate(self.input_interfaces)]
|
||||||
predictions = []
|
predictions = []
|
||||||
for predict_fn in self.predict:
|
for predict_fn in self.predict:
|
||||||
if self.context:
|
if self.capture_session:
|
||||||
if self.capture_session:
|
graph, sess = self.session
|
||||||
graph, sess = self.session
|
with graph.as_default():
|
||||||
with graph.as_default():
|
with sess.as_default():
|
||||||
with sess.as_default():
|
prediction = predict_fn(*processed_input)
|
||||||
prediction = predict_fn(*processed_input,
|
|
||||||
self.context)
|
|
||||||
else:
|
|
||||||
try:
|
|
||||||
prediction = predict_fn(*processed_input, self.context)
|
|
||||||
except ValueError:
|
|
||||||
print("It looks like you might be "
|
|
||||||
"using tensorflow < 2.0. Please pass "
|
|
||||||
"capture_session=True in Interface to avoid "
|
|
||||||
"a 'Tensor is not an element of this graph.' "
|
|
||||||
"error.")
|
|
||||||
prediction = predict_fn(*processed_input, self.context)
|
|
||||||
else:
|
else:
|
||||||
if self.capture_session:
|
try:
|
||||||
graph, sess = self.session
|
prediction = predict_fn(*processed_input)
|
||||||
with graph.as_default():
|
except ValueError as exception:
|
||||||
with sess.as_default():
|
if str(exception).endswith("is not an element of this "
|
||||||
prediction = predict_fn(*processed_input)
|
"graph."):
|
||||||
else:
|
raise ValueError("It looks like you might be using "
|
||||||
try:
|
"tensorflow < 2.0. Please "
|
||||||
prediction = predict_fn(*processed_input)
|
"pass capture_session=True in "
|
||||||
except ValueError:
|
"Interface to avoid the 'Tensor is "
|
||||||
print("It looks like you might be "
|
"not an element of this graph.' "
|
||||||
"using tensorflow < 2.0. Please pass "
|
"error.")
|
||||||
"capture_session=True in Interface to avoid "
|
else:
|
||||||
"a 'Tensor is not an element of this graph.' "
|
raise exception
|
||||||
"error.")
|
|
||||||
prediction = predict_fn(*processed_input)
|
|
||||||
|
|
||||||
if len(self.output_interfaces) / \
|
if len(self.output_interfaces) / \
|
||||||
len(self.predict) == 1:
|
len(self.predict) == 1:
|
||||||
@ -209,8 +196,6 @@ class Interface:
|
|||||||
"""
|
"""
|
||||||
# if validate and not self.validate_flag:
|
# if validate and not self.validate_flag:
|
||||||
# self.validate()
|
# self.validate()
|
||||||
context = self.load_fn() if self.load_fn else None
|
|
||||||
self.context = context
|
|
||||||
|
|
||||||
if self.capture_session:
|
if self.capture_session:
|
||||||
import tensorflow as tf
|
import tensorflow as tf
|
||||||
|
Binary file not shown.
BIN
dist/gradio-0.9.4.tar.gz
vendored
Normal file
BIN
dist/gradio-0.9.4.tar.gz
vendored
Normal file
Binary file not shown.
@ -1,6 +1,6 @@
|
|||||||
Metadata-Version: 1.0
|
Metadata-Version: 1.0
|
||||||
Name: gradio
|
Name: gradio
|
||||||
Version: 0.9.3
|
Version: 0.9.4
|
||||||
Summary: Python library for easily interacting with trained machine learning models
|
Summary: Python library for easily interacting with trained machine learning models
|
||||||
Home-page: https://github.com/abidlabs/gradio
|
Home-page: https://github.com/abidlabs/gradio
|
||||||
Author: Abubakar Abid
|
Author: Abubakar Abid
|
||||||
|
@ -2,7 +2,6 @@ MANIFEST.in
|
|||||||
README.md
|
README.md
|
||||||
setup.py
|
setup.py
|
||||||
gradio/__init__.py
|
gradio/__init__.py
|
||||||
gradio/hosted.py
|
|
||||||
gradio/inputs.py
|
gradio/inputs.py
|
||||||
gradio/interface.py
|
gradio/interface.py
|
||||||
gradio/networking.py
|
gradio/networking.py
|
||||||
|
Loading…
Reference in New Issue
Block a user