Spaces:
Sleeping
Sleeping
nam pham
commited on
Commit
·
41c4fb2
1
Parent(s):
eded98b
feat: load unsupported model
Browse files
app.py
CHANGED
@@ -72,7 +72,7 @@ def does_file_glob_exist(repo_id: str, glob: str) -> bool:
|
|
72 |
|
73 |
|
74 |
def export_to_torch(model_id, create_pr, output_model_id):
|
75 |
-
model = SentenceTransformer(model_id, backend="torch")
|
76 |
model.push_to_hub(
|
77 |
repo_id=output_model_id,
|
78 |
create_pr=create_pr,
|
@@ -84,7 +84,7 @@ def export_to_onnx(model_id: str, create_pr: bool, output_model_id: str, token:
|
|
84 |
if does_file_glob_exist(output_model_id, "**/model.onnx"):
|
85 |
raise FileExistsError("An ONNX model already exists in the repository")
|
86 |
|
87 |
-
model = SentenceTransformer(model_id, backend="onnx")
|
88 |
|
89 |
commit_message = "Add exported onnx model 'model.onnx'"
|
90 |
|
@@ -184,7 +184,7 @@ def export_to_onnx_dynamic_quantization(
|
|
184 |
if does_file_glob_exist(output_model_id, f"onnx/model_qint8_{onnx_quantization_config}.onnx"):
|
185 |
raise FileExistsError("The quantized ONNX model already exists in the repository")
|
186 |
|
187 |
-
model = SentenceTransformer(model_id, backend="onnx")
|
188 |
|
189 |
if not create_pr and is_new_model(output_model_id):
|
190 |
model.push_to_hub(repo_id=output_model_id, token=token)
|
@@ -202,7 +202,8 @@ def export_to_onnx_dynamic_quantization(
|
|
202 |
)
|
203 |
except ValueError:
|
204 |
# Currently, quantization with optimum has some issues if there's already an ONNX model in a subfolder
|
205 |
-
model = SentenceTransformer(model_id,
|
|
|
206 |
st_export_dynamic_quantized_onnx_model(
|
207 |
model,
|
208 |
quantization_config=onnx_quantization_config,
|
@@ -262,7 +263,7 @@ def export_to_onnx_optimization(model_id: str, create_pr: bool, output_model_id:
|
|
262 |
if does_file_glob_exist(output_model_id, f"onnx/model_{onnx_optimization_config}.onnx"):
|
263 |
raise FileExistsError("The optimized ONNX model already exists in the repository")
|
264 |
|
265 |
-
model = SentenceTransformer(model_id, backend="onnx")
|
266 |
|
267 |
if not create_pr and is_new_model(output_model_id):
|
268 |
model.push_to_hub(repo_id=output_model_id, token=token)
|
@@ -329,7 +330,7 @@ def export_to_openvino(model_id: str, create_pr: bool, output_model_id: str, tok
|
|
329 |
if does_file_glob_exist(output_model_id, "**/openvino_model.xml"):
|
330 |
raise FileExistsError("The OpenVINO model already exists in the repository")
|
331 |
|
332 |
-
model = SentenceTransformer(model_id, backend="openvino")
|
333 |
|
334 |
commit_message = "Add exported openvino model 'openvino_model.xml'"
|
335 |
|
@@ -434,7 +435,7 @@ def export_to_openvino_static_quantization(
|
|
434 |
if does_file_glob_exist(output_model_id, "openvino/openvino_model_qint8_quantized.xml"):
|
435 |
raise FileExistsError("The quantized OpenVINO model already exists in the repository")
|
436 |
|
437 |
-
model = SentenceTransformer(model_id, backend="openvino")
|
438 |
|
439 |
if not create_pr and is_new_model(output_model_id):
|
440 |
model.push_to_hub(repo_id=output_model_id, token=token)
|
|
|
72 |
|
73 |
|
74 |
def export_to_torch(model_id, create_pr, output_model_id):
|
75 |
+
model = SentenceTransformer(model_id, trust_remote_code=True, backend="torch")
|
76 |
model.push_to_hub(
|
77 |
repo_id=output_model_id,
|
78 |
create_pr=create_pr,
|
|
|
84 |
if does_file_glob_exist(output_model_id, "**/model.onnx"):
|
85 |
raise FileExistsError("An ONNX model already exists in the repository")
|
86 |
|
87 |
+
model = SentenceTransformer(model_id, trust_remote_code=True,backend="onnx")
|
88 |
|
89 |
commit_message = "Add exported onnx model 'model.onnx'"
|
90 |
|
|
|
184 |
if does_file_glob_exist(output_model_id, f"onnx/model_qint8_{onnx_quantization_config}.onnx"):
|
185 |
raise FileExistsError("The quantized ONNX model already exists in the repository")
|
186 |
|
187 |
+
model = SentenceTransformer(model_id, trust_remote_code=True, backend="onnx")
|
188 |
|
189 |
if not create_pr and is_new_model(output_model_id):
|
190 |
model.push_to_hub(repo_id=output_model_id, token=token)
|
|
|
202 |
)
|
203 |
except ValueError:
|
204 |
# Currently, quantization with optimum has some issues if there's already an ONNX model in a subfolder
|
205 |
+
model = SentenceTransformer(model_id, trust_remote_code=True
|
206 |
+
, backend="onnx", model_kwargs={"export": True})
|
207 |
st_export_dynamic_quantized_onnx_model(
|
208 |
model,
|
209 |
quantization_config=onnx_quantization_config,
|
|
|
263 |
if does_file_glob_exist(output_model_id, f"onnx/model_{onnx_optimization_config}.onnx"):
|
264 |
raise FileExistsError("The optimized ONNX model already exists in the repository")
|
265 |
|
266 |
+
model = SentenceTransformer(model_id, trust_remote_code=True, backend="onnx")
|
267 |
|
268 |
if not create_pr and is_new_model(output_model_id):
|
269 |
model.push_to_hub(repo_id=output_model_id, token=token)
|
|
|
330 |
if does_file_glob_exist(output_model_id, "**/openvino_model.xml"):
|
331 |
raise FileExistsError("The OpenVINO model already exists in the repository")
|
332 |
|
333 |
+
model = SentenceTransformer(model_id, trust_remote_code=True, backend="openvino")
|
334 |
|
335 |
commit_message = "Add exported openvino model 'openvino_model.xml'"
|
336 |
|
|
|
435 |
if does_file_glob_exist(output_model_id, "openvino/openvino_model_qint8_quantized.xml"):
|
436 |
raise FileExistsError("The quantized OpenVINO model already exists in the repository")
|
437 |
|
438 |
+
model = SentenceTransformer(model_id, trust_remote_code=True, backend="openvino")
|
439 |
|
440 |
if not create_pr and is_new_model(output_model_id):
|
441 |
model.push_to_hub(repo_id=output_model_id, token=token)
|