Update main/library/onnx/onnx_export.py
Browse files
main/library/onnx/onnx_export.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import os
|
| 2 |
import io
|
| 3 |
import sys
|
|
|
|
| 4 |
import onnx
|
| 5 |
import json
|
| 6 |
import torch
|
|
@@ -68,7 +69,7 @@ def quantization_int8(output_path):
|
|
| 68 |
quantize_dynamic(model_input=output_path, model_output=output_path_int8, weight_type=QuantType.QInt8)
|
| 69 |
# Return the INT8 path if successfully generated; otherwise fallback to the original path
|
| 70 |
return output_path_int8 if os.path.exists(output_path_int8) else output_path
|
| 71 |
-
|
| 72 |
@spaces.GPU
|
| 73 |
def onnx_exporter(input_path, output_path, is_half=False, int8_mode=False, device="cpu"):
|
| 74 |
"""
|
|
|
|
| 1 |
import os
|
| 2 |
import io
|
| 3 |
import sys
|
| 4 |
+
import spaces
|
| 5 |
import onnx
|
| 6 |
import json
|
| 7 |
import torch
|
|
|
|
| 69 |
quantize_dynamic(model_input=output_path, model_output=output_path_int8, weight_type=QuantType.QInt8)
|
| 70 |
# Return the INT8 path if successfully generated; otherwise fallback to the original path
|
| 71 |
return output_path_int8 if os.path.exists(output_path_int8) else output_path
|
| 72 |
+
|
| 73 |
@spaces.GPU
|
| 74 |
def onnx_exporter(input_path, output_path, is_half=False, int8_mode=False, device="cpu"):
|
| 75 |
"""
|