Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Felix Marty
commited on
Commit
ยท
0fead51
1
Parent(s):
c0ea4f1
fix
Browse files- app.py +5 -2
- onnx_export.py +0 -1
app.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
import csv
|
| 2 |
import os
|
| 3 |
from datetime import datetime
|
| 4 |
-
from typing import Optional
|
| 5 |
|
| 6 |
import gradio as gr
|
| 7 |
from huggingface_hub import HfApi, Repository
|
|
@@ -21,7 +21,7 @@ if HF_TOKEN:
|
|
| 21 |
repo = Repository(local_dir=DATADIR, clone_from=DATASET_REPO_URL, token=HF_TOKEN)
|
| 22 |
|
| 23 |
|
| 24 |
-
def onnx_export(token: str, model_id: str, task: str, opset: int) -> str:
|
| 25 |
if token == "" or model_id == "":
|
| 26 |
return """
|
| 27 |
### Invalid input ๐
|
|
@@ -29,6 +29,9 @@ def onnx_export(token: str, model_id: str, task: str, opset: int) -> str:
|
|
| 29 |
Please fill a token and model name.
|
| 30 |
"""
|
| 31 |
try:
|
|
|
|
|
|
|
|
|
|
| 32 |
api = HfApi(token=token)
|
| 33 |
|
| 34 |
error, commit_info = convert(api=api, model_id=model_id, task=task, opset=opset)
|
|
|
|
| 1 |
import csv
|
| 2 |
import os
|
| 3 |
from datetime import datetime
|
| 4 |
+
from typing import Optional, Union
|
| 5 |
|
| 6 |
import gradio as gr
|
| 7 |
from huggingface_hub import HfApi, Repository
|
|
|
|
| 21 |
repo = Repository(local_dir=DATADIR, clone_from=DATASET_REPO_URL, token=HF_TOKEN)
|
| 22 |
|
| 23 |
|
| 24 |
+
def onnx_export(token: str, model_id: str, task: str, opset: Union[int, str]) -> str:
|
| 25 |
if token == "" or model_id == "":
|
| 26 |
return """
|
| 27 |
### Invalid input ๐
|
|
|
|
| 29 |
Please fill a token and model name.
|
| 30 |
"""
|
| 31 |
try:
|
| 32 |
+
if opset == "":
|
| 33 |
+
opset = None
|
| 34 |
+
|
| 35 |
api = HfApi(token=token)
|
| 36 |
|
| 37 |
error, commit_info = convert(api=api, model_id=model_id, task=task, opset=opset)
|
onnx_export.py
CHANGED
|
@@ -61,7 +61,6 @@ def convert_onnx(model_id: str, task: str, folder: str, opset: int) -> List:
|
|
| 61 |
"Could not infer the pad token id, which is needed in this case, please provide it with the --pad_token_id argument"
|
| 62 |
)
|
| 63 |
|
| 64 |
-
print("opset:", opset)
|
| 65 |
# Ensure the requested opset is sufficient
|
| 66 |
if opset == None:
|
| 67 |
opset = onnx_config.DEFAULT_ONNX_OPSET
|
|
|
|
| 61 |
"Could not infer the pad token id, which is needed in this case, please provide it with the --pad_token_id argument"
|
| 62 |
)
|
| 63 |
|
|
|
|
| 64 |
# Ensure the requested opset is sufficient
|
| 65 |
if opset == None:
|
| 66 |
opset = onnx_config.DEFAULT_ONNX_OPSET
|