inference icon indicating copy to clipboard operation
inference copied to clipboard

Running workflow on local machine error

Open yeongnamtan opened this issue 1 year ago • 17 comments

Search before asking

  • [X] I have searched the Inference issues and found no similar feature requests.

Question

I tried running the below workflow on my local machine and get this error.

SAHI PEOPLE DETECTION: https://app.roboflow.com/workflows/embed/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ3b3JrZmxvd0lkIjoicTdwQWRlb0xXR3Z5ZVo1RGFFaUoiLCJ3b3Jrc3BhY2VJZCI6ImtyT1RBYm5jRmhvUU1DZExPbGU0IiwidXNlcklkIjoiSW1GTElaU2tHYk55OXpiNFV1cWxNelBScHBRMiIsImlhdCI6MTcyNDgwNzA2M30.Ds34vuWm6zS3zHuozZzAGcgoktqHoRjKvC50MSppS0w UserWarning: Field "model_type" in BlockManifest has conflict with protected namespace "model_".

You may be able to resolve this warning by setting model_config['protected_namespaces'] = (). UserWarning: Field "model_version" in BlockManifest has conflict with protected namespace "model_".

You may be able to resolve this warning by setting `model_config['protected_namespaces'] = ()`.
UserWarning: Field name "schema" in "WorkflowsBlocksSchemaDescription" shadows an attribute in parent "BaseModel"
UserWarning: Specified provider 'CUDAExecutionProvider' is not in available provider names.Available providers: 'CPUExecutionProvider'
UserWarning: Specified provider 'OpenVINOExecutionProvider' is not in available provider names.Available providers: 'CPUExecutionProvider'

Additional

No response

yeongnamtan avatar Sep 30 '24 07:09 yeongnamtan

Hi there,

This is just warning, for now you may not worry. Good that you are pointing this up, will be fixed soon 👍

PawelPeczek-Roboflow avatar Sep 30 '24 08:09 PawelPeczek-Roboflow

I can't run in local machine because of this error.

yeongnamtan avatar Sep 30 '24 09:09 yeongnamtan

well, that's strange - I suspect there is other issue - could you elaborate more?

PawelPeczek-Roboflow avatar Sep 30 '24 09:09 PawelPeczek-Roboflow

Plse see below. My local computer just hang...

(myenv) PS C:\Users\yeong> python demo_roboflow_workflow.py SupervisionWarnings: BoundingBoxAnnotator is deprecated: BoundingBoxAnnotator is deprecated and has been renamed to BoxAnnotator. BoundingBoxAnnotator will be removed in supervision-0.26.0. InferenceExperimentalFeatureWarning: init_with_workflow is experimental: Usage of workflows with InferencePipeline is an experimental feature. Please report any issues here: https://github.com/roboflow/inference/issues UserWarning: Field "model_type" has conflict with protected namespace "model_".

You may be able to resolve this warning by setting model_config['protected_namespaces'] = (). UserWarning: Field "model_version" has conflict with protected namespace "model_".

You may be able to resolve this warning by setting model_config['protected_namespaces'] = (). UserWarning: Field name "schema" in "WorkflowsBlocksSchemaDescription" shadows an attribute in parent "BaseModel" UserWarning: Specified provider 'CUDAExecutionProvider' is not in available provider names.Available providers: 'CPUExecutionProvider' UserWarning: Specified provider 'OpenVINOExecutionProvider' is not in available provider names.Available providers: 'CPUExecutionProvider'

yeongnamtan avatar Sep 30 '24 12:09 yeongnamtan

Could you verify the content of /tmp/cache and sub-directories named after your model? It looks like the weights download may be long for some reasons.

Additionally could you export LOG_LEVEL=DEBUG to see what is going on under the hood?

PawelPeczek-Roboflow avatar Sep 30 '24 12:09 PawelPeczek-Roboflow

I created a virtual env called myenv2 and did a pip install inference there. ''' PS C:\Users\yeong> .\myenv2\Scripts\Activate (myenv2) PS C:\Users\yeong> $env:LOG_LEVEL = "DEBUG" (myenv2) PS C:\Users\yeong> echo $env:LOG_LEVEL DEBUG (myenv2) PS C:\Users\yeong> python demo_roboflow_workflow.py [10/01/24 09:58:31] DEBUG Checking for latest inference release version... init.py:22 [10/01/24 09:58:36] INFO Memory Cache initialised init.py:22 [10/01/24 09:58:41] DEBUG Persistence through SQLiteQueue collector.py:97 DEBUG Cached plan details collector.py:109 SupervisionWarnings: BoundingBoxAnnotator is deprecated: BoundingBoxAnnotator is deprecated and has been renamed to BoxAnnotator. BoundingBoxAnnotator will be removed in supervision-0.26.0. InferenceExperimentalFeatureWarning: init_with_workflow is experimental: Usage of workflows with InferencePipeline is an experimental feature. Please report any issues here: https://github.com/roboflow/inference/issues UserWarning: Field "model_type" in BlockManifest has conflict with protected namespace "model_".

You may be able to resolve this warning by setting model_config['protected_namespaces'] = (). UserWarning: Field "model_version" in BlockManifest has conflict with protected namespace "model_".

You may be able to resolve this warning by setting model_config['protected_namespaces'] = (). UserWarning: Field name "schema" in "WorkflowsBlocksSchemaDescription" shadows an attribute in parent "BaseModel" [10/01/24 09:58:45] DEBUG For step: $steps.image_slicer, detected the following input dimensionalities: graph_constructor.py:594 defaultdict(<class 'set'>, {'image': {1}, 'slice_width': {0}, 'slice_height': {0}, 'overlap_ratio_width': {0}, 'overlap_ratio_height': {0}}) DEBUG For step: $steps.sahi_model, detected the following input dimensionalities: graph_constructor.py:594 defaultdict(<class 'set'>, {'images': {2}, 'model_id': {0}, 'class_agnostic_nms': {0}, 'class_filter': {0}, 'confidence': {0}, 'iou_threshold': {0},
'max_detections': {0}, 'max_candidates': {0}, 'disable_active_learning': {0}, 'active_learning_target_dataset': {0}}) [10/01/24 09:58:46] DEBUG For step: $steps.combined_predictions, detected the following input graph_constructor.py:594 dimensionalities: defaultdict(<class 'set'>, {'reference_image': {1}, 'predictions': {2}, 'overlap_filtering_strategy': {0}, 'iou_threshold': {0}}) DEBUG For step: $steps.bounding_box_visualization, detected the following input graph_constructor.py:594 dimensionalities: defaultdict(<class 'set'>, {'image': {1}, 'copy_image': {0}, 'predictions': {1}, 'color_palette': {0}, 'palette_size': {0}, 'custom_colors': {0}, 'color_axis': {0}, 'thickness': {0}, 'roundness': {0}}) DEBUG For step: $steps.person_count, detected the following input dimensionalities: graph_constructor.py:594 defaultdict(<class 'set'>, {'data': {1}, 'operations': {0}}) DEBUG For step: $steps.label_visualization, detected the following input graph_constructor.py:594 dimensionalities: defaultdict(<class 'set'>, {'image': {1}, 'copy_image': {0}, 'predictions': {1}, 'color_palette': {0}, 'palette_size': {0}, 'custom_colors': {0}, 'color_axis': {0}, 'text': {0}, 'text_position': {0}, 'text_color': {0}, 'text_scale': {0}, 'text_thickness': {0}, 'text_padding': {0}, 'border_radius': {0}}) INFO Inference thread started inference_pipeline.py:807 [10/01/24 09:58:51] DEBUG Cannot obtain plan details, api key hash cannot be resolved collector.py:442 DEBUG Sending usage payload {'820b2': {'model:people-detection-o4rdr/7': {'timestamp_start': collector.py:456 1727747912538052200, 'timestamp_stop': 1727747922492632200, 'exec_session_id': '1727747589359273000_c674', 'ip_address_hash': 'ec541', 'processed_frames': 70, 'fps': 0, 'source_duration': 0, 'category': 'model', 'resource_id': 'people-detection-o4rdr/7', 'resource_details': '{"source": "workflow-execution", "task_type": "object-detection"}', 'hosted': False, 'api_key_hash': '820b2', 'is_gpu_available': False, 'python_version': '3.10.11', 'inference_version': '0.21.1', 'enterprise': False}}} DEBUG Failed to send usage following usage payloads: {'820b2'} collector.py:464 DEBUG Enqueuing back unsent payload collector.py:472 DEBUG Enqueuing usage payload {'820b2': {'model:people-detection-o4rdr/7': {'timestamp_start': collector.py:193 1727747912538052200, 'timestamp_stop': 1727747922492632200, 'exec_session_id': '1727747589359273000_c674', 'ip_address_hash': 'ec541', 'processed_frames': 70, 'fps': 0,
'source_duration': 0, 'category': 'model', 'resource_id': 'people-detection-o4rdr/7', 'resource_details': '{"source": "workflow-execution", "task_type": "object-detection"}', 'hosted': False, 'is_gpu_available': False, 'python_version': '3.10.11', 'inference_version': '0.21.1', 'enterprise': False, 'api_key': '820b2'}}} DEBUG Cannot obtain plan details, api key hash cannot be resolved collector.py:442 DEBUG Sending usage payload {'820b2': {'workflows:sahi-people-detection': {'timestamp_start': collector.py:456 1727747912995564800, 'timestamp_stop': 1727747922174710400, 'exec_session_id': '1727747589359273000_c674', 'ip_address_hash': 'ec541', 'processed_frames': 17, 'fps': 30.0, 'source_duration': 0.5666666666666667, 'category': 'workflows', 'resource_id': 'sahi-people-detection', 'resource_details': '{"steps": ["roboflow_core/roboflow_object_detection_model@v1:sahi_model", "roboflow_core/bounding_box_visualization@v1:bounding_box_visualization", "roboflow_core/label_visualization@v1:label_visualization", "roboflow_core/property_definition@v1:person_count", "roboflow_core/image_slicer@v1:image_slicer", "roboflow_core/detections_stitch@v1:combined_predictions"], "is_preview": false}', 'hosted': False, 'api_key_hash': '820b2', 'is_gpu_available': False, 'python_version': '3.10.11', 'inference_version': '0.21.1', 'enterprise': False}}} [10/01/24 09:58:52] INFO Video consumption started video_source.py:649 [ WARN:[email protected]] global cap_msmf.cpp:476 anonymous-namespace'::SourceReaderCB::OnReadSample videoio(MSMF): OnReadSample() is called with error status: -1072875772 [ WARN:[email protected]] global cap_msmf.cpp:488 anonymous-namespace'::SourceReaderCB::OnReadSample videoio(MSMF): async ReadSample() call is failed with error status: -1072875772 [ WARN:[email protected]] global cap_msmf.cpp:1769 CvCapture_MSMF::grabFrame videoio(MSMF): can't grab frame. Error: -1072875772 INFO Video consumption finished video_source.py:680 DEBUG Failed to send usage following usage payloads: {'820b2'} collector.py:464 [10/01/24 09:58:53] DEBUG Enqueuing back unsent payload collector.py:472 DEBUG Enqueuing usage payload {'820b2': {'workflows:sahi-people-detection': {'timestamp_start': collector.py:193 1727747912995564800, 'timestamp_stop': 1727747922174710400, 'exec_session_id': '1727747589359273000_c674', 'ip_address_hash': 'ec541', 'processed_frames': 17, 'fps':
30.0, 'source_duration': 0.5666666666666667, 'category': 'workflows', 'resource_id':
'sahi-people-detection', 'resource_details': '{"steps":
["roboflow_core/roboflow_object_detection_model@v1:sahi_model",
"roboflow_core/bounding_box_visualization@v1:bounding_box_visualization",
"roboflow_core/label_visualization@v1:label_visualization",
"roboflow_core/property_definition@v1:person_count",
"roboflow_core/image_slicer@v1:image_slicer",
"roboflow_core/detections_stitch@v1:combined_predictions"], "is_preview": false}',
'hosted': False, 'is_gpu_available': False, 'python_version': '3.10.11',
'inference_version': '0.21.1', 'enterprise': False, 'api_key': '820b2'}}}
[10/01/24 09:58:59] INFO Video consumption started video_source.py:649 [ WARN:[email protected]] global cap_msmf.cpp:476 anonymous-namespace'::SourceReaderCB::OnReadSample videoio(MSMF): OnReadSample() is called with error status: -1072875772 [ WARN:[email protected]] global cap_msmf.cpp:488 anonymous-namespace'::SourceReaderCB::OnReadSample videoio(MSMF): async ReadSample() call is failed with error status: -1072875772 [ WARN:[email protected]] global cap_msmf.cpp:1769 CvCapture_MSMF::grabFrame videoio(MSMF): can't grab frame. Error: -1072875772 INFO Video consumption finished video_source.py:680 [10/01/24 09:59:06] INFO Video consumption started video_source.py:649 [ WARN:[email protected]] global cap_msmf.cpp:476 anonymous-namespace'::SourceReaderCB::OnReadSample videoio(MSMF): OnReadSample() is called with error status: -1072875772 [ WARN:[email protected]] global cap_msmf.cpp:488 anonymous-namespace'::SourceReaderCB::OnReadSample videoio(MSMF): async ReadSample() call is failed with error status: -1072875772 [ WARN:[email protected]] global cap_msmf.cpp:1769 CvCapture_MSMF::grabFrame videoio(MSMF): can't grab frame. Error: -1072875772 INFO Video consumption finished video_source.py:680 [10/01/24 09:59:12] INFO Video consumption started video_source.py:649 [ WARN:[email protected]] global cap_msmf.cpp:476 anonymous-namespace'::SourceReaderCB::OnReadSample videoio(MSMF): OnReadSample() is called with error status: -1072875772 [ WARN:[email protected]] global cap_msmf.cpp:488 anonymous-namespace'::SourceReaderCB::OnReadSample videoio(MSMF): async ReadSample() call is failed with error status: -1072875772 [ WARN:[email protected]] global cap_msmf.cpp:1769 CvCapture_MSMF::grabFrame videoio(MSMF): can't grab frame. Error: -1072875772 INFO Video consumption finished video_source.py:680 [10/01/24 09:59:18] INFO Video consumption started video_source.py:649 [ WARN:[email protected]] global cap_msmf.cpp:476 anonymous-namespace'::SourceReaderCB::OnReadSample videoio(MSMF): OnReadSample() is called with error status: -1072875772 [ WARN:[email protected]] global cap_msmf.cpp:488 anonymous-namespace'::SourceReaderCB::OnReadSample videoio(MSMF): async ReadSample() call is failed with error status: -1072875772 [ WARN:[email protected]] global cap_msmf.cpp:1769 CvCapture_MSMF::grabFrame videoio(MSMF): can't grab frame. Error: -1072875772 INFO Video consumption finished video_source.py:680 [10/01/24 09:59:24] INFO Video consumption started video_source.py:649 [ WARN:[email protected]] global cap_msmf.cpp:476 anonymous-namespace'::SourceReaderCB::OnReadSample videoio(MSMF): OnReadSample() is called with error status: -1072875772 [ WARN:[email protected]] global cap_msmf.cpp:488 anonymous-namespace'::SourceReaderCB::OnReadSample videoio(MSMF): async ReadSample() call is failed with error status: -1072875772 [ WARN:[email protected]] global cap_msmf.cpp:1769 CvCapture_MSMF::grabFrame videoio(MSMF): can't grab frame. Error: -1072875772 INFO Video consumption finished video_source.py:680 [10/01/24 09:59:31] INFO Video consumption started video_source.py:649 [ WARN:[email protected]] global cap_msmf.cpp:476 anonymous-namespace'::SourceReaderCB::OnReadSample videoio(MSMF): OnReadSample() is called with error status: -1072875772 [ WARN:[email protected]] global cap_msmf.cpp:488 anonymous-namespace'::SourceReaderCB::OnReadSample videoio(MSMF): async ReadSample() call is failed with error status: -1072875772

'''

yeongnamtan avatar Oct 01 '24 02:10 yeongnamtan

ok, so this lines:

[ WARN:[email protected]] global cap_msmf.cpp:476 anonymous-namespace'::SourceReaderCB::OnReadSample videoio(MSMF): OnReadSample() is called with error status: -1072875772 [ WARN:[email protected]] global cap_msmf.cpp:488 anonymous-namespace'::SourceReaderCB::OnReadSample videoio(MSMF): async ReadSample() call is failed with error status: -1072875772
[ WARN:[email protected]] global cap_msmf.cpp:1769 CvCapture_MSMF::grabFrame videoio(MSMF): can't grab frame. Error: -1072875772

indicate issue with camera source. What is the setup you run the processing?

PawelPeczek-Roboflow avatar Oct 01 '24 08:10 PawelPeczek-Roboflow

I use my computer webcam

yeongnamtan avatar Oct 01 '24 10:10 yeongnamtan

Ok,

From the error I get that you are running on Windows, right? Are you able to consume the camera feed using Opencv? this may be used to confirm: https://www.geeksforgeeks.org/python-opencv-capture-video-from-camera/

PawelPeczek-Roboflow avatar Oct 01 '24 10:10 PawelPeczek-Roboflow

i am running on windows. I can consume the camera feed using OpenCV.

yeongnamtan avatar Oct 02 '24 02:10 yeongnamtan

could you please show the script you use to start inference pipeline?

PawelPeczek-Roboflow avatar Oct 02 '24 07:10 PawelPeczek-Roboflow

Import the InferencePipeline object

from inference import InferencePipeline import cv2

def my_sink(result, video_frame): if result.get("output_image"): # Display an image from the workflow response cv2.imshow("Workflow Image", result["output_image"].numpy_image) cv2.waitKey(1) #print(result) # do something with the predictions of each frame

https://app.roboflow.com/fish-laucn/workflows/edit/sahi-people-detection

initialize a pipeline object

pipeline = InferencePipeline.init_with_workflow( api_key="xxx", workspace_name="fish-laucn", workflow_id="sahi-people-detection", video_reference=0, # Path to video, device id (int, usually 0 for built in webcams), or RTSP stream url max_fps=30, on_prediction=my_sink ) pipeline.start() #start the pipeline pipeline.join() #wait for the pipeline thread to finish

yeongnamtan avatar Oct 02 '24 08:10 yeongnamtan

masked your API key, but since you revealed it I strongly recommend rotating

PawelPeczek-Roboflow avatar Oct 02 '24 08:10 PawelPeczek-Roboflow

well - looks good here - are you sure the camera is under device 0?

PawelPeczek-Roboflow avatar Oct 02 '24 08:10 PawelPeczek-Roboflow

I mean does:

import cv2

# Open the default camera
cam = cv2.VideoCapture(0)

print(cam.isOpened())

says true?

PawelPeczek-Roboflow avatar Oct 02 '24 08:10 PawelPeczek-Roboflow

(newenv) PS C:\Users\yeong> python Python 3.9.12 (main, Apr 4 2022, 05:22:27) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32 Type "help", "copyright", "credits" or "license" for more information.

import cv2 cam = cv2.VideoCapture(0) print(cam.isOpened()) True

I had rotated my API key

yeongnamtan avatar Oct 03 '24 01:10 yeongnamtan

Ok, honestly I do not know why you cannot grab the video frames in inference pipeline. I have a feeling that adding this to inference pipeline may solve the problem.

You can try to override video consumer for inference pipeline with this code:

from typing import Any, Callable, Dict, List, Optional, Protocol, Tuple, Union

from inference.core.interfaces.camera.video_source import CV2VideoFrameProducer

class WindowsCV2VideoFrameProducer(CV2VideoFrameProducer):
    def __init__(self, video: Union[str, int]):
        if isinstance(video, int):
            self.stream = cv2.VideoCapture(video, cv2.CAP_DSHOW)
        else:
            super().__init__(video)

and then kick of inference pipeline with

from functools import partial 


pipeline = InferencePipeline.init_with_workflow(
    api_key="xxx",
    workspace_name="fish-laucn",
    workflow_id="sahi-people-detection",
    video_reference=partial(WindowsCV2VideoFrameProducer, video=0), # Path to video, device id (int, usually 0 for built in webcams), or RTSP stream url
    max_fps=30,
    on_prediction=my_sink
)

PawelPeczek-Roboflow avatar Oct 03 '24 07:10 PawelPeczek-Roboflow

Hi @yeongnamtan, due to no feedback I'll close this issue, but please feel free to reopen if proposed solution is still not working for you.

grzegorz-roboflow avatar Nov 15 '24 12:11 grzegorz-roboflow