Parcourir la source

Add of extraction scripts

Jérôme BUISINE il y a 4 ans
Parent
commit
bdbafeb2ea
9 fichiers modifiés avec 305 ajouts et 0 suppressions
  1. 110 0
      .gitignore
  2. 6 0
      .gitmodules
  3. 21 0
      LICENSE
  4. 14 0
      README.md
  5. 62 0
      calibration_errors.py
  6. 18 0
      custom_config.py
  7. 70 0
      extractions/match_extracts_scene_mean.py
  8. 1 0
      modules
  9. 3 0
      requirements.txt

+ 110 - 0
.gitignore

@@ -0,0 +1,110 @@
+# Byte-compiled / optimized / DLL files
+__pycache__/
+*.py[cod]
+*$py.class
+
+# C extensions
+*.so
+
+# Distribution / packaging
+.Python
+build/
+develop-eggs/
+dist/
+downloads/
+eggs/
+.eggs/
+lib/
+lib64/
+parts/
+sdist/
+var/
+wheels/
+*.egg-info/
+.installed.cfg
+*.egg
+MANIFEST
+
+# PyInstaller
+#  Usually these files are written by a python script from a template
+#  before PyInstaller builds the exe, so as to inject date/other infos into it.
+*.manifest
+*.spec
+
+# Installer logs
+pip-log.txt
+pip-delete-this-directory.txt
+
+# Unit test / coverage reports
+htmlcov/
+.tox/
+.coverage
+.coverage.*
+.cache
+nosetests.xml
+coverage.xml
+*.cover
+.hypothesis/
+.pytest_cache/
+
+# Translations
+*.mo
+*.pot
+
+# Django stuff:
+*.log
+local_settings.py
+db.sqlite3
+
+# Flask stuff:
+instance/
+.webassets-cache
+
+# Scrapy stuff:
+.scrapy
+
+# Sphinx documentation
+docs/_build/
+
+# PyBuilder
+target/
+
+# Jupyter Notebook
+.ipynb_checkpoints
+
+# pyenv
+.python-version
+
+# celery beat schedule file
+celerybeat-schedule
+
+# SageMath parsed files
+*.sage.py
+
+# Environments
+.env
+.venv
+env/
+venv/
+ENV/
+env.bak/
+venv.bak/
+
+# Spyder project settings
+.spyderproject
+.spyproject
+
+# Rope project settings
+.ropeproject
+
+# mkdocs documentation
+/site
+
+# mypy
+.mypy_cache/
+
+# data folder
+links/data
+links/expe
+.vscode
+media

+ 6 - 0
.gitmodules

@@ -0,0 +1,6 @@
+[submodule "Thesis-CommonModules"]
+	path = Thesis-CommonModules
+	url = https://github.com/prise-3d/Thesis-CommonModules.git
+[submodule "modules"]
+	path = modules
+	url = https://github.com/prise-3d/Thesis-CommonModules.git

+ 21 - 0
LICENSE

@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2019 PrISE-3D
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.

+ 14 - 0
README.md

@@ -0,0 +1,14 @@
+# SIN3D-launcher
+
+## Description
+
+Project for analysis SIN3D experiments
+
+## How to use ?
+
+
+
+
+## Licence
+
+[The MIT license](LICENSE)

+ 62 - 0
calibration_errors.py

@@ -0,0 +1,62 @@
+# main imports
+import argparse
+import numpy as np
+import sys
+
+# mongo import
+from pymongo import MongoClient
+
+# modules imports
+sys.path.insert(0, '') # trick to enable import of main folder module
+
+# config imports
+import custom_config  as cfg
+
+def main():
+
+    parser = argparse.ArgumentParser(description="Get error during calibration experiment for each user")
+
+    parser.add_argument('--expeId', type=str, help='Experiment identifier')
+
+    args = parser.parse_args()
+
+    p_expe_id = args.expeId
+
+
+    # connect to Mongo db and collect data
+    client = MongoClient(cfg.default_host)
+    db = client.sin3d
+
+    query = {
+        'data.msg.experimentName': "CalibrationMeasurement", 
+        'data.msgId': "EXPERIMENT_VALIDATED"
+    }
+
+    # add of expeid into query if exists
+    if p_expe_id:
+        print("Expe id used", p_expe_id)
+        query['data.experimentId'] = p_expe_id
+
+    print(query)
+
+    res = db.datas.find(query)
+
+    zone_index = np.arange(16)
+    threshold_img = (zone_index / 15) * 100
+
+    print(threshold_img)
+
+    for cursor in res:
+        user_data = cursor['data']
+        user_id = user_data['userId']
+
+        experiment_user_thresholds = []
+        experiment_error_thresholds = []
+        for id, val in enumerate(user_data['msg']['extracts']):
+            experiment_user_thresholds.append(val['quality'])
+            experiment_error_thresholds.append((int(val['quality'] - threshold_img[id])))
+
+        print(user_id, experiment_user_thresholds, experiment_error_thresholds, np.mean(experiment_error_thresholds))
+
+if __name__== "__main__":
+    main()

+ 18 - 0
custom_config.py

@@ -0,0 +1,18 @@
+from modules.config.global_config import *
+
+# store all variables from global config
+context_vars = vars()
+
+# utils variables
+experiment_list = [
+    'MatchExtractsWithReference',
+    'AreSameImagesRandom',
+    'AreSameImagesReference',
+    'AreSameImagesReferenceOneExtract',
+    'PercentQualityRandom',
+    'IsImageCorrect',
+    'IsImageCorrectOneExtract'
+    'CalibrationMeasurement'
+]
+
+default_host = 'diran.univ-littoral.fr'

+ 70 - 0
extractions/match_extracts_scene_mean.py

@@ -0,0 +1,70 @@
+# main imports
+import argparse
+import numpy as np
+import sys
+
+# mongo import
+from pymongo import MongoClient
+
+# modules imports
+sys.path.insert(0, '') # trick to enable import of main folder module
+
+# config imports
+import custom_config  as cfg
+
+def main():
+
+    parser = argparse.ArgumentParser(description="Get error during calibration experiment for each user")
+
+    parser.add_argument('--expeId', type=str, help='Experiment identifier')
+    parser.add_argument('--experiment', type=str, help='Experiment name', choices=cfg.experiment_list, required=True)
+    parser.add_argument('--scene', type=str, help='Scene identifier to use', choices=cfg.scenes_indices)
+
+    args = parser.parse_args()
+
+    p_expe_id    = args.expeId
+    p_experiment = args.experiment
+    p_scene      = args.scene
+
+    # connect to Mongo db and collect data
+    client = MongoClient(cfg.default_host)
+    db = client.sin3d
+
+    query = {
+        'data.msg.experimentName': p_experiment, 
+        'data.msgId': "EXPERIMENT_VALIDATED"
+    }
+
+    # add of expeid into query if exists
+    if p_expe_id:
+        print("Expe id used", p_expe_id)
+        query['data.experimentId'] = p_expe_id
+
+    if p_scene:
+
+        index = cfg.scenes_indices.index(p_scene.strip())
+        scene_name = cfg.scenes_names[index]
+
+        print("Scene used", scene_name)
+        query['data.msg.sceneName'] = scene_name
+
+    print(query)
+
+    res = db.datas.find(query)
+
+    zone_index = np.arange(16)
+    threshold_img = (zone_index / 15) * 100
+
+    for cursor in res:
+        user_data = cursor['data']
+        user_id = user_data['userId']
+
+        experiment_user_thresholds = []
+        experiment_error_thresholds = []
+        for id, val in enumerate(user_data['msg']['extracts']):
+            experiment_user_thresholds.append(val['quality'])
+
+        print(user_id, experiment_user_thresholds)
+
+if __name__== "__main__":
+    main()

+ 1 - 0
modules

@@ -0,0 +1 @@
+Subproject commit 6b8f28e9e2b077269df746c2a819756b865bd4bb

+ 3 - 0
requirements.txt

@@ -0,0 +1,3 @@
+numpy
+requests
+pymongo