@@ -473,53 +473,34 @@ def json(self):
473473 return prediction_group_json
474474
475475 @staticmethod
476- def create_prediction_group (json_response , image_path , prediction_type ):
476+ def create_prediction_group (json_response , image_path , prediction_type , image_dims ):
477477 """
478478 Method to create a prediction group based on the JSON Response
479479
480480 :param prediction_type:
481481 :param json_response: Based on Roboflow JSON Response from Inference API
482482 :param model:
483483 :param image_path:
484+ :param image_dims:
484485 :return:
485486 """
486487 prediction_list = []
487488
488- # LOADING PHOTO TAKES TIME - PASS VARIABLES IF POSSIBLE
489- image_loaded = Image .open (image_path )
490- dimensions = image_loaded .size
491- # LOADING PHOTO TAKES TIME - PASS VARIABLES IF POSSIBLE
492-
493489 if prediction_type in [OBJECT_DETECTION_MODEL , INSTANCE_SEGMENTATION_MODEL ]:
494490 for prediction in json_response ["predictions" ]:
495491 prediction = Prediction (
496492 prediction , image_path , prediction_type = prediction_type
497493 )
498494 prediction_list .append (prediction )
499- if "image" not in json_response :
500- json_response ["image" ] = {
501- "width" : dimensions [0 ],
502- "height" : dimensions [1 ],
503- }
504- img_dims = json_response ["image" ]
495+ img_dims = image_dims
505496 elif prediction_type == CLASSIFICATION_MODEL :
506497 prediction = Prediction (json_response , image_path , prediction_type )
507498 prediction_list .append (prediction )
508- if "image" not in json_response :
509- json_response ["image" ] = {
510- "width" : dimensions [0 ],
511- "height" : dimensions [1 ],
512- }
513- img_dims = json_response ["image" ]
499+ img_dims = image_dims
514500 elif prediction_type == SEMANTIC_SEGMENTATION_MODEL :
515501 prediction = Prediction (json_response , image_path , prediction_type )
516502 prediction_list .append (prediction )
517- if "image" not in json_response :
518- json_response ["image" ] = {
519- "width" : dimensions [0 ],
520- "height" : dimensions [1 ],
521- }
522- img_dims = json_response ["image" ]
503+ img_dims = image_dims
523504
524505 # Seperate list and return as a prediction group
525506 return PredictionGroup (img_dims , image_path , * prediction_list )
0 commit comments