mirror of
https://github.com/gradio-app/gradio.git
synced 2025-01-12 10:34:32 +08:00
Merge branch 'master' of https://github.com/gradio-app/gradio-UI
This commit is contained in:
commit
93de2b2411
@ -31,7 +31,7 @@ class Interface:
|
||||
def __init__(self, fn, inputs, outputs, saliency=None, verbose=False, examples=None,
|
||||
live=False, show_input=True, show_output=True,
|
||||
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 inputs: a string or `AbstractInput` representing the input interface.
|
||||
@ -68,8 +68,6 @@ class Interface:
|
||||
fn = [fn]
|
||||
self.output_interfaces *= len(fn)
|
||||
self.predict = fn
|
||||
self.load_fn = load_fn
|
||||
self.context = None
|
||||
self.verbose = verbose
|
||||
self.status = "OFF"
|
||||
self.saliency = saliency
|
||||
@ -82,6 +80,7 @@ class Interface:
|
||||
self.server_name = server_name
|
||||
self.title = title
|
||||
self.description = description
|
||||
self.thumbnail = thumbnail
|
||||
self.examples = examples
|
||||
|
||||
def get_config_file(self):
|
||||
@ -98,46 +97,34 @@ class Interface:
|
||||
"show_output": self.show_output,
|
||||
"title": self.title,
|
||||
"description": self.description,
|
||||
"thumbnail": self.thumbnail
|
||||
}
|
||||
|
||||
def process(self, raw_input):
|
||||
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 = []
|
||||
for predict_fn in self.predict:
|
||||
if self.context:
|
||||
if self.capture_session:
|
||||
graph, sess = self.session
|
||||
with graph.as_default():
|
||||
with sess.as_default():
|
||||
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)
|
||||
if self.capture_session:
|
||||
graph, sess = self.session
|
||||
with graph.as_default():
|
||||
with sess.as_default():
|
||||
prediction = predict_fn(*processed_input)
|
||||
else:
|
||||
if self.capture_session:
|
||||
graph, sess = self.session
|
||||
with graph.as_default():
|
||||
with sess.as_default():
|
||||
prediction = predict_fn(*processed_input)
|
||||
else:
|
||||
try:
|
||||
prediction = predict_fn(*processed_input)
|
||||
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)
|
||||
try:
|
||||
prediction = predict_fn(*processed_input)
|
||||
except ValueError as exception:
|
||||
if str(exception).endswith("is not an element of this "
|
||||
"graph."):
|
||||
raise ValueError("It looks like you might be using "
|
||||
"tensorflow < 2.0. Please "
|
||||
"pass capture_session=True in "
|
||||
"Interface to avoid the 'Tensor is "
|
||||
"not an element of this graph.' "
|
||||
"error.")
|
||||
else:
|
||||
raise exception
|
||||
|
||||
if len(self.output_interfaces) / \
|
||||
len(self.predict) == 1:
|
||||
@ -209,8 +196,6 @@ class Interface:
|
||||
"""
|
||||
# if validate and not self.validate_flag:
|
||||
# self.validate()
|
||||
context = self.load_fn() if self.load_fn else None
|
||||
self.context = context
|
||||
|
||||
if self.capture_session:
|
||||
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
|
||||
Name: gradio
|
||||
Version: 0.9.3
|
||||
Version: 0.9.4
|
||||
Summary: Python library for easily interacting with trained machine learning models
|
||||
Home-page: https://github.com/abidlabs/gradio
|
||||
Author: Abubakar Abid
|
||||
|
@ -2,7 +2,6 @@ MANIFEST.in
|
||||
README.md
|
||||
setup.py
|
||||
gradio/__init__.py
|
||||
gradio/hosted.py
|
||||
gradio/inputs.py
|
||||
gradio/interface.py
|
||||
gradio/networking.py
|
||||
|
@ -29,8 +29,9 @@ class Interface:
|
||||
"""
|
||||
|
||||
def __init__(self, fn, inputs, outputs, saliency=None, verbose=False, examples=None,
|
||||
live=False, show_input=True, show_output=True, capture_session=False, title=None, description=None,
|
||||
server_name=LOCALHOST_IP):
|
||||
live=False, show_input=True, show_output=True,
|
||||
load_fn=None, capture_session=False, title=None, description=None,
|
||||
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 inputs: a string or `AbstractInput` representing the input interface.
|
||||
@ -79,6 +80,7 @@ class Interface:
|
||||
self.server_name = server_name
|
||||
self.title = title
|
||||
self.description = description
|
||||
self.thumbnail = thumbnail
|
||||
self.examples = examples
|
||||
|
||||
def get_config_file(self):
|
||||
@ -95,6 +97,7 @@ class Interface:
|
||||
"show_output": self.show_output,
|
||||
"title": self.title,
|
||||
"description": self.description,
|
||||
"thumbnail": self.thumbnail
|
||||
}
|
||||
|
||||
def process(self, raw_input):
|
||||
|
2
setup.py
2
setup.py
@ -5,7 +5,7 @@ except ImportError:
|
||||
|
||||
setup(
|
||||
name='gradio',
|
||||
version='0.9.3',
|
||||
version='0.9.4',
|
||||
include_package_data=True,
|
||||
description='Python library for easily interacting with trained machine learning models',
|
||||
author='Abubakar Abid',
|
||||
|
34
size.sh
34
size.sh
@ -1,34 +0,0 @@
|
||||
#!/bin/bash
|
||||
#set -x
|
||||
|
||||
# Shows you the largest objects in your repo's pack file.
|
||||
# Written for osx.
|
||||
#
|
||||
# @see https://stubbisms.wordpress.com/2009/07/10/git-script-to-show-largest-pack-objects-and-trim-your-waist-line/
|
||||
# @author Antony Stubbs
|
||||
|
||||
# set the internal field separator to line break, so that we can iterate easily over the verify-pack output
|
||||
IFS=$'\n';
|
||||
|
||||
# list all objects including their size, sort by size, take top 10
|
||||
objects=`git verify-pack -v .git/objects/pack/pack-*.idx | grep -v chain | sort -k3nr | head`
|
||||
|
||||
echo "All sizes are in kB's. The pack column is the size of the object, compressed, inside the pack file."
|
||||
|
||||
output="size,pack,SHA,location"
|
||||
allObjects=`git rev-list --all --objects`
|
||||
for y in $objects
|
||||
do
|
||||
# extract the size in bytes
|
||||
size=$((`echo $y | cut -f 5 -d ' '`/1024))
|
||||
# extract the compressed size in bytes
|
||||
compressedSize=$((`echo $y | cut -f 6 -d ' '`/1024))
|
||||
# extract the SHA
|
||||
sha=`echo $y | cut -f 1 -d ' '`
|
||||
# find the objects location in the repository tree
|
||||
other=`echo "${allObjects}" | grep $sha`
|
||||
#lineBreak=`echo -e "\n"`
|
||||
output="${output}\n${size},${compressedSize},${other}"
|
||||
done
|
||||
|
||||
echo -e $output | column -t -s ', '
|
Loading…
Reference in New Issue
Block a user