label-studio-ml-backend: ImportError: cannot import name 'LabelStudioMLBase' from 'label_studio.ml'

Getting this error when trying to follow the guide: https://labelstud.io/guide/ml.html at label-studio-ml init my_ml_backend --script label_studio-ml/examples/simple_text_classifier.py step

p.s.: not sure if it matters, but I didn’t run the pip install -r requirements.txt command, since I already have newer versions of the listed packages

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 22 (13 by maintainers)

Most upvoted comments

Hi @serjrd,

You can skip the last two steps by just replacing:

self.project_dir=None

with

self.project_dir="/label-studio/data/media/"

in mmdetection.py

Alright, so after a while it seems that I can sum up all the issues I faced on my path to set up ml-backend:

  • Wrong import statements in the examples folder
  • Counter-intuitive process of making label-studio to actually get data from ML-backend (you specifically need to open ‘label’ link - getting to labeling screen by just clicking the project apparently doesn’t do it)
  • By default ML backend showed errors like requests.exceptions.MissingSchema: Invalid URL '/data/upload/41__2021.03.23_18-27_urDDvKC.jpg': No schema supplied. Perhaps you meant http:///data/upload/41__2021.03.23_18-27_urDDvKC.jpg?. Had to manually add http://.... part.
  • Had to set up third-party HTTP server to serve label-studio’s image folder to avoid Authentication credentials were not provided problem. Not really sure at the moment how to fix this issue better.

Thank for the help @rm-data-viz

There’s clearly lots to be fixed!

@rm-data-viz

As I said, it doesn’t show any errors. I don’t know if something got broken at 1.0.0, but it just doesn’t work the way I thought it should.

I tried deleting both label-studio and label-studio-ml-backend and installing them from scratch.

So here’s what I did:

pip3 uninstall label-studio && pip3 uninstall label-studio-ml && rm -r label-studio-ml-backend 
pip3 install label-studio
git clone https://github.com/heartexlabs/label-studio-ml-backend
cd label-studio-ml-backend
pip install -e .

sed -i s/label_studio.ml/label_studio_ml/ label_studio_ml/examples/mmdetection/mmdetection.py
sed -i s/label_studio.utils.io/label_studio.core.utils.io/ label_studio_ml/examples/mmdetection/mmdetection.py

label-studio-ml init coco-detector --from label_studio_ml/examples/mmdetection/mmdetection.py

label-studio-ml start coco-detector --with config_file=vfnet.py checkpoint_file=vfnet.pth score_threshold=0.5  device=cuda:0
label-studio start

I set up labeling interface like this:

<View>
  <Image name="image" value="$image" zoom="true"/>
  <RectangleLabels name="label" toName="image">
    <Label value="object1(s)" background="#135d75" predicted_values="object1(s)"/>
    <Label value="object2(s)" background="blue" predicted_values="object2(s)/>
  </RectangleLabels>
</View>

I add machine learning backend and it says ‘connected’. The Display ML-predicted annotations when labeling toggle is active.

But when I go ahead and import some images and open them for labeling objects - nothing happens. No errors in console. No predicted bounding boxes. Nothing 😦