biigle / magic-sam

:m: BIIGLE module for the Magic SAM image annotation instrument
GNU General Public License v3.0
0 stars 0 forks source link

image embedding error #8

Closed Npiechaud closed 1 year ago

Npiechaud commented 1 year ago

Hey guys,

Just reporting an error with the tool

I have had an error with magic-SAM that says "Could not load the image embedding" each time I press the SAM button. The processing seem to work normally (I mean, I see the little stars coming out of the hat) but i get the error when it stops. Other types of annotations are fine. I tried with Chrome and Edge. I also tried on different volumes in different projects. At least one other user I know has the same error.

Capture

This tool is very handy, hope it is an easy fix. Cheers

dlangenk commented 1 year ago

Hey Nils,

this has likely to do with #7. I did a quick fix for that image only. I will fix the issue behind that later. If you have another image that does not work. Just send me a mail and I'll quickly upload the fixed embedding. (Please note that we have a downtime of Maia and Sam from 2 to 9 today).

Best Daniel

Npiechaud commented 1 year ago

Hi Daniel, Thanks for the quick response. I can wait for the general fix, no worries. What is a rotation flag? Is that set by the user? Something we can fix on our side?

cheers

dlangenk commented 1 year ago

Hi Nils,

When you take a photo with e.g. your mobile phone and you do this in landscape mode (sideways) then a value is set in the file that the photo has been taken in landscape mode. This way when opened by an image viewer it should be always rotated correctly. However, some libraries just ignore this flag thus the orientation of the photo is incorrect while processing it which leads to errors.

So basically you could set the orientation flag yourself but instead it should be handled correctly by our script. Unfortunately, Martin is on holiday and I want him to have a look at it before going live. So it will take two more weeks.

Cheers

Npiechaud commented 1 year ago

Ok, thanks for the info. We will plan accordingly.

Cheers

dlangenk commented 1 year ago

@mzur Unfortunately this seems to be a different error (look at server log).

mzur commented 1 year ago

To clarify: BIIGLE's default behavior is to ignore the EXIF rotation flag (because we often have cameras facing down which randomly produce either rotation value of the flag). In this case BIIGLE mistakenly does not ignore this flag.

@dlangenk Can you please tell me which log entry you mean? Either you can paste it here or give me a timestamp.

dlangenk commented 1 year ago

It's the problem we talked about this morning. For example this one:

array:7 [▼ // resources/views/admin/logs/index-redis.blade.php
  "message" => """
    Error while executing python command '/var/www/vendor/biigle/magic-sam/src/config/../resources/scripts/compute_embedding.py '/var/www/storage/magic_sam/sam_chec ▶
    Traceback (most recent call last):
      File "/var/www/vendor/biigle/magic-sam/src/config/../resources/scripts/compute_embedding.py", line 19, in <module>
        sam.to(device=device)
      File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py", line 989, in to
        return self._apply(convert)
      File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py", line 641, in _apply
        module._apply(fn)
      File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py", line 641, in _apply
        module._apply(fn)
      File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py", line 641, in _apply
        module._apply(fn)
      File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py", line 664, in _apply
        param_applied = fn(param)
      File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py", line 987, in convert
        return t.to(device, dtype if t.is_floating_point() or t.is_complex() else None, non_blocking)
      File "/opt/conda/lib/python3.10/site-packages/torch/cuda/__init__.py", line 229, in _lazy_init
        torch._C._cuda_init()
    RuntimeError: No CUDA GPUs are available
    """
  "context" => array:1 [▶]
  "level" => 400
  "level_name" => "ERROR"
  "channel" => "production"
  "datetime" => "2023-07-27T10:52:02.028950+02:00"
  "extra" => []
]
mzur commented 1 year ago

I see. We fixed this issue temporarily and Magic SAM should work again. The long-term fix is in progress (i.e. switching to Docker Swarm with a GPU health check). I'll close this for now but please feel free to reopen if there are still issues.