diff --git a/gradio/interface.py b/gradio/interface.py index ba0cda8667..4bcb2a009b 100644 --- a/gradio/interface.py +++ b/gradio/interface.py @@ -107,8 +107,16 @@ class Interface: 'host_name': hostname, 'ip_address': ip_address } + + if self.capture_session: + try: + import tensorflow as tf + self.session = tf.get_default_graph(), \ + tf.keras.backend.get_session() + except (ImportError, AttributeError): # If they are using TF >= 2.0 or don't have TF, just ignore this. + pass + try: - print("try initiated") requests.post(analytics_url + 'gradio-initiated-analytics/', data=data) except requests.ConnectionError: @@ -144,7 +152,6 @@ class Interface: return config - def process(self, raw_input): processed_input = [input_interface.preprocess( raw_input[i]) for i, input_interface in @@ -262,14 +269,6 @@ class Interface: # if validate and not self.validate_flag: # self.validate() - if self.capture_session: - try: - import tensorflow as tf - self.session = tf.get_default_graph(), \ - tf.keras.backend.get_session() - except (ImportError, AttributeError): # If they are using TF >= 2.0 or don't have TF, just ignore this. - pass - output_directory = tempfile.mkdtemp() # Set up a port to serve the directory containing the static files with interface. server_port, httpd = networking.start_simple_server(self, output_directory, self.server_name)