mirror of
https://github.com/gradio-app/gradio.git
synced 2025-02-05 11:10:03 +08:00
added disabled, always_flagged in config
This commit is contained in:
parent
5159d31898
commit
a3b05b25a2
@ -47,7 +47,8 @@ class Interface:
|
||||
postprocessing_fns=None,
|
||||
verbose=True,
|
||||
saliency=None,
|
||||
always_flag=False
|
||||
always_flag=False,
|
||||
interactivity_disabled=False,
|
||||
):
|
||||
"""
|
||||
:param inputs: a string or `AbstractInput` representing the input interface.
|
||||
@ -101,6 +102,7 @@ class Interface:
|
||||
self.hash = random.getrandbits(32)
|
||||
self.saliency = saliency
|
||||
self.always_flag = always_flag
|
||||
self.interactivity_disabled = interactivity_disabled
|
||||
|
||||
@staticmethod
|
||||
def _infer_model_type(model):
|
||||
@ -145,6 +147,9 @@ class Interface:
|
||||
self.input_interface.get_sample_inputs()
|
||||
)
|
||||
|
||||
networking.set_always_flagged_in_config_file(output_directory, self.always_flag)
|
||||
networking.set_disabled_in_config_file(output_directory, self.interactivity_disabled)
|
||||
|
||||
def predict(self, preprocessed_input):
|
||||
"""
|
||||
Method that calls the relevant method of the model object to make a prediction.
|
||||
|
@ -132,7 +132,17 @@ def set_disabled_in_config_file(temp_dir, disabled):
|
||||
render_template_with_tags(
|
||||
config_file,
|
||||
{
|
||||
"disabled": disabled
|
||||
"disabled": json.dumps(disabled)
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
def set_always_flagged_in_config_file(temp_dir, always_flagged):
|
||||
config_file = os.path.join(temp_dir, CONFIG_FILE)
|
||||
render_template_with_tags(
|
||||
config_file,
|
||||
{
|
||||
"always_flagged": json.dumps(always_flagged)
|
||||
},
|
||||
)
|
||||
|
||||
|
@ -2,5 +2,7 @@
|
||||
"input_interface_type": "{{input_interface_type}}",
|
||||
"output_interface_type": "{{output_interface_type}}",
|
||||
"share_url": "{{share_url}}",
|
||||
"disabled": "{{disabled}}",
|
||||
"always_flagged": "{{always_flagged}}",
|
||||
"sample_inputs": {{sample_inputs}}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user