Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running workflow on local machine error #690

Open
1 task done
yeongnamtan opened this issue Sep 30, 2024 · 17 comments
Open
1 task done

Running workflow on local machine error #690

yeongnamtan opened this issue Sep 30, 2024 · 17 comments
Labels
question Further information is requested

Comments

@yeongnamtan
Copy link

Search before asking

  • 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 yeongnamtan added the question Further information is requested label Sep 30, 2024
@PawelPeczek-Roboflow
Copy link
Collaborator

Hi there,

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

@yeongnamtan
Copy link
Author

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

@PawelPeczek-Roboflow
Copy link
Collaborator

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

@yeongnamtan
Copy link
Author

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'

@PawelPeczek-Roboflow
Copy link
Collaborator

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?

@yeongnamtan
Copy link
Author

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:0@19.379] global cap_msmf.cpp:476 anonymous-namespace'::SourceReaderCB::OnReadSample videoio(MSMF): OnReadSample() is called with error status: -1072875772 [ WARN:0@19.391] global cap_msmf.cpp:488 anonymous-namespace'::SourceReaderCB::OnReadSample videoio(MSMF): async ReadSample() call is failed with error status: -1072875772
[ WARN:1@19.409] 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:0@26.892] global cap_msmf.cpp:476 anonymous-namespace'::SourceReaderCB::OnReadSample videoio(MSMF): OnReadSample() is called with error status: -1072875772 [ WARN:0@26.903] global cap_msmf.cpp:488 anonymous-namespace'::SourceReaderCB::OnReadSample videoio(MSMF): async ReadSample() call is failed with error status: -1072875772
[ WARN:2@26.917] 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:3@33.935] global cap_msmf.cpp:476 anonymous-namespace'::SourceReaderCB::OnReadSample videoio(MSMF): OnReadSample() is called with error status: -1072875772 [ WARN:3@33.946] global cap_msmf.cpp:488 anonymous-namespace'::SourceReaderCB::OnReadSample videoio(MSMF): async ReadSample() call is failed with error status: -1072875772
[ WARN:4@33.965] 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:3@39.657] global cap_msmf.cpp:476 anonymous-namespace'::SourceReaderCB::OnReadSample videoio(MSMF): OnReadSample() is called with error status: -1072875772 [ WARN:3@39.667] global cap_msmf.cpp:488 anonymous-namespace'::SourceReaderCB::OnReadSample videoio(MSMF): async ReadSample() call is failed with error status: -1072875772
[ WARN:5@39.678] 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:6@45.761] global cap_msmf.cpp:476 anonymous-namespace'::SourceReaderCB::OnReadSample videoio(MSMF): OnReadSample() is called with error status: -1072875772 [ WARN:6@45.775] global cap_msmf.cpp:488 anonymous-namespace'::SourceReaderCB::OnReadSample videoio(MSMF): async ReadSample() call is failed with error status: -1072875772
[ WARN:7@45.785] 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:3@51.981] global cap_msmf.cpp:476 anonymous-namespace'::SourceReaderCB::OnReadSample videoio(MSMF): OnReadSample() is called with error status: -1072875772 [ WARN:3@51.992] global cap_msmf.cpp:488 anonymous-namespace'::SourceReaderCB::OnReadSample videoio(MSMF): async ReadSample() call is failed with error status: -1072875772
[ WARN:8@52.004] 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:3@58.763] global cap_msmf.cpp:476 anonymous-namespace'::SourceReaderCB::OnReadSample videoio(MSMF): OnReadSample() is called with error status: -1072875772 [ WARN:3@58.776] global cap_msmf.cpp:488 anonymous-namespace'::SourceReaderCB::OnReadSample videoio(MSMF): async ReadSample() call is failed with error status: -1072875772

'''

@PawelPeczek-Roboflow
Copy link
Collaborator

ok, so this lines:

[ WARN:0@26.892] global cap_msmf.cpp:476 anonymous-namespace'::SourceReaderCB::OnReadSample videoio(MSMF): OnReadSample() is called with error status: -1072875772 [ WARN:0@26.903] global cap_msmf.cpp:488 anonymous-namespace'::SourceReaderCB::OnReadSample videoio(MSMF): async ReadSample() call is failed with error status: -1072875772
[ WARN:2@26.917] 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?

@yeongnamtan
Copy link
Author

I use my computer webcam

@PawelPeczek-Roboflow
Copy link
Collaborator

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/

@yeongnamtan
Copy link
Author

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

@PawelPeczek-Roboflow
Copy link
Collaborator

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

@yeongnamtan
Copy link
Author

yeongnamtan commented Oct 2, 2024

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

@PawelPeczek-Roboflow
Copy link
Collaborator

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

@PawelPeczek-Roboflow
Copy link
Collaborator

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

@PawelPeczek-Roboflow
Copy link
Collaborator

I mean does:

import cv2

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

print(cam.isOpened())

says true?

@yeongnamtan
Copy link
Author

(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

@PawelPeczek-Roboflow
Copy link
Collaborator

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
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants