Correctly catch errors in on_model_change.
Browse files
app.py
CHANGED
@@ -67,7 +67,7 @@ def error_str(error, title="Error", model=None, task=None, framework=None, compu
|
|
67 |
Error: {error}
|
68 |
""")
|
69 |
issue_url = f"https://huggingface.co/spaces/pcuenq/transformers-to-coreml/discussions/new?title={issue_title}&description={issue_description}"
|
70 |
-
discussion_text = f"
|
71 |
return f"""
|
72 |
#### {title}
|
73 |
{error}
|
@@ -107,6 +107,8 @@ def on_model_change(model):
|
|
107 |
model = url_to_model_id(model)
|
108 |
tasks = None
|
109 |
error = None
|
|
|
|
|
110 |
|
111 |
try:
|
112 |
config_file = hf_hub_download(model, filename="config.json")
|
@@ -124,16 +126,18 @@ def on_model_change(model):
|
|
124 |
|
125 |
frameworks = supported_frameworks(model)
|
126 |
selected_framework = frameworks[0] if len(frameworks) > 0 else None
|
127 |
-
return (
|
128 |
-
gr.update(visible=bool(model_type)), # Settings column
|
129 |
-
gr.update(choices=tasks, value=tasks[0] if tasks else None), # Tasks
|
130 |
-
gr.update(visible=len(frameworks)>1, choices=frameworks, value=selected_framework), # Frameworks
|
131 |
-
gr.update(value=error_str(error, model=model)), # Error
|
132 |
-
)
|
133 |
except Exception as e:
|
134 |
error = e
|
135 |
model_type = None
|
136 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
137 |
|
138 |
def convert_model(preprocessor, model, model_coreml_config,
|
139 |
compute_units, precision, tolerance, output,
|
|
|
67 |
Error: {error}
|
68 |
""")
|
69 |
issue_url = f"https://huggingface.co/spaces/pcuenq/transformers-to-coreml/discussions/new?title={issue_title}&description={issue_description}"
|
70 |
+
discussion_text = f"You can open a discussion on the [Hugging Face Hub]({issue_url}) to report this issue."
|
71 |
return f"""
|
72 |
#### {title}
|
73 |
{error}
|
|
|
107 |
model = url_to_model_id(model)
|
108 |
tasks = None
|
109 |
error = None
|
110 |
+
frameworks = []
|
111 |
+
selected_framework = None
|
112 |
|
113 |
try:
|
114 |
config_file = hf_hub_download(model, filename="config.json")
|
|
|
126 |
|
127 |
frameworks = supported_frameworks(model)
|
128 |
selected_framework = frameworks[0] if len(frameworks) > 0 else None
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
except Exception as e:
|
130 |
error = e
|
131 |
model_type = None
|
132 |
|
133 |
+
return (
|
134 |
+
gr.update(visible=bool(model_type)), # Settings column
|
135 |
+
gr.update(choices=tasks, value=tasks[0] if tasks else None), # Tasks
|
136 |
+
gr.update(visible=len(frameworks)>1, choices=frameworks, value=selected_framework), # Frameworks
|
137 |
+
gr.update(value=error_str(error, model=model)), # Error
|
138 |
+
)
|
139 |
+
|
140 |
+
|
141 |
|
142 |
def convert_model(preprocessor, model, model_coreml_config,
|
143 |
compute_units, precision, tolerance, output,
|