Correctly catch errors in on_model_change.
Browse files66 unmodified lines6768697071727333 unmodified lines10710810911011111211 unmodified lines12412512612712812913013113213313413513613713813966 unmodified linesError: {error}""")issue_url = f"https://huggingface.co/spaces/pcuenq/transformers-to-coreml/discussions/new?title={issue_title}&description={issue_description}"discussion_text = f"It could be that the model is not yet compatible with the Core ML exporter. Please, open a discussion on the [Hugging Face Hub]({issue_url}) to report this issue."return f"""#### {title}{error}33 unmodified linesmodel = url_to_model_id(model)tasks = Noneerror = Nonetry:config_file = hf_hub_download(model, filename="config.json")11 unmodified linesframeworks = supported_frameworks(model)selected_framework = frameworks[0] if len(frameworks) > 0 else Nonereturn (gr.update(visible=bool(model_type)), # Settings columngr.update(choices=tasks, value=tasks[0] if tasks else None), # Tasksgr.update(visible=len(frameworks)>1, choices=frameworks, value=selected_framework), # Frameworksgr.update(value=error_str(error, model=model)), # Error)except Exception as e:error = emodel_type = Nonedef convert_model(preprocessor, model, model_coreml_config,compute_units, precision, tolerance, output,66 unmodified lines6768697071727333 unmodified lines10710810911011111211311411 unmodified lines12612712812913013113213313413513613713813914014114214366 unmodified linesError: {error}""")issue_url = f"https://huggingface.co/spaces/pcuenq/transformers-to-coreml/discussions/new?title={issue_title}&description={issue_description}"discussion_text = f"You can open a discussion on the [Hugging Face Hub]({issue_url}) to report this issue."return f"""#### {title}{error}33 unmodified linesmodel = url_to_model_id(model)tasks = Noneerror = Noneframeworks = []selected_framework = Nonetry:config_file = hf_hub_download(model, filename="config.json")11 unmodified linesframeworks = supported_frameworks(model)selected_framework = frameworks[0] if len(frameworks) > 0 else Noneexcept Exception as e:error = emodel_type = Nonereturn (gr.update(visible=bool(model_type)), # Settings columngr.update(choices=tasks, value=tasks[0] if tasks else None), # Tasksgr.update(visible=len(frameworks)>1, choices=frameworks, value=selected_framework), # Frameworksgr.update(value=error_str(error, model=model)), # Error)def convert_model(preprocessor, model, model_coreml_config,compute_units, precision, tolerance, output,
app.py+11-7