ethz-asl / analog_gauge_reader

Open framework for reading analog gauges, deployable on real world robotic systems
MIT License
23 stars 4 forks source link

Can not get it to run #22

Open Eheran1 opened 4 months ago

Eheran1 commented 4 months ago

I have Anaconda installed on my windows machine, so I only followed the instructions below Activate conda environment. So create the new environment, activate it and install the dependencies via copy&paste of the given commands. I then copied the github repository into a local folder C:/Users/me/.spyder-py3/analog_gauge_reader-main to get the actual script etc. (this is missing in the installation procedure?).

When I now try to run the pipeline script, I get this error (line breaks and spaces added for readability)

(gauge_reader) C:\Users\me\.spyder-py3\analog_gauge_reader-main>python pipeline.py 
--detection_model        C:/Users/me/.spyder-py3/analog_gauge_reader-main/gauge_detection/detection_inference.py 
--segmentation_model     C:/Users/me/.spyder-py3/analog_gauge_reader-main/segmentation/segmenation_inference.py 
--key_point_model        C:/Users/me/.spyder-py3/analog_gauge_reader-main/key_point_detection/key_point_inference.py 
--base_path              C:/Users/me/.spyder-py3/analog_gauge_reader-main/results 
--input                  C:/Users/me/.spyder-py3/analog_gauge_reader-main/input 
--debug --eval
-------------------
Gauge Detection
WARNING ⚠️ Unable to automatically guess model task, assuming 'task=detect'. Explicitly define task for your model, i.e. 'task=detect', 'segment', 'classify','pose' or 'obb'.
Unexpected err=TypeError("model='C:\\Users\\me\\.spyder-py3\\analog_gauge_reader-main\\gauge_detection\\detection_inference.py' is not a supported model format. See https://docs.ultralytics.com/modes/predict for help.\n\n                   Format     Argument           Suffix    CPU    GPU\n0                 PyTorch            -              .pt   True   True\n1             TorchScript  torchscript     .torchscript   True   True\n2                    ONNX         onnx            .onnx   True   True\n3                OpenVINO     openvino  _openvino_model   True  False\n4                TensorRT       engine          .engine  False   True\n5                  CoreML       coreml       .mlpackage   True  False\n6   TensorFlow SavedModel  saved_model     _saved_model   True   True\n7     TensorFlow GraphDef           pb              .pb   True   True\n8         TensorFlow Lite       tflite          .tflite   True  False\n9     TensorFlow Edge TPU      edgetpu  _edgetpu.tflite   True  False\n10          TensorFlow.js         tfjs       _web_model   True  False\n11           PaddlePaddle       paddle    _paddle_model   True   True\n12                   NCNN         ncnn      _ncnn_model   True   True"), type(err)=<class 'TypeError'>

In the "results" folder, I can find the original picture, a JSON file with this content:

{
    "input": "C:/Users/me/.spyder-py3/analog_gauge_reader-main/input",
    "detection_model": "C:/Users/me/.spyder-py3/analog_gauge_reader-main/gauge_detection/detection_inference.py",
    "key_point_model": "C:/Users/me/.spyder-py3/analog_gauge_reader-main/key_point_detection/key_point_inference.py",
    "segmentation_model": "C:/Users/me/.spyder-py3/analog_gauge_reader-main/segmentation/segmenation_inference.py",
    "base_path": "C:/Users/me/.spyder-py3/analog_gauge_reader-main/results",
    "debug": true,
    "eval": true
}

And run.log with this content:

root - INFO - Start processing image at path C:/Users/me/.spyder-py3/analog_gauge_reader-main/input\IMG_20240606_130929_028.jpg
root - INFO - Start Gauge Detection
root - ERROR - Unexpected err=TypeError("model='C:\\Users\\me\\.spyder-py3\\analog_gauge_reader-main\\gauge_detection\\detection_inference.py' is not a supported model format. See https://docs.ultralytics.com/modes/predict for help.\n\n                   Format     Argument           Suffix    CPU    GPU\n0                 PyTorch            -              .pt   True   True\n1             TorchScript  torchscript     .torchscript   True   True\n2                    ONNX         onnx            .onnx   True   True\n3                OpenVINO     openvino  _openvino_model   True  False\n4                TensorRT       engine          .engine  False   True\n5                  CoreML       coreml       .mlpackage   True  False\n6   TensorFlow SavedModel  saved_model     _saved_model   True   True\n7     TensorFlow GraphDef           pb              .pb   True   True\n8         TensorFlow Lite       tflite          .tflite   True  False\n9     TensorFlow Edge TPU      edgetpu  _edgetpu.tflite   True  False\n10          TensorFlow.js         tfjs       _web_model   True  False\n11           PaddlePaddle       paddle    _paddle_model   True   True\n12                   NCNN         ncnn      _ncnn_model   True   True"), type(err)=<class 'TypeError'>

I also tried to use the gauge_detection_model etc. that are in the "models" folder like this:

python pipeline.py 
--detection_model        C:/Users/me/.spyder-py3/analog_gauge_reader-main/models/gauge_detection_model.pt 
--segmentation_model     C:/Users/me/.spyder-py3/analog_gauge_reader-main/models/segmentation_model.pt 
--key_point_model        C:/Users/me/.spyder-py3/analog_gauge_reader-main/models/key_point_model.pt 
--base_path              C:/Users/me/.spyder-py3/analog_gauge_reader-main/results 
--input                  C:/Users/me/.spyder-py3/analog_gauge_reader-main/input 
--debug --eval

And get this error:

-------------------
Gauge Detection
Unexpected err=UnpicklingError("invalid load key, 'v'."), type(err)=<class '_pickle.UnpicklingError'>

Any ideas what I am doing wrong?

InDroKalena commented 3 months ago

Were you able to find a solution to this? I'm experiencing the same error.

InDroKalena commented 3 months ago

I found a solution using git lfs before cloning the repo:

Install git lfs (https://git-lfs.github.com/): sudo apt-get install git-lfs Set it up: git lfs install

Eheran1 commented 2 months ago

I got it to run doing the following after deleting the old environment: In Anaconda CMD

cd <folder where you want the analog_gauge_reader folder to be in>
git clone https://github.com/ethz-asl/analog_gauge_reader
cd <path to your analog_gauge_reader folder>
conda create --name gauge_reader python=3.8 -y
conda activate gauge_reader
conda install pytorch==2.0.0 torchvision==0.15.0 torchaudio==2.0.0 -c pytorch -c nvidia
pip install -U openmim
mim install mmengine==0.7.2
mim install mmcv==2.0.0
mim install mmdet==3.0.0
mim install mmocr==1.0.0
pip install ultralytics==8.0.66
pip install -U scikit-learn==1.2.2

I then put a picture in a new folder "Pictures" and run the script like this:

cd <path to your analog_gauge_reader folder>
python pipeline.py --detection_model models/gauge_detection_model.pt --segmentation_model models/segmentation_model.pt --key_point_model models/key_point_model.pt --base_path results --input Pictures --debug --eval

This seems to work and give me the expected result. But even when running it without --debug --eval, I get a ton of errors on the way:

>python pipeline.py --detection_model models/gauge_detection_model.pt --segmentation_model models/segmentation_model.pt --key_point_model models/key_point_model.pt --base_path results --input Pictures

0: 480x640 3 Gauge Faces, 30.6ms
Speed: 1.0ms preprocess, 30.6ms inference, 8.5ms postprocess per image at shape (1, 3, 640, 640)
Using cache found in C:\Users\[me]/.cache\torch\hub\facebookresearch_dinov2_main
C:\Users\[me]/.cache\torch\hub\facebookresearch_dinov2_main\dinov2\layers\swiglu_ffn.py:51: UserWarning: xFormers is not available (SwiGLU)
  warnings.warn("xFormers is not available (SwiGLU)")
C:\Users\[me]/.cache\torch\hub\facebookresearch_dinov2_main\dinov2\layers\attention.py:33: UserWarning: xFormers is not available (Attention)
  warnings.warn("xFormers is not available (Attention)")
C:\Users\[me]/.cache\torch\hub\facebookresearch_dinov2_main\dinov2\layers\block.py:40: UserWarning: xFormers is not available (Block)
  warnings.warn("xFormers is not available (Block)")
C:\ProgramData\anaconda3\envs\gauge_reader\lib\site-packages\sklearn\cluster\_kmeans.py:1382: UserWarning: KMeans is known to have a memory leak on Windows with MKL, when there are less chunks than available threads. You can avoid it by setting the environment variable OMP_NUM_THREADS=3.
  warnings.warn(
C:\ProgramData\anaconda3\envs\gauge_reader\lib\site-packages\sklearn\cluster\_kmeans.py:1382: UserWarning: KMeans is known to have a memory leak on Windows with MKL, when there are less chunks than available threads. You can avoid it by setting the environment variable OMP_NUM_THREADS=1.
  warnings.warn(
Loads checkpoint by http backend from path: https://download.openmmlab.com/mmocr/textdet/dbnet/dbnet_resnet18_fpnc_1200e_icdar2015/dbnet_resnet18_fpnc_1200e_icdar2015_20220825_221614-7c0e94f2.pth
The model and loaded state dict do not match exactly

unexpected key in source state_dict: data_preprocessor.mean, data_preprocessor.std

08/06 15:32:23 - mmengine - WARNING - Failed to search registry with scope "mmocr" in the "function" registry tree. As a workaround, the current "function" registry in "mmengine" is used to build instance. This may cause unexpected failure when running the built modules. Please check whether "mmocr" is a correct scope, or whether the registry is initialized.
08/06 15:32:23 - mmengine - WARNING - `Visualizer` backend is not initialized because save_dir is None.
Loads checkpoint by http backend from path: https://download.openmmlab.com/mmocr/textrecog/abinet/abinet_20e_st-an_mj/abinet_20e_st-an_mj_20221005_012617-ead8c139.pth
C:\ProgramData\anaconda3\envs\gauge_reader\lib\site-packages\mmocr\models\textrecog\module_losses\ce_module_loss.py:101: UserWarning: padding does not exist in the dictionary
  warnings.warn(
C:\ProgramData\anaconda3\envs\gauge_reader\lib\site-packages\mmocr\models\textrecog\postprocessors\base.py:60: UserWarning: padding does not exist in the dictionary
  warnings.warn(
The model and loaded state dict do not match exactly

unexpected key in source state_dict: data_preprocessor.mean, data_preprocessor.std

C:\ProgramData\anaconda3\envs\gauge_reader\lib\site-packages\mmcv\cnn\bricks\transformer.py:819: UserWarning: Use same attn_mask in all
attentions in BaseTransformerLayer
  warnings.warn(f'Use same attn_mask in all attentions in '
C:\ProgramData\anaconda3\envs\gauge_reader\lib\site-packages\torch\nn\functional.py:4999: UserWarning: Support for mismatched
key_padding_mask and attn_mask is deprecated. Use same type for both instead.
  warnings.warn(
Inference ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

0: 640x640 1 Gauge Needle, 15.0ms
Speed: 1.5ms preprocess, 15.0ms inference, 48.6ms postprocess per image at shape (1, 3, 640, 640)
itisfree commented 2 months ago

hello!I am a student and i want try your project but I don't know how to get picture the project need,so can you share the data of the project need to me,thank you very much!

itisfree commented 2 months ago

or can you tell me how get the picture need in your project?

Eheran1 commented 2 months ago

The pictures are pictures of gauges. Here a random picture on the internet you can try

itisfree commented 2 months ago

hellow! can you tell me how your data file is set up and how your data.yaml set up?

Eheran1 commented 2 months ago

All the commands I did, assuming an existing installation of Anaconda Navigator, are listed above. I have no idea what "data.yaml" is and have not altered anything.

itisfree commented 2 months ago

thank you

---Original--- From: @.> Date: Thu, Aug 15, 2024 00:54 AM To: @.>; Cc: @.**@.>; Subject: Re: [ethz-asl/analog_gauge_reader] Can not get it to run (Issue #22)

All the commands I did, assuming an existing installation of Anaconda Navigator, are listed above. I have no idea what "data.yaml" is and have not altered anything.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>