Update README.md
Browse files
README.md
CHANGED
|
@@ -79,34 +79,6 @@ This model is designed for **Edge AI deployment**, optimized via **ONNX** and **
|
|
| 79 |
|
| 80 |
**Edge Optimization:** Model converted and optimized using `openvino.convert_model()`.
|
| 81 |
|
| 82 |
-
---
|
| 83 |
-
|
| 84 |
-
## Inference Example
|
| 85 |
-
```python
|
| 86 |
-
from openvino.runtime import Core
|
| 87 |
-
import cv2
|
| 88 |
-
import numpy as np
|
| 89 |
-
|
| 90 |
-
ie = Core()
|
| 91 |
-
model = ie.read_model(model="casting_ir/model.xml")
|
| 92 |
-
compiled_model = ie.compile_model(model=model, device_name="CPU")
|
| 93 |
-
|
| 94 |
-
# Load and preprocess image
|
| 95 |
-
img = cv2.imread('sample_casting.png', cv2.IMREAD_GRAYSCALE)
|
| 96 |
-
img = cv2.resize(img, (128, 128)) / 255.0
|
| 97 |
-
img = np.expand_dims(img, (0,1)).astype(np.float32)
|
| 98 |
-
|
| 99 |
-
# Run inference
|
| 100 |
-
infer_request = compiled_model.create_infer_request()
|
| 101 |
-
result = infer_request.infer(inputs={compiled_model.inputs[0]: img})
|
| 102 |
-
|
| 103 |
-
reconstructed = result[compiled_model.outputs[0]]
|
| 104 |
-
error = np.mean((img - reconstructed)**2)
|
| 105 |
-
if error > 0.01:
|
| 106 |
-
print("Defective Casting Detected")
|
| 107 |
-
else:
|
| 108 |
-
print("Casting OK")
|
| 109 |
-
```
|
| 110 |
|
| 111 |
---
|
| 112 |
|
|
|
|
| 79 |
|
| 80 |
**Edge Optimization:** Model converted and optimized using `openvino.convert_model()`.
|
| 81 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
|
| 83 |
---
|
| 84 |
|