mirror of
https://github.com/gradio-app/gradio.git
synced 2025-01-06 10:25:17 +08:00
removed validate
This commit is contained in:
parent
480591ad2b
commit
7595e1e41b
@ -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
|
||||
|
@ -15,7 +15,7 @@ import numpy as np
|
||||
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'
|
||||
@ -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
|
||||
@ -258,9 +251,6 @@ class Image(AbstractInput):
|
||||
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 {
|
||||
@ -384,9 +374,6 @@ class Webcam(AbstractInput):
|
||||
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 {
|
||||
|
@ -209,82 +209,16 @@ class Interface:
|
||||
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.
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user