Skip to content

Problem with loading weights #5

@cjwalther

Description

@cjwalther

Using the example code in the readme.md on my workstation has shown that QReader succeeds where other python codes fail (congrats on that!). However, when moving the same small code into a venv on the server where it is meant to be included into a django project (and where hence django is installed), it fails by suddenly landing in django-land (after line 1124 in serialization.py) although django is not invoked in the example code.

This is confusing and kind of above my pay grade...

Traceback (most recent call last):
  File "/webapps/roggu/roggu/rogguapp/q1.py", line 15, in <module>
    detector = QReader()
  File "/webapps/roggu/lib/python3.10/site-packages/qreader.py", line 26, in __init__
    self.detector = QRDetector()
  File "/webapps/roggu/lib/python3.10/site-packages/qrdet.py", line 28, in __init__
    self.model = Yolov7Detector(weights=_WEIGHTS_PATH, img_size=None, agnostic_nms=True, traced=False)
  File "/webapps/roggu/lib/python3.10/site-packages/yolov7_package/model_utils.py", line 147, in __init__
    self.model = attempt_load([weights], map_location=self.device)  # load FP32 model
  File "/webapps/roggu/lib/python3.10/site-packages/yolov7_package/models/experimental.py", line 242, in attempt_load
    ckpt = torch.load(w, map_location=map_location)  # load
  File "/webapps/roggu/lib/python3.10/site-packages/torch/serialization.py", line 789, in load
    return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args)
  File "/webapps/roggu/lib/python3.10/site-packages/torch/serialization.py", line 1131, in _load
    result = unpickler.load()
  File "/webapps/roggu/lib/python3.10/site-packages/torch/serialization.py", line 1124, in find_class
    return super().find_class(mod_name, name)
  File "/webapps/roggu/roggu/rogguapp/models.py", line 3, in <module>
    class Beleg(models.Model):
  File "/webapps/roggu/lib/python3.10/site-packages/django/db/models/base.py", line 127, in __new__
    app_config = apps.get_containing_app_config(module)
  File "/webapps/roggu/lib/python3.10/site-packages/django/apps/registry.py", line 260, in get_containing_app_config
    self.check_apps_ready()
  File "/webapps/roggu/lib/python3.10/site-packages/django/apps/registry.py", line 137, in check_apps_ready
    settings.INSTALLED_APPS
  File "/webapps/roggu/lib/python3.10/site-packages/django/conf/__init__.py", line 92, in __getattr__
    self._setup(name)
  File "/webapps/roggu/lib/python3.10/site-packages/django/conf/__init__.py", line 72, in _setup
    raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions