Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Weights files missing. #190

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
__pycache__
*.pyc
videos
dataset
dataset
Empty file modified .travis.yml
100644 → 100755
Empty file.
Empty file modified CODE_OF_CONDUCT.md
100644 → 100755
Empty file.
Empty file modified CONTRIBUTING.md
100644 → 100755
Empty file.
Empty file modified LICENSE
100644 → 100755
Empty file.
325 changes: 26 additions & 299 deletions README.md
100644 → 100755

Large diffs are not rendered by default.

Empty file modified docs/audio/countdown_sound.wav
100644 → 100755
Empty file.
Empty file modified docs/audio/done_sound.wav
100644 → 100755
Empty file.
Empty file modified docs/audio/exit_sound.wav
100644 → 100755
Empty file.
Empty file modified docs/gifs/action_recognition_1.gif
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/gifs/fitness_tracking.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docs/gifs/fitness_tracking_1.gif
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docs/gifs/fitness_tracking_2.gif
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/gifs/gesture_recognition.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/gifs/gesture_recognition_1.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/gifs/hri_recognition.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docs/imgs/sense_core_logo.svg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docs/wiki/home.md
100644 → 100755
Empty file.
Empty file modified examples/run_action_recognition.py
100644 → 100755
Empty file.
Empty file modified examples/run_calorie_estimation.py
100644 → 100755
Empty file.
Empty file modified examples/run_fitness_rep_counter.py
100644 → 100755
Empty file.
Empty file modified examples/run_fitness_tracker.py
100644 → 100755
Empty file.
102 changes: 102 additions & 0 deletions examples/run_hri_recognition.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#!/usr/bin/env python
"""
Real time detection of 30 actions.

Usage:
run_action_recognition.py [--camera_id=CAMERA_ID]
[--path_in=FILENAME]
[--path_out=FILENAME]
[--title=TITLE]
[--model_name=NAME]
[--model_version=VERSION]
[--use_gpu]
run_action_recognition.py (-h | --help)

Options:
--path_in=FILENAME Video file to stream from
--path_out=FILENAME Video file to stream to
--title=TITLE This adds a title to the window display
--model_name=NAME Name of the model to be used.
--model_version=VERSION Version of the model to be used.
--use_gpu Whether to run inference on the GPU or not.
"""
from docopt import docopt

import sense.display
from sense.controller import Controller
from sense.downstream_tasks.hri_recognition import INT2LAB
from sense.downstream_tasks.hri_recognition import GESTURE_THRESHOLDS
from sense.downstream_tasks.nn_utils import LogisticRegression
from sense.downstream_tasks.nn_utils import Pipe
from sense.downstream_tasks.postprocess import PostprocessClassificationOutput
from sense.loading import update_backbone_weights
from sense.loading import build_backbone_network
from sense.loading import load_weights_from_resources
from sense.loading import ModelConfig


SUPPORTED_MODEL_CONFIGURATIONS = [
ModelConfig('StridedInflatedEfficientNet', 'pro', ['action_recognition']),
ModelConfig('StridedInflatedMobileNetV2', 'pro', ['action_recognition']),
ModelConfig('StridedInflatedEfficientNet', 'lite', ['action_recognition']),
ModelConfig('StridedInflatedMobileNetV2', 'lite', ['action_recognition']),
]

if __name__ == "__main__":
# Parse arguments
args = docopt(__doc__)
camera_id = int(args['--camera_id'] or 0)
path_in = args['--path_in'] or None
path_out = args['--path_out'] or None
title = args['--title'] or None
use_gpu = args['--use_gpu']

# Load backbone network according to config file
backbone_model_config = ModelConfig('StridedInflatedEfficientNet', 'pro', [])
backbone_weights = backbone_model_config.load_weights()['backbone']

# Load custom network
checkpoint_classifier = load_weights_from_resources('hri_recognition/fyp5024.checkpoint')

# Update original weights in case some intermediate layers have been finetuned
update_backbone_weights(backbone_weights, checkpoint_classifier)

# Create backbone network
backbone_network = build_backbone_network(backbone_model_config, backbone_weights)

hri_classifier = LogisticRegression(num_in=backbone_network.feature_dim,
num_out=len(INT2LAB))
hri_classifier.load_state_dict(checkpoint_classifier)
hri_classifier.eval()

# Concatenate backbone network and logistic regression
net = Pipe(backbone_network, hri_classifier)

postprocessor = [
PostprocessClassificationOutput(INT2LAB, smoothing=4)
]

border_size = 30

display_ops = [
sense.display.DisplayFPS(expected_camera_fps=net.fps,
expected_inference_fps=net.fps / net.step_size),
sense.display.DisplayTopKClassificationOutputs(top_k=1, threshold=0.5),
sense.display.DisplayClassnameOverlay(thresholds=GESTURE_THRESHOLDS,
border_size_top=border_size if not title else border_size + 50),
]

display_results = sense.display.DisplayResults(title=title, display_ops=display_ops)

# Run live inference
controller = Controller(
neural_network=net,
post_processors=postprocessor,
results_display=display_results,
callbacks=[],
camera_id=camera_id,
path_in=path_in,
path_out=path_out,
use_gpu=use_gpu
)
controller.run_inference()
Empty file modified requirements.txt
100644 → 100755
Empty file.
Empty file modified resources/action_recognition/sien_lite_logreg.ckpt
100644 → 100755
Empty file.
Empty file modified resources/action_recognition/sien_logreg.ckpt
100644 → 100755
Empty file.
Empty file modified resources/action_recognition/simn_lite_logreg.ckpt
100644 → 100755
Empty file.
Empty file modified resources/action_recognition/simn_logreg.ckpt
100644 → 100755
Empty file.
Empty file modified resources/calorie_estimation/sien_lite_met_converter.ckpt
100644 → 100755
Empty file.
Empty file modified resources/calorie_estimation/sien_met_converter.ckpt
100644 → 100755
Empty file.
Empty file modified resources/calorie_estimation/simn_lite_met_converter.ckpt
100644 → 100755
Empty file.
Empty file modified resources/calorie_estimation/simn_met_converter.ckpt
100644 → 100755
Empty file.
Empty file modified resources/fitness_activity_recognition/sien_lite_logreg.ckpt
100644 → 100755
Empty file.
Empty file modified resources/fitness_activity_recognition/sien_logreg.ckpt
100644 → 100755
Empty file.
Empty file modified resources/fitness_activity_recognition/simn_lite_logreg.ckpt
100644 → 100755
Empty file.
Empty file modified resources/fitness_activity_recognition/simn_logreg.ckpt
100644 → 100755
Empty file.
Binary file added resources/hri_recognition/fyp5024.checkpoint
Binary file not shown.
Binary file added resources/hri_recognition/fyp5024.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified sense/__init__.py
100644 → 100755
Empty file.
Empty file modified sense/backbone_networks/__init__.py
100644 → 100755
Empty file.
Empty file modified sense/backbone_networks/efficientnet.py
100644 → 100755
Empty file.
Empty file modified sense/backbone_networks/mobilenet.py
100644 → 100755
Empty file.
Empty file modified sense/camera.py
100644 → 100755
Empty file.
Empty file modified sense/controller.py
100644 → 100755
Empty file.
Empty file modified sense/display.py
100644 → 100755
Empty file.
Empty file modified sense/downstream_tasks/__init__.py
100644 → 100755
Empty file.
Empty file modified sense/downstream_tasks/action_recognition/__init__.py
100644 → 100755
Empty file.
Empty file modified sense/downstream_tasks/calorie_estimation/__init__.py
100644 → 100755
Empty file.
Empty file.
Empty file modified sense/downstream_tasks/calorie_estimation/met_converter.py
100644 → 100755
Empty file.
Empty file modified sense/downstream_tasks/fitness_activity_recognition/__init__.py
100644 → 100755
Empty file.
Empty file modified sense/downstream_tasks/fitness_rep_counting/__init__.py
100644 → 100755
Empty file.
40 changes: 40 additions & 0 deletions sense/downstream_tasks/hri_recognition/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
LAB2INT = {
"Come forward": 0,
"Do Nothing": 1,
"Doing something else": 2,
"Handwave": 3,
"Move backward": 4,
"Move to the left": 5,
"Move to the right": 6,
"Pause": 7,
"Pointing: Object": 8,
"Repeat: Rotate arm clockwise": 9,
"Resume": 10,
"Start": 11,
"Stop": 12,
"Thumbs down": 13,
"Thumbs up": 14,
"Undo: Rotate arm anti-clockwise": 15,
"Watch out": 16
}

INT2LAB = {value: key for key, value in LAB2INT.items()}

GESTURE_THRESHOLDS = {
"Pause": 0.6,
"Move to the left": 0.6,
"Undo: Rotate arm anti-clockwise": 0.3,
"Thumbs down": 0.6,
"Watch out": 0.5,
"Thumbs up": 0.9,
"Resume": 0.7,
"Repeat: Rotate arm clockwise": 0.3,
"Come forward": 0.5,
"Move to the right": 0.6,
"Move backward": 0.8,
"Handwave": 0.4,
"Start": 0.5,
"Pointing: Object": 0.5,
"Stop": 0.95
}

Empty file modified sense/downstream_tasks/nn_utils.py
100644 → 100755
Empty file.
Empty file modified sense/downstream_tasks/postprocess.py
100644 → 100755
Empty file.
Empty file modified sense/engine.py
100644 → 100755
Empty file.
Empty file modified sense/finetuning.py
100644 → 100755
Empty file.
7 changes: 3 additions & 4 deletions sense/loading.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ def __init__(self, model_name: str, version: str, feature_converters: List[str])
self.model_name = model_name
self.version = version
self.combined_model_name = f'{self.model_name}-{self.version}'

self.feature_converters = feature_converters

def check_weight_files(self):
Expand Down Expand Up @@ -117,17 +116,17 @@ def get_relevant_weights(
:return:
First available model config and dictionary of model weights
"""
for config in model_config_list:
print(config.feature_converters)

# Filter out model configurations that don't match requested name, version and converter
if requested_model_name:
model_config_list = [config for config in model_config_list
if config.model_name == requested_model_name]
print(model_config_list)
if requested_version:
model_config_list = [config for config in model_config_list
if config.version == requested_version]
if requested_converter:
model_config_list = [config for config in model_config_list
if requested_converter in config.feature_converters]

# Check if not empty
if not model_config_list:
Expand Down
Empty file modified sense/models.yml
100644 → 100755
Empty file.
Empty file modified sense/utils.py
100644 → 100755
Empty file.
Empty file modified setup.cfg
100644 → 100755
Empty file.
Empty file modified tests/resources/checkpoint_dir/best_classifier.checkpoint
100644 → 100755
Empty file.
Empty file modified tests/resources/checkpoint_dir/classifier.checkpoint
100644 → 100755
Empty file.
Empty file modified tests/resources/checkpoint_dir/label2int.json
100644 → 100755
Empty file.
Empty file modified tests/resources/test_video.mp4
100644 → 100755
Empty file.
Empty file modified tests/scripts/test_run_custom_classifier.sh
100644 → 100755
Empty file.
Empty file modified tests/test_display.py
100644 → 100755
Empty file.
Empty file modified tests/test_loading.py
100644 → 100755
Empty file.
Empty file modified tools/__init__.py
100644 → 100755
Empty file.
Empty file modified tools/conversion/cfg/efficientnet.cfg
100644 → 100755
Empty file.
Empty file modified tools/conversion/cfg/logistic_regression.cfg
100644 → 100755
Empty file.
Empty file modified tools/conversion/config_loader.py
100644 → 100755
Empty file.
Empty file modified tools/conversion/convert_to_tflite.py
100644 → 100755
Empty file.
Empty file modified tools/conversion/keras_converter.py
100644 → 100755
Empty file.
Empty file modified tools/conversion/keras_exporter.py
100644 → 100755
Empty file.
Empty file modified tools/conversion/section_conversion.py
100644 → 100755
Empty file.
Empty file modified tools/conversion/weights_loader.py
100644 → 100755
Empty file.
Empty file modified tools/flip_video.py
100644 → 100755
Empty file.
Empty file modified tools/run_custom_classifier.py
100644 → 100755
Empty file.
Empty file modified tools/sense_studio/.gitignore
100644 → 100755
Empty file.
Empty file modified tools/sense_studio/__init__.py
100644 → 100755
Empty file.
Empty file modified tools/sense_studio/annotation.py
100644 → 100755
Empty file.
Empty file modified tools/sense_studio/sense_studio.py
100644 → 100755
Empty file.
Empty file modified tools/sense_studio/static/main.css
100644 → 100755
Empty file.
Empty file modified tools/sense_studio/static/main.js
100644 → 100755
Empty file.
Empty file modified tools/sense_studio/static/sense_favicon.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified tools/sense_studio/static/sense_studio_logo.svg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified tools/sense_studio/static/video_recording.js
100644 → 100755
Empty file.
Empty file modified tools/sense_studio/templates/frame_annotation.html
100644 → 100755
Empty file.
Empty file modified tools/sense_studio/templates/navigation.html
100644 → 100755
Empty file.
Empty file modified tools/sense_studio/templates/project_details.html
100644 → 100755
Empty file.
Empty file modified tools/sense_studio/templates/projects_overview.html
100644 → 100755
Empty file.
Empty file modified tools/sense_studio/templates/skeleton.html
100644 → 100755
Empty file.
Empty file modified tools/sense_studio/templates/video_list.html
100644 → 100755
Empty file.
Empty file modified tools/sense_studio/templates/video_recording.html
100644 → 100755
Empty file.
Empty file modified tools/sense_studio/utils.py
100644 → 100755
Empty file.
Empty file modified tools/sense_studio/video_recording.py
100644 → 100755
Empty file.
Empty file modified tools/train_classifier.py
100644 → 100755
Empty file.
Empty file modified tools/video_capture.py
100644 → 100755
Empty file.