Skip to content

Commit 7ed90dd

Browse files
Merge pull request #2 from stanfordnmbl/update-latest
Upgrade to version 1.1.
2 parents 13a9030 + 99ad40f commit 7ed90dd

14 files changed

+284
-116
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ stop:
2020
start:
2121
docker-compose up -d
2222
# -v $(pwd)/.env:/code/.env
23-
docker run --name motionlab_openpose --link motionlab_redis_1:redis --link motionlab_www_1:www --net motionlab_default -d --shm-size=1g --ulimit memlock=-1 --ulimit stack=67108864 stanfordnmbl/motionlab-worker /bin/sh -c 'celery -A worker worker --loglevel=info --concurrency=1 --pool=solo'
23+
docker run --name motionlab_openpose --link motionlab_redis_1:redis --link motionlab_www_1:www --net motionlab_default -d --shm-size=1g --ulimit memlock=-1 --ulimit stack=67108864 stanfordnmbl/motionlab-worker /bin/sh -c 'celery -A worker worker --loglevel=debug --concurrency=1 --pool=solo'
2424

2525
run: docker stop start

motionlab/models.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
def get_file_path(directory):
1010
def func(instance, filename):
1111
ext = filename.split('.')[-1]
12-
filename = "%s.%s" % (uuid.uuid4(), ext)
12+
name = os.path.basename(filename).split('.')[0]
13+
name = name.replace(' ', '_')
14+
filename = "%s-%s.%s" % (name, uuid.uuid4(), ext)
1315
return os.path.join(directory, filename)
1416
return func
1517

motionlab/settings.py

+31
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,37 @@
108108
},
109109
]
110110

111+
# LOGS.
112+
LOGGING = {
113+
'version': 1,
114+
'disable_existing_loggers': False,
115+
'formatters': {
116+
'default': {
117+
'format': '[DJANGO] %(levelname)s %(asctime)s %(module)s '
118+
'%(name)s.%(funcName)s:%(lineno)s: %(message)s'
119+
},
120+
},
121+
'handlers': {
122+
'file': {
123+
'level': 'DEBUG',
124+
'class': 'logging.FileHandler',
125+
'filename': 'motionlab-log.log', # Specify the path to the log file
126+
},
127+
'console': {
128+
'level': 'DEBUG',
129+
'class': 'logging.StreamHandler',
130+
'formatter': 'default',
131+
}
132+
},
133+
'loggers': {
134+
'django': {
135+
'handlers': ['file', 'console'], # Add the 'console' handler here
136+
'level': 'DEBUG',
137+
'propagate': False,
138+
},
139+
},
140+
}
141+
111142
# Max file size.
112143
# Set FILE_UPLOAD_MAX_MEMORY_SIZE to 1 GB
113144
FILE_UPLOAD_MAX_MEMORY_SIZE = 1 * 1024 * 1024 * 1024 # 51 GB

motionlab/templates/motionlab/analysis.html

+39-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
11
{% extends "motionlab/base.html" %}
2-
{% load static %}
2+
{% load static custom_filters %}
33
{% block content %}
44

55
{% get_media_prefix as MEDIA_URL %}
66

7+
<style>
8+
.console {
9+
background-color: #000;
10+
color: #0f0;
11+
padding: 10px;
12+
font-family: monospace;
13+
white-space: pre-wrap; /* Ensures long lines are wrapped */
14+
border: 1px solid #444;
15+
border-radius: 4px;
16+
}
17+
</style>
18+
719
<script>
20+
var video_name = "{{ video_name|safe }}";
21+
822
function copyToClipboard() {
923
/* Get the text field */
1024
var copyText = document.getElementById("link");
@@ -18,6 +32,8 @@
1832

1933
/* Alert the copied text */
2034
alert("The results link " + copyText.value + "is now copied.\nSave it in a safe place to get access to your results.");
35+
36+
console.log(video_name)
2137
}
2238
</script>
2339

@@ -76,7 +92,11 @@ <h3 class="section-heading">
7692
<h3>Original video</h3>
7793
<div class="video-container" style="margin-bottom: 2em; height: 20em;">
7894
<video controls style="width: 100%; height: 100%" autoplay loop muted>
79-
<source src="{{ video.file.url }}" type="video/mp4">
95+
{% if video and video.file and video.file.url %}
96+
<source src="{{ video.file.url }}" type="video/mp4">
97+
{% else %}
98+
<p>File URL does not exist.</p>
99+
{% endif %}
80100
Your browser does not support the video tag.
81101
</video>
82102
</div>
@@ -86,7 +106,11 @@ <h3>Motion Analysis</h3>
86106
<div class="video-container" style="margin-bottom: 2em; height: 20em;">
87107
{% if annotation.status == "done" or annotation.status == "error" %}
88108
<video controls style="width: 100%; height: 100%" autoplay loop muted>
89-
<source src="{{ annotation.file.url }}" type="video/mp4">
109+
{% if annotation and annotation.file and annotation.file.url %}
110+
<source src="{{ annotation.file.url }}" type="video/mp4">
111+
{% else %}
112+
<p>File URL does not exist.</p>
113+
{% endif %}
90114
Your browser does not support the video tag.
91115
</video>
92116
{% else %}
@@ -132,15 +156,22 @@ <h3>Motion Analysis</h3>
132156
{% if annotation.status == "done" or annotation.status == "error" %}
133157
<div class="section categories" id="analyze" style="padding: 6rem 0 6rem;">
134158
<div class="container">
135-
<h3 class="section-heading">
136159
{% if annotation.status == "processing" or annotation.status == "submitted" %}
137-
The video is still processing, please visit this site later.
160+
<h3 class="section-heading">The video is still processing, please visit this site later.</h3>
138161
{% elif annotation.status == "error" %}
139-
Processing finished with an error, we are investigating it.
162+
</br>
163+
<div>
164+
{% for key, value in results.items %}
165+
{% with parts=value|split:":" %}
166+
<h3 class="section-heading">{{ parts.0 }}:</h3>
167+
<div class="console">{{ parts.1|unquote_error }}</div>
168+
{% endwith %}
169+
{% endfor %}
170+
</div>
140171
{% else %}
141-
Results
172+
<h3 class="section-heading">Results</h3>
142173
{% endif %}
143-
</h3>
174+
144175
{% if annotation.status == "done" %}
145176
<div style="text-align: center">
146177
<table style="margin-left:auto; margin-right:auto;">

motionlab/templates/motionlab/analysis_multiple.html

+21-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@
44

55
{% get_media_prefix as MEDIA_URL %}
66

7+
<style>
8+
.console {
9+
background-color: #000;
10+
color: #0f0;
11+
padding: 10px;
12+
font-family: monospace;
13+
white-space: pre-wrap; /* Ensures long lines are wrapped */
14+
border: 1px solid #444;
15+
border-radius: 4px;
16+
}
17+
</style>
18+
719
<script>
820

921
var video_file_urls = JSON.parse("{{ video_file_urls|escapejs }}");
@@ -83,7 +95,15 @@
8395
textToShow += ` <div class="container">`
8496
textToShow += ` <h3 class="section-heading">`
8597
if (annotation_statuses[selectedValue] == "error") {
86-
textToShow += ` Processing finished with an error, we are investigating it.`
98+
for (let key in results_list[selectedValue]) {
99+
var parts = results_list[selectedValue][key].split(":")
100+
textToShow += `<h3 class="section-heading">`
101+
textToShow += parts[0]
102+
textToShow += `:</h3>`
103+
textToShow += `<div class="console">`
104+
textToShow += decodeURIComponent(parts[1])
105+
textToShow += `</div>`
106+
}
87107
} else {
88108
textToShow += ` Results`
89109
}

motionlab/templates/motionlab/for_researchers.html

-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ <h3 class="section-heading" style="text-align: center; padding: 1em 0;">Open-sou
168168

169169

170170
<script>
171-
{{ recordid }}
172171
document.getElementById("id_file").onchange = function() {
173172
document.getElementById("videoForm").submit();
174173
document.getElementById("id_file").disabled = true;

motionlab/templatetags/custom_filters.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from django import template
2-
2+
import urllib.parse
33
import json
44

55
register = template.Library()
@@ -38,3 +38,11 @@ def num_processed(annotation_statuses):
3838
@register.filter(name='zip')
3939
def zip_lists(a, b):
4040
return zip(a, b)
41+
42+
@register.filter
43+
def split(value, arg):
44+
return value.split(arg)
45+
46+
@register.filter
47+
def unquote_error(value):
48+
return urllib.parse.unquote(value)

0 commit comments

Comments
 (0)