Skip to content

Commit 7f87f85

Browse files
committed
YOLOv3 crash with empty image hotfix
1 parent df29b57 commit 7f87f85

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/backends/onnxruntime.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ RAI_Tensor* RAI_TensorCreateFromOrtValue(OrtValue* v, size_t batch_offset, long
206206
if (status != NULL) goto error;
207207

208208
int64_t total_batch_size = dims[0];
209+
total_batch_size = total_batch_size > 0 ? total_batch_size : 1;
209210

210211
shape = RedisModule_Calloc(ndims, sizeof(*shape));
211212
strides = RedisModule_Calloc(ndims, sizeof(*strides));

src/backends/tensorflow.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ RAI_Tensor* RAI_TensorCreateFromTFTensor(TF_Tensor *tensor, size_t batch_offset,
8989

9090
const size_t ndims = TF_NumDims(tensor);
9191

92-
const int64_t total_batch_size = TF_Dim(tensor, 0);
92+
int64_t total_batch_size = TF_Dim(tensor, 0);
93+
total_batch_size = total_batch_size > 0 ? total_batch_size : 1;
9394

9495
int64_t* shape = RedisModule_Calloc(ndims, sizeof(*shape));
9596
int64_t* strides = RedisModule_Calloc(ndims, sizeof(*strides));

0 commit comments

Comments
 (0)