Closed jeronimocabezuelo closed 3 months ago
THW maxflow module is a C++ extension to the library. It only gets installed when the requirements are met. I assume that is the case in the codalab machine but not locally.
Please try following the instructions here: https://loli.github.io/medpy/installation/graphcutsupport.html
Best, O
On Mon, 15 Feb 2021, 14:50 jeronimocabezuelo, notifications@github.com wrote:
Hi, I wanted to use a graph based image segmenter and this library worked flawlessly when installed in a google collaboratory remotely. However, when I import it locally with jupyter notebook it gives the error that it does not find the medpy.graphcut.maxflow module. Indeed, in medpy / graphcut / init.py on line 200 the .maxflow module is called, however I did not find any module called maxflow. The funny thing about this is that this error does not occur in google collaboratory. [image: Captura de pantalla 2021-02-15 120933] https://user-images.githubusercontent.com/79094184/107954497-ce339380-6f9c-11eb-9022-b5e9ed11b696.png
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/loli/medpy/issues/99, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGLK7XBNOCIZME6V5FTY3TS7ERCLANCNFSM4XUXHMAQ .
Hi. I am also facing the same issue. I tried on both ubuntu machine and google colab, facing the same issue. Below are the steps which I used on google colab. (https://colab.research.google.com/)
!apt-get install libboost-python-dev build-essential
!pip install medpy
import numpy
from medpy.io import load, header
from medpy.graphcut import graphcut_from_voxels
from mdepy.graphcut.energy_voxel import boundary_difference_exponential
I am getting the following errors:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-5-2670f2fdeac5> in <module>()
1 import numpy
2 from medpy.io import load, header
----> 3 from medpy.graphcut import graphcut_from_voxels
4 from mdepy.graphcut.energy_voxel import boundary_difference_exponential
ImportError: cannot import name 'graphcut_from_voxels' from 'medpy.graphcut' (/usr/local/lib/python3.7/dist-packages/medpy/graphcut/__init__.py)
---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.
To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------
Attaching the screenshot also. Please let me know how this error can be removed.
Also in ubuntu (following the below steps in termial)
sudo apt-get install libboost-python-dev build-essential
pip install medpy
I am getting the following error
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-2670f2fdeac5> in <module>
1 import numpy
2 from medpy.io import load, header
----> 3 from medpy.graphcut import graphcut_from_voxels
4 from mdepy.graphcut.energy_voxel import boundary_difference_exponential
~/miniconda3/envs/sumit_2021/lib/python3.6/site-packages/medpy/graphcut/__init__.py in <module>
198
199 # import from compile C++ Python module
--> 200 from .maxflow import GraphDouble, GraphFloat, GraphInt # this always triggers an error in Eclipse, but is right
201
202 # import all functions/methods/classes into the module
ModuleNotFoundError: No module named 'medpy.graphcut.maxflow'
Please note that the error you are getting on Colab is distinct to the one you get on Ubuntu.
In the second case (Ubuntu), the graphcut package has not been compiled successfully. To figure out why, try installing with
!pip install medpy --log install.log
and check the log file.
In the first case (Colab) you import from medpy.graphcut import graphcut_from_voxels
, but it should be from medpy.graphcut import graph_from_voxels
.
Please read your errors carefully, read the manual ( https://loli.github.io/medpy/) and check your code before opening an issue.
Am Sa., 1. Mai 2021 um 16:45 Uhr schrieb Sumit Sharma < @.***>:
Hi. I am also facing the same issue. I tried on both ubuntu machine and google colab, facing the same issue. Below are the steps which I used on google colab.
!apt-get install libboost-python-dev build-essential !pip install medpy
import numpy from medpy.io import load, header from medpy.graphcut import graphcut_from_voxels from mdepy.graphcut.energy_voxel import boundary_difference_exponential
I am getting the following errors:
ImportError Traceback (most recent call last) in () 1 import numpy 2 from medpy.io import load, header ----> 3 from medpy.graphcut import graphcut_from_voxels 4 from mdepy.graphcut.energy_voxel import boundary_difference_exponential
ImportError: cannot import name 'graphcut_from_voxels' from 'medpy.graphcut' (/usr/local/lib/python3.7/dist-packages/medpy/graphcut/ init.py)
NOTE: If your import is failing due to a missing package, you can manually install dependencies using either !pip or !apt. To view examples of installing some common dependencies, click the "Open Examples" button below.
Attaching the screenshot also. Please let me know how this error can be removed. [image: image] https://user-images.githubusercontent.com/28561272/116785959-f752c300-aab9-11eb-9f47-68d047dc761c.png
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/loli/medpy/issues/99#issuecomment-830643796, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGLK7V7YYDTG5PRMVUQ4RDTLQH2LANCNFSM4XUXHMAQ .
Thank you for your valuable inputs. The error is resolved in google colab, will check using the logs how to resolve it for the ubuntu server also. Actually, I was trying to use the code snippet from one of your pages, seems that minor code snippet correction might be needed. https://loli.github.io/medpy/graphcut.html.
Please modify the code snippet (if possible) as it will be useful for others also.
from medpy.graphcut import graph_from_voxels
from medpy.graphcut.energy_voxel import boundary_difference_exponential
Thanks for pointing out the error in the documentation.
On Tue, 4 May 2021, 14:54 Sumit Sharma, @.***> wrote:
Thank you for your valuable inputs. The error is resolved in google colab, will check using the logs how to resolve it for the ubuntu server also. Actually, I was trying to use the code snippet from one of your pages, seems that minor code snippet correction might be needed. https://loli.github.io/medpy/graphcut.html.
Please modify the code snippet (if possible) as it will be useful for others also.
from medpy.graphcut import graph_from_voxels from medpy.graphcut.energy_voxel import boundary_difference_exponential
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/loli/medpy/issues/99#issuecomment-831918868, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGLK7X6TGB763JCIBNSOSDTL7VBRANCNFSM4XUXHMAQ .
Addressed in latest release 0.5.0
Hi, I wanted to use a graph based image segmenter and this library worked flawlessly when installed in a google collaboratory remotely. However, when I import it locally with jupyter notebook it gives the error that it does not find the medpy.graphcut.maxflow module. Indeed, in medpy / graphcut / init.py on line 200 the .maxflow module is called, however I did not find any module called maxflow. The funny thing about this is that this error does not occur in google collaboratory.