antingshen / BeaverDam

Video annotation tool for deep learning training labels
BSD 2-Clause "Simplified" License
202 stars 99 forks source link

find annotation of videos #118

Closed sujiez closed 7 years ago

sujiez commented 7 years ago

Hi Beaverdam development team,

I need your help to access annotations of videos in a python code. I remember that I can access those annotations through the shell by doing:

from annotator.models import Video
Video.objects.all()

However, when I put the first line in my py file which is in the same folder as manage.py, I get such error:

Traceback (most recent call last): File "try.py", line 1, in from annotator.models import Video File "/home/szhou/BeaverDam/annotator/models.py", line 22 def from_list(cls, path_to_list, *, source, host, filename_prefix=''):                        ^ SyntaxError: invalid syntax

Could you help me to solve this problem? Thanks.

antingshen commented 7 years ago

Seems like you're using the wrong Python version. Ensure it's Python 3.4+

sujiez commented 7 years ago

This error shows when I am using python2.7, but when I switch to python3.5, I get such error (attached as screen shot) screenshot from 2017-08-08 11-35-36

sujiez commented 7 years ago

I think the problem is solved, and there are some good solution when you google "access django models from outside". Basically, I just put these line of codes before my file:

import os
from django.core.wsgi import get_wsgi_application
os.environ['DJANGO_SETTINGS_MODULE'] = "beaverdam.settings"
application = get_wsgi_application()

Thanks to you guys, we can have such a good annotation tool.