Correctly catch errors in on_model_change.
Browse files66 unmodified lines676869707071727333 unmodified lines10710810911011111211311411 unmodified lines12612712812712812913013113212913013113213313413513613713813914014114214366 unmodified lines Error: {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." 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 lines model = url_to_model_id(model) tasks = None error = None frameworks = [] selected_framework = None
try: config_file = hf_hub_download(model, filename="config.json")11 unmodified lines
frameworks = supported_frameworks(model) selected_framework = frameworks[0] if len(frameworks) > 0 else None return ( gr.update(visible=bool(model_type)), # Settings column gr.update(choices=tasks, value=tasks[0] if tasks else None), # Tasks gr.update(visible=len(frameworks)>1, choices=frameworks, value=selected_framework), # Frameworks gr.update(value=error_str(error, model=model)), # Error ) except Exception as e: error = e model_type = None
return ( gr.update(visible=bool(model_type)), # Settings column gr.update(choices=tasks, value=tasks[0] if tasks else None), # Tasks gr.update(visible=len(frameworks)>1, choices=frameworks, value=selected_framework), # Frameworks gr.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