backend
This commit is contained in:
29
paddleExport.py
Normal file
29
paddleExport.py
Normal file
@@ -0,0 +1,29 @@
|
||||
import paddle
|
||||
from paddleocr import PaddleOCR
|
||||
from ppocr.architectures import build_model
|
||||
import paddle.static as static
|
||||
|
||||
# Initialisiere das OCR-Modell
|
||||
ocr = PaddleOCR(use_angle_cls=True, lang='en')
|
||||
|
||||
# Spezifikation der Eingabe - das Modell erwartet ein RGB-Bild der Größe 640x640
|
||||
input_spec = static.InputSpec(shape=[1, 3, 640, 640], dtype='float32', name='image')
|
||||
|
||||
# Exportiere das Modell ins ONNX-Format
|
||||
def export_to_onnx():
|
||||
paddle.enable_static()
|
||||
model_dir = './inference/ch_ppocr_mobile_v2.0_det_infer/' # Pfad zum vortrainierten Modell
|
||||
model_file = f'{model_dir}/model'
|
||||
params_file = f'{model_dir}/params'
|
||||
|
||||
paddle.onnx.export(
|
||||
model=model_file,
|
||||
path='paddleocr_model.onnx',
|
||||
input_spec=[input_spec],
|
||||
model_params=params_file,
|
||||
opset_version=11,
|
||||
)
|
||||
print("Modell wurde erfolgreich nach ONNX exportiert.")
|
||||
|
||||
export_to_onnx()
|
||||
|
||||
Reference in New Issue
Block a user