Skip to content

Commit

Permalink
removed validate
Browse files Browse the repository at this point in the history
  • Loading branch information
aliabd committed Aug 3, 2020
1 parent 480591a commit 7595e1e
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 98 deletions.
1 change: 0 additions & 1 deletion gradio.egg-info/SOURCES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ gradio/outputs.py
gradio/preprocessing_utils.py
gradio/strings.py
gradio/tunneling.py
gradio/validation_data.py
gradio.egg-info/PKG-INFO
gradio.egg-info/SOURCES.txt
gradio.egg-info/dependency_links.txt
Expand Down
15 changes: 1 addition & 14 deletions gradio/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import PIL.Image
import PIL.ImageOps
import scipy.io.wavfile
from gradio import preprocessing_utils, validation_data
from gradio import preprocessing_utils

# Where to find the static resources associated with each template.
# BASE_INPUT_INTERFACE_TEMPLATE_PATH = 'static/js/interfaces/input/{}.js'
Expand All @@ -31,13 +31,6 @@ class AbstractInput(ABC):
def __init__(self, label):
self.label = label

def get_validation_inputs(self):
"""
An interface can optionally implement a method that returns a list of examples inputs that it should be able to
accept and preprocess for validation purposes.
"""
return []

def get_template_context(self):
"""
:return: a dictionary with context variables for the javascript file associated with the context
Expand Down Expand Up @@ -258,9 +251,6 @@ def __init__(self, shape=None, image_mode='RGB', label=None):
self.image_mode = image_mode
super().__init__(label)

def get_validation_inputs(self):
return validation_data.BASE64_COLOR_IMAGES

@classmethod
def get_shortcut_implementations(cls):
return {
Expand Down Expand Up @@ -384,9 +374,6 @@ def __init__(self, shape=(224, 224), label=None):
self.num_channels = 3
super().__init__(label)

def get_validation_inputs(self):
return validation_data.BASE64_COLOR_IMAGES

@classmethod
def get_shortcut_implementations(cls):
return {
Expand Down
68 changes: 1 addition & 67 deletions gradio/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,82 +209,16 @@ def process(self, raw_input):
predictions[i]) for i, output_interface in enumerate(self.output_interfaces)]
return processed_output, durations

def validate(self):
if self.validate_flag:
if self.verbose:
print("Interface already validated")
return
validation_inputs = self.input_interface.get_validation_inputs()
n = len(validation_inputs)
if n == 0:
self.validate_flag = True
if self.verbose:
print(
"No validation samples for this interface... skipping validation."
)
return
for m, msg in enumerate(validation_inputs):
if self.verbose:
print(
"Validating samples: {}/{} [".format(m+1, n)
+ "=" * (m + 1)
+ "." * (n - m - 1)
+ "]",
end="\r",
)
try:
processed_input = self.input_interface.preprocess(msg)
prediction = self.predict(processed_input)
except Exception as e:
data = {'error': e}
try:
requests.post(analytics_url + 'gradio-error-analytics/',
data=data)
except requests.ConnectionError:
pass # do not push analytics if no network
if self.verbose:
print("\n----------")
print(
"Validation failed, likely due to incompatible pre-processing and model input. See below:\n"
)
print(traceback.format_exc())
break
try:
_ = self.output_interface.postprocess(prediction)
except Exception as e:
data = {'error': e}
try:
requests.post(analytics_url + 'gradio-error-analytics/',
data=data)
except requests.ConnectionError:
pass # do not push analytics if no network
if self.verbose:
print("\n----------")
print(
"Validation failed, likely due to incompatible model output and post-processing."
"See below:\n"
)
print(traceback.format_exc())
break
else: # This means if a break was not explicitly called
self.validate_flag = True
if self.verbose:
print("\n\nValidation passed successfully!")
return
raise RuntimeError("Validation did not pass")

def close(self):
if self.simple_server and not(self.simple_server.fileno() == -1): # checks to see if server is running
print("Closing Gradio server on port {}...".format(self.server_port))
networking.close_server(self.simple_server)

def launch(self, inline=None, inbrowser=None, share=False, validate=True, debug=False):
def launch(self, inline=None, inbrowser=None, share=False, debug=False):
"""
Parameters
share (bool): whether to create a publicly shareable link from your computer for the interface.
"""
# if validate and not self.validate_flag:
# self.validate()

output_directory = tempfile.mkdtemp()
# Set up a port to serve the directory containing the static files with interface.
Expand Down
16 changes: 0 additions & 16 deletions gradio/validation_data.py

This file was deleted.

0 comments on commit 7595e1e

Please sign in to comment.