Giter VIP home page Giter VIP logo

beesbook_backend's Introduction

beesbook_backend

The purpose of this backend is to interface the data on the servers and the user and developers. It currently holds the ability to plot videos and images from bb_binary and bb_tracking data.. The plots can be cropped to show only relevant areas and the filling of gaps (for missing frames in tracks).

How To (for users)

  1. install api part of bb_backend (no dependencies required)
  2. tunnel

ssh -N -L 8000:localhost:8000 thekla.imp.fu-berlin.de

  1. use bb_backend.api to fetch images and videos:
import bb_backend.api
from bb_backend.api import FramePlotter, VideoPlotter
bb_backend.api.server_adress = '127.0.0.1:8000'

frame_plotter = FramePlotter(frame_id=12058089920919369671, xs=[350, 450], ys=[350, 450],
                                sizes=[40,200],title="Image title (e.g. timestamp)",
                                labels=["Abee","Beebee"], scale=1.0, colors=["r", "y"])
plt.imshow(frame_plotter.get_image())

# Make video consisting of 3 times the same frame.
video_plotter = VideoPlotter(frames=[frame_plotter, frame_plotter, frame_plotter])

video_plotter.get_video(display_in_notebook=True)

Setup (not for users)

  1. Install software and library requirements:
  • docker
  • docker-compose (python package)
  • python virtualenv with packages in requirements.txt
  • ffmpeg with x264 encoding and h264 decoding capability
  1. Initialize database data volume:

docker create -v /var/lib/postgresql --name postgres_data postgres:9.6

docker-compose up -d

docker-compose exec postgres psql -U postgres -c "CREATE DATABASE beesbook;"

python manage.py migrate

  1. Find and store all video locations

python manage.py make_db_video [video_path_location]

e.g. python manage.py make_db_video /home/beesbook/hlrn/work1-hlrn/videos_HD_2016/

  1. Read all repository data

python manage.py make_db_repo [repo_folder]

e.g. python manage.py make_db_repo /mnt/storage/beesbook/repo_season_2016_fixed

  1. Run the server

Please configure nginx or something similar

For testing python manage.py runserver is fine.

beesbook_backend's People

Contributors

ktugan avatar walachey avatar

Watchers

 avatar James Cloos avatar  avatar

Forkers

walachey

beesbook_backend's Issues

frontend library to abstract interface

Knowing how to use the backend is kinda complicated. Build some functions to abstract the interface so other people can start using it too.

See plot.py from the old code for integration into notebooks.

Documentation

A documentation is required for following things:

  • How to deploy the application
    • docker and postgres
    • make_db_repo and make_db_video
    • ffmpeg requirements
  • How to use the api
    • getting images and videos (syntax of the post request)
    • plotting images and videos (syntax of the post request)

blocking ffmpeg commands

The ffmpeg commands should block other ffmpeg commands until they are finished and then check if the files exist.

This is required when two parallel requests are made which extract the same video.

move caching to redis

The memoizing decorator functions (filepath_cacher, cacher) should use redis instead a file system.

It also should expire some of the items (e.g. extracted images) every now and probably even delete from the hard disk.

encoding of new videos does not use gpu when flag is set

gpu flag set true does not enable gpu accelerated encoding:

ffmpeg_frames_to_video = ' '.join([
    f'ffmpeg -v {verbosity_level}',
    '-r 3',  # input framerate
    '-i {input_path}',
    '-r 3',  # video framerate (kinda irrelevant)
    '-pix_fmt yuv420p',
    '-vcodec libx264',
    '{output_path}'
])

concurrency

check if ffmpeg is running already (locking?)

refactor config file

Merge the config files into a single one. This config file should decide itself which config to use (gpu or cpu).

Also allow global config variables (config variables used by both types).

fillgap bug

Internal Server Error: /plotter/plot_video/
Traceback (most recent call last):
  File "/home/ktugan/miniconda3/envs/backend/lib/python3.6/site-packages/django/core/handlers/exception.py", line 39, in inner
    response = get_response(request)
  File "/home/ktugan/miniconda3/envs/backend/lib/python3.6/site-packages/django/core/handlers/base.py", line 187, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/home/ktugan/miniconda3/envs/backend/lib/python3.6/site-packages/django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/ktugan/miniconda3/envs/backend/lib/python3.6/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
    return view_func(*args, **kwargs)
  File "/home/ktugan/beesbook_backend/plotter/views.py", line 79, in plot_video
    path = Frame.plot_video(data, fill_gap, crop)
  File "/home/ktugan/beesbook_backend/plotter/utils.py", line 35, in check_file
    mem_object = f.call_and_shelve(*args, **kwargs)
  File "/home/ktugan/miniconda3/envs/backend/lib/python3.6/site-packages/joblib/memory.py", line 476, in call_and_shelve
    _, argument_hash, metadata = self._cached_call(args, kwargs)
  File "/home/ktugan/miniconda3/envs/backend/lib/python3.6/site-packages/joblib/memory.py", line 430, in _cached_call
    out, metadata = self.call(*args, **kwargs)
  File "/home/ktugan/miniconda3/envs/backend/lib/python3.6/site-packages/joblib/memory.py", line 675, in call
    output = self.func(*args, **kwargs)
  File "/home/ktugan/beesbook_backend/plotter/models.py", line 113, in plot_video
    return media.plot_video(data, crop)
  File "/home/ktugan/beesbook_backend/plotter/media.py", line 216, in plot_video
    xs = [x for p in data for x in p['x']]
  File "/home/ktugan/beesbook_backend/plotter/media.py", line 216, in <listcomp>
    xs = [x for p in data for x in p['x']]
KeyError: 'x'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.