Π·Π΅ΡΠΊΠ°Π»ΠΎ ΠΈΠ·
https://github.com/ssciwr/AMMICO.git
synced 2025-10-29 21:16:06 +02:00
Deploying to gh-pages from @ ssciwr/AMMICO@42b6732308 π
ΠΡΠΎΡ ΠΊΠΎΠΌΠΌΠΈΡ ΡΠΎΠ΄Π΅ΡΠΆΠΈΡΡΡ Π²:
ΡΠΎΠ΄ΠΈΡΠ΅Π»Ρ
aa82c43cef
ΠΠΎΠΌΠΌΠΈΡ
883045706b
ΠΠ²ΠΎΠΈΡΠ½ΡΠ΅ Π΄Π°Π½Π½ΡΠ΅
build/doctrees/ammico.doctree
ΠΠ²ΠΎΠΈΡΠ½ΡΠ΅ Π΄Π°Π½Π½ΡΠ΅
build/doctrees/ammico.doctree
ΠΠ²ΠΎΠΈΡΠ½ΡΠΉ ΡΠ°ΠΉΠ» Π½Π΅ ΠΎΡΠΎΠ±ΡΠ°ΠΆΠ°Π΅ΡΡΡ.
ΠΠ²ΠΎΠΈΡΠ½ΡΠ΅ Π΄Π°Π½Π½ΡΠ΅
build/doctrees/environment.pickle
ΠΠ²ΠΎΠΈΡΠ½ΡΠ΅ Π΄Π°Π½Π½ΡΠ΅
build/doctrees/environment.pickle
ΠΠ²ΠΎΠΈΡΠ½ΡΠΉ ΡΠ°ΠΉΠ» Π½Π΅ ΠΎΡΠΎΠ±ΡΠ°ΠΆΠ°Π΅ΡΡΡ.
@ -845,7 +845,7 @@
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Detection of faces and facial expression analysis\n",
|
||||
"Faces and facial expressions are detected and analyzed using the `EmotionDetector` class from the `faces` module. Initially, it is detected if faces are present on the image using RetinaFace, followed by analysis if face masks are worn (Face-Mask-Detection). The detection of age, gender, race, and emotions is carried out with deepface, but only if the disclosure statement has been accepted (see above).\n",
|
||||
"Faces and facial expressions are detected and analyzed using the `EmotionDetector` class from the `faces` module. Initially, it is detected if faces are present on the image using RetinaFace, followed by analysis if face masks are worn (Face-Mask-Detection). The probabilistic detection of age, gender, race, and emotions is carried out with deepface, but only if the disclosure statement has been accepted (see above).\n",
|
||||
"\n",
|
||||
"<img src=\"../_static/emotion_detector.png\" width=\"800\" />\n",
|
||||
"\n",
|
||||
@ -855,13 +855,13 @@
|
||||
"\n",
|
||||
"From the seven facial expressions, an overall dominating emotion category is identified: negative, positive, or neutral emotion. These are defined with the facial expressions angry, disgust, fear and sad for the negative category, happy for the positive category, and surprise and neutral for the neutral category.\n",
|
||||
"\n",
|
||||
"A similar threshold as for the emotion recognition is set for the race/ethnicity detection, `race_threshold`, with the default set to 50% so that a confidence for the race above 0.5 only will return a value in the analysis. \n",
|
||||
"A similar threshold as for the emotion recognition is set for the race/ethnicity and gender detection, `race_threshold` and `gender_threshold`, with the default set to 50% so that a confidence for race / gender above 0.5 only will return a value in the analysis.\n",
|
||||
"\n",
|
||||
"Gender and age probabilistic detection do not allow access to the confidence value, so that no threshold can be set for these.\n",
|
||||
"For age unfortunately no confidence value is accessible so that no threshold values can be set for this type of analysis. The [reported MAE of the model is ± 4.65](https://sefiks.com/2019/02/13/apparent-age-and-gender-prediction-in-keras/).\n",
|
||||
"\n",
|
||||
"You may also pass the name of the environment variable that determines if you accept or reject the ethical disclosure statement. By default, the variable is named `DISCLOSURE_AMMICO`.\n",
|
||||
"\n",
|
||||
"Summarizing, the face detection is carried out using the following method call and keywords, where `emotion_threshold`, `race_threshold`, `accept_disclosure` are optional:"
|
||||
"Summarizing, the face detection is carried out using the following method call and keywords, where `emotion_threshold`, `race_threshold`, `gender_threshold`, `accept_disclosure` are optional:"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -872,6 +872,7 @@
|
||||
"source": [
|
||||
"for key in image_dict.keys():\n",
|
||||
" image_dict[key] = ammico.EmotionDetector(image_dict[key], emotion_threshold=50, race_threshold=50,\n",
|
||||
" gender_threshold=50,\n",
|
||||
" accept_disclosure=\"DISCLOSURE_AMMICO\").analyse_image()"
|
||||
]
|
||||
},
|
||||
|
||||
ΠΠ²ΠΎΠΈΡΠ½ΡΠ΅ Π΄Π°Π½Π½ΡΠ΅
build/doctrees/notebooks/DemoNotebook_ammico.doctree
ΠΠ²ΠΎΠΈΡΠ½ΡΠ΅ Π΄Π°Π½Π½ΡΠ΅
build/doctrees/notebooks/DemoNotebook_ammico.doctree
ΠΠ²ΠΎΠΈΡΠ½ΡΠΉ ΡΠ°ΠΉΠ» Π½Π΅ ΠΎΡΠΎΠ±ΡΠ°ΠΆΠ°Π΅ΡΡΡ.
ΠΠ²ΠΎΠΈΡΠ½ΡΠ΅ Π΄Π°Π½Π½ΡΠ΅
build/doctrees/readme_link.doctree
ΠΠ²ΠΎΠΈΡΠ½ΡΠ΅ Π΄Π°Π½Π½ΡΠ΅
build/doctrees/readme_link.doctree
ΠΠ²ΠΎΠΈΡΠ½ΡΠΉ ΡΠ°ΠΉΠ» Π½Π΅ ΠΎΡΠΎΠ±ΡΠ°ΠΆΠ°Π΅ΡΡΡ.
@ -845,7 +845,7 @@
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Detection of faces and facial expression analysis\n",
|
||||
"Faces and facial expressions are detected and analyzed using the `EmotionDetector` class from the `faces` module. Initially, it is detected if faces are present on the image using RetinaFace, followed by analysis if face masks are worn (Face-Mask-Detection). The detection of age, gender, race, and emotions is carried out with deepface, but only if the disclosure statement has been accepted (see above).\n",
|
||||
"Faces and facial expressions are detected and analyzed using the `EmotionDetector` class from the `faces` module. Initially, it is detected if faces are present on the image using RetinaFace, followed by analysis if face masks are worn (Face-Mask-Detection). The probabilistic detection of age, gender, race, and emotions is carried out with deepface, but only if the disclosure statement has been accepted (see above).\n",
|
||||
"\n",
|
||||
"<img src=\"../_static/emotion_detector.png\" width=\"800\" />\n",
|
||||
"\n",
|
||||
@ -855,13 +855,13 @@
|
||||
"\n",
|
||||
"From the seven facial expressions, an overall dominating emotion category is identified: negative, positive, or neutral emotion. These are defined with the facial expressions angry, disgust, fear and sad for the negative category, happy for the positive category, and surprise and neutral for the neutral category.\n",
|
||||
"\n",
|
||||
"A similar threshold as for the emotion recognition is set for the race/ethnicity detection, `race_threshold`, with the default set to 50% so that a confidence for the race above 0.5 only will return a value in the analysis. \n",
|
||||
"A similar threshold as for the emotion recognition is set for the race/ethnicity and gender detection, `race_threshold` and `gender_threshold`, with the default set to 50% so that a confidence for race / gender above 0.5 only will return a value in the analysis.\n",
|
||||
"\n",
|
||||
"Gender and age probabilistic detection do not allow access to the confidence value, so that no threshold can be set for these.\n",
|
||||
"For age unfortunately no confidence value is accessible so that no threshold values can be set for this type of analysis. The [reported MAE of the model is ± 4.65](https://sefiks.com/2019/02/13/apparent-age-and-gender-prediction-in-keras/).\n",
|
||||
"\n",
|
||||
"You may also pass the name of the environment variable that determines if you accept or reject the ethical disclosure statement. By default, the variable is named `DISCLOSURE_AMMICO`.\n",
|
||||
"\n",
|
||||
"Summarizing, the face detection is carried out using the following method call and keywords, where `emotion_threshold`, `race_threshold`, `accept_disclosure` are optional:"
|
||||
"Summarizing, the face detection is carried out using the following method call and keywords, where `emotion_threshold`, `race_threshold`, `gender_threshold`, `accept_disclosure` are optional:"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -872,6 +872,7 @@
|
||||
"source": [
|
||||
"for key in image_dict.keys():\n",
|
||||
" image_dict[key] = ammico.EmotionDetector(image_dict[key], emotion_threshold=50, race_threshold=50,\n",
|
||||
" gender_threshold=50,\n",
|
||||
" accept_disclosure=\"DISCLOSURE_AMMICO\").analyse_image()"
|
||||
]
|
||||
},
|
||||
|
||||
@ -190,7 +190,6 @@
|
||||
</li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#utils.ammico_prefetch_models"><code class="docutils literal notranslate"><span class="pre">ammico_prefetch_models()</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#utils.append_data_to_dict"><code class="docutils literal notranslate"><span class="pre">append_data_to_dict()</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#utils.check_for_missing_keys"><code class="docutils literal notranslate"><span class="pre">check_for_missing_keys()</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#utils.dump_df"><code class="docutils literal notranslate"><span class="pre">dump_df()</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#utils.find_files"><code class="docutils literal notranslate"><span class="pre">find_files()</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#utils.get_color_table"><code class="docutils literal notranslate"><span class="pre">get_color_table()</span></code></a></li>
|
||||
@ -1188,7 +1187,7 @@
|
||||
<span id="faces-module"></span><h1>faces module<a class="headerlink" href="#module-faces" title="Link to this heading">ο</a></h1>
|
||||
<dl class="py class">
|
||||
<dt class="sig sig-object py" id="faces.EmotionDetector">
|
||||
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">faces.</span></span><span class="sig-name descname"><span class="pre">EmotionDetector</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">subdict</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">dict</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">emotion_threshold</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">float</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">50.0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">race_threshold</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">float</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">50.0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">accept_disclosure</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">'DISCLOSURE_AMMICO'</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#faces.EmotionDetector" title="Link to this definition">ο</a></dt>
|
||||
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">faces.</span></span><span class="sig-name descname"><span class="pre">EmotionDetector</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">subdict</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">dict</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">emotion_threshold</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">float</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">50.0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">race_threshold</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">float</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">50.0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">gender_threshold</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">float</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">50.0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">accept_disclosure</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">'DISCLOSURE_AMMICO'</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#faces.EmotionDetector" title="Link to this definition">ο</a></dt>
|
||||
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">AnalysisMethod</span></code></p>
|
||||
<dl class="py method">
|
||||
<dt class="sig sig-object py" id="faces.EmotionDetector.analyse_image">
|
||||
@ -1204,7 +1203,7 @@
|
||||
<dl class="py method">
|
||||
<dt class="sig sig-object py" id="faces.EmotionDetector.analyze_single_face">
|
||||
<span class="sig-name descname"><span class="pre">analyze_single_face</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">face</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">ndarray</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">→</span> <span class="sig-return-typehint"><span class="pre">dict</span></span></span><a class="headerlink" href="#faces.EmotionDetector.analyze_single_face" title="Link to this definition">ο</a></dt>
|
||||
<dd><p>Analyzes the features of a single face.</p>
|
||||
<dd><p>Analyzes the features of a single face on the image.</p>
|
||||
<dl class="field-list simple">
|
||||
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
||||
<dd class="field-odd"><p><strong>face</strong> (<em>np.ndarray</em>) β The face image array.</p>
|
||||
@ -1563,20 +1562,6 @@ ammico_prefetch_models.</p>
|
||||
<dd><p>Append entries from nested dictionaries to keys in a global dict.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py function">
|
||||
<dt class="sig sig-object py" id="utils.check_for_missing_keys">
|
||||
<span class="sig-prename descclassname"><span class="pre">utils.</span></span><span class="sig-name descname"><span class="pre">check_for_missing_keys</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">mydict</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">dict</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">→</span> <span class="sig-return-typehint"><span class="pre">dict</span></span></span><a class="headerlink" href="#utils.check_for_missing_keys" title="Link to this definition">ο</a></dt>
|
||||
<dd><p>Check the nested dictionary for any missing keys in the subdicts.</p>
|
||||
<dl class="field-list simple">
|
||||
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
||||
<dd class="field-odd"><p><strong>mydict</strong> (<em>dict</em>) β The nested dictionary with keys to check.</p>
|
||||
</dd>
|
||||
<dt class="field-even">Returns<span class="colon">:</span></dt>
|
||||
<dd class="field-even"><p><strong>dict</strong> β The dictionary with keys appended.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py function">
|
||||
<dt class="sig sig-object py" id="utils.dump_df">
|
||||
<span class="sig-prename descclassname"><span class="pre">utils.</span></span><span class="sig-name descname"><span class="pre">dump_df</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">mydict</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">dict</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">→</span> <span class="sig-return-typehint"><span class="pre">DataFrame</span></span></span><a class="headerlink" href="#utils.dump_df" title="Link to this definition">ο</a></dt>
|
||||
|
||||
@ -150,8 +150,6 @@
|
||||
<h2 id="C">C</h2>
|
||||
<table style="width: 100%" class="indextable genindextable"><tr>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="ammico.html#utils.check_for_missing_keys">check_for_missing_keys() (in module utils)</a>
|
||||
</li>
|
||||
<li><a href="ammico.html#summary.SummaryDetector.check_model">check_model() (summary.SummaryDetector method)</a>
|
||||
</li>
|
||||
<li><a href="ammico.html#faces.EmotionDetector.clean_subdict">clean_subdict() (faces.EmotionDetector method)</a>
|
||||
@ -167,10 +165,10 @@
|
||||
<li><a href="ammico.html#module-colors">module</a>
|
||||
</li>
|
||||
</ul></li>
|
||||
</ul></td>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="ammico.html#cropposts.compute_crop_corner">compute_crop_corner() (in module cropposts)</a>
|
||||
</li>
|
||||
</ul></td>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="ammico.html#multimodal_search.MultimodalSearch.compute_gradcam_batch">compute_gradcam_batch() (multimodal_search.MultimodalSearch method)</a>
|
||||
</li>
|
||||
<li><a href="ammico.html#cropposts.crop_image_from_post">crop_image_from_post() (in module cropposts)</a>
|
||||
|
||||
@ -231,7 +231,6 @@
|
||||
</li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="ammico.html#utils.ammico_prefetch_models"><code class="docutils literal notranslate"><span class="pre">ammico_prefetch_models()</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="ammico.html#utils.append_data_to_dict"><code class="docutils literal notranslate"><span class="pre">append_data_to_dict()</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="ammico.html#utils.check_for_missing_keys"><code class="docutils literal notranslate"><span class="pre">check_for_missing_keys()</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="ammico.html#utils.dump_df"><code class="docutils literal notranslate"><span class="pre">dump_df()</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="ammico.html#utils.find_files"><code class="docutils literal notranslate"><span class="pre">find_files()</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="ammico.html#utils.get_color_table"><code class="docutils literal notranslate"><span class="pre">get_color_table()</span></code></a></li>
|
||||
|
||||
@ -493,7 +493,7 @@ directly on the right next to the image. This way, the user can directly inspect
|
||||
<section id="The-detector-modules">
|
||||
<h1>The detector modules<a class="headerlink" href="#The-detector-modules" title="Link to this heading">ο</a></h1>
|
||||
<p>The different detector modules with their options are explained in more detail in this section. ## Text detector Text on the images can be extracted using the <code class="docutils literal notranslate"><span class="pre">TextDetector</span></code> class (<code class="docutils literal notranslate"><span class="pre">text</span></code> module). The text is initally extracted using the Google Cloud Vision API and then translated into English with googletrans. The translated text is cleaned of whitespace, linebreaks, and numbers using Python syntax and spaCy.</p>
|
||||
<p><img alt="9aef17316ccf4f19b43e0b932d59111b" class="no-scaled-link" src="../_images/text_detector.png" style="width: 800px;" /></p>
|
||||
<p><img alt="90be7c015e304097993d21d99303c896" class="no-scaled-link" src="../_images/text_detector.png" style="width: 800px;" /></p>
|
||||
<p>The user can set if the text should be further summarized, and analyzed for sentiment and named entity recognition, by setting the keyword <code class="docutils literal notranslate"><span class="pre">analyse_text</span></code> to <code class="docutils literal notranslate"><span class="pre">True</span></code> (the default is <code class="docutils literal notranslate"><span class="pre">False</span></code>). If set, the transformers pipeline is used for each of these tasks, with the default models as of 03/2023. Other models can be selected by setting the optional keyword <code class="docutils literal notranslate"><span class="pre">model_names</span></code> to a list of selected models, on for each task:
|
||||
<code class="docutils literal notranslate"><span class="pre">model_names=["sshleifer/distilbart-cnn-12-6",</span> <span class="pre">"distilbert-base-uncased-finetuned-sst-2-english",</span> <span class="pre">"dbmdz/bert-large-cased-finetuned-conll03-english"]</span></code> for summary, sentiment, and ner. To be even more specific, revision numbers can also be selected by specifying the optional keyword <code class="docutils literal notranslate"><span class="pre">revision_numbers</span></code> to a list of revision numbers for each model, for example <code class="docutils literal notranslate"><span class="pre">revision_numbers=["a4f8f3e",</span> <span class="pre">"af0f99b",</span> <span class="pre">"f2482bf"]</span></code>.</p>
|
||||
<p>Please note that for the Google Cloud Vision API (the TextDetector class) you need to set a key in order to process the images. This key is ideally set as an environment variable using for example</p>
|
||||
@ -575,7 +575,7 @@ directly on the right next to the image. This way, the user can directly inspect
|
||||
<section id="Image-summary-and-query">
|
||||
<h2>Image summary and query<a class="headerlink" href="#Image-summary-and-query" title="Link to this heading">ο</a></h2>
|
||||
<p>The <code class="docutils literal notranslate"><span class="pre">SummaryDetector</span></code> can be used to generate image captions (<code class="docutils literal notranslate"><span class="pre">summary</span></code>) as well as visual question answering (<code class="docutils literal notranslate"><span class="pre">VQA</span></code>).</p>
|
||||
<p><img alt="6cb54833a42b4b89b389ddc8f34fe6e9" class="no-scaled-link" src="../_images/summary_detector.png" style="width: 800px;" /></p>
|
||||
<p><img alt="339c0fa2d41c45eb83986c95afad7426" class="no-scaled-link" src="../_images/summary_detector.png" style="width: 800px;" /></p>
|
||||
<p>This module is based on the <a class="reference external" href="https://github.com/salesforce/LAVIS">LAVIS</a> library. Since the models can be quite large, an initial object is created which will load the necessary models into RAM/VRAM and then use them in the analysis. The user can specify the type of analysis to be performed using the <code class="docutils literal notranslate"><span class="pre">analysis_type</span></code> keyword. Setting it to <code class="docutils literal notranslate"><span class="pre">summary</span></code> will generate a caption (summary), <code class="docutils literal notranslate"><span class="pre">questions</span></code> will prepare answers (VQA) to a list of questions as set by the user,
|
||||
<code class="docutils literal notranslate"><span class="pre">summary_and_questions</span></code> will do both. Note that the desired analysis type needs to be set here in the initialization of the detector object, and not when running the analysis for each image; the same holds true for the selected model.</p>
|
||||
<p>The implemented models are listed below.</p>
|
||||
@ -827,24 +827,25 @@ directly on the right next to the image. This way, the user can directly inspect
|
||||
</section>
|
||||
<section id="Detection-of-faces-and-facial-expression-analysis">
|
||||
<h2>Detection of faces and facial expression analysis<a class="headerlink" href="#Detection-of-faces-and-facial-expression-analysis" title="Link to this heading">ο</a></h2>
|
||||
<p>Faces and facial expressions are detected and analyzed using the <code class="docutils literal notranslate"><span class="pre">EmotionDetector</span></code> class from the <code class="docutils literal notranslate"><span class="pre">faces</span></code> module. Initially, it is detected if faces are present on the image using RetinaFace, followed by analysis if face masks are worn (Face-Mask-Detection). The detection of age, gender, race, and emotions is carried out with deepface, but only if the disclosure statement has been accepted (see above).</p>
|
||||
<p><img alt="d19f2be1c6a44bf68f8e1afc73fff668" class="no-scaled-link" src="../_images/emotion_detector.png" style="width: 800px;" /></p>
|
||||
<p>Faces and facial expressions are detected and analyzed using the <code class="docutils literal notranslate"><span class="pre">EmotionDetector</span></code> class from the <code class="docutils literal notranslate"><span class="pre">faces</span></code> module. Initially, it is detected if faces are present on the image using RetinaFace, followed by analysis if face masks are worn (Face-Mask-Detection). The probabilistic detection of age, gender, race, and emotions is carried out with deepface, but only if the disclosure statement has been accepted (see above).</p>
|
||||
<p><img alt="ac82b635c13540078d8dda8f36bb0c2d" class="no-scaled-link" src="../_images/emotion_detector.png" style="width: 800px;" /></p>
|
||||
<p>Depending on the features found on the image, the face detection module returns a different analysis content: If no faces are found on the image, all further steps are skipped and the result <code class="docutils literal notranslate"><span class="pre">"face":</span> <span class="pre">"No",</span> <span class="pre">"multiple_faces":</span> <span class="pre">"No",</span> <span class="pre">"no_faces":</span> <span class="pre">0,</span> <span class="pre">"wears_mask":</span> <span class="pre">["No"],</span> <span class="pre">"age":</span> <span class="pre">[None],</span> <span class="pre">"gender":</span> <span class="pre">[None],</span> <span class="pre">"race":</span> <span class="pre">[None],</span> <span class="pre">"emotion":</span> <span class="pre">[None],</span> <span class="pre">"emotion</span> <span class="pre">(category)":</span> <span class="pre">[None]</span></code> is returned. If one or several faces are found, up to three faces are analyzed if they are partially concealed by a face mask. If
|
||||
yes, only age and gender are detected; if no, also race, emotion, and dominant emotion are detected. In case of the latter, the output could look like this: <code class="docutils literal notranslate"><span class="pre">"face":</span> <span class="pre">"Yes",</span> <span class="pre">"multiple_faces":</span> <span class="pre">"Yes",</span> <span class="pre">"no_faces":</span> <span class="pre">2,</span> <span class="pre">"wears_mask":</span> <span class="pre">["No",</span> <span class="pre">"No"],</span> <span class="pre">"age":</span> <span class="pre">[27,</span> <span class="pre">28],</span> <span class="pre">"gender":</span> <span class="pre">["Man",</span> <span class="pre">"Man"],</span> <span class="pre">"race":</span> <span class="pre">["asian",</span> <span class="pre">None],</span> <span class="pre">"emotion":</span> <span class="pre">["angry",</span> <span class="pre">"neutral"],</span> <span class="pre">"emotion</span> <span class="pre">(category)":</span> <span class="pre">["Negative",</span> <span class="pre">"Neutral"]</span></code>, where for the two faces that are detected (given by <code class="docutils literal notranslate"><span class="pre">no_faces</span></code>), some of the values are returned as a list
|
||||
with the first item for the first (largest) face and the second item for the second (smaller) face (for example, <code class="docutils literal notranslate"><span class="pre">"emotion"</span></code> returns a list <code class="docutils literal notranslate"><span class="pre">["angry",</span> <span class="pre">"neutral"]</span></code> signifying the first face expressing anger, and the second face having a neutral expression).</p>
|
||||
<p>The emotion detection reports the seven facial expressions angry, fear, neutral, sad, disgust, happy and surprise. These emotions are assigned based on the returned confidence of the model (between 0 and 1), with a high confidence signifying a high likelihood of the detected emotion being correct. Emotion recognition is not an easy task, even for a human; therefore, we have added a keyword <code class="docutils literal notranslate"><span class="pre">emotion_threshold</span></code> signifying the % value above which an emotion is counted as being detected. The
|
||||
default is set to 50%, so that a confidence above 0.5 results in an emotion being assigned. If the confidence is lower, no emotion is assigned.</p>
|
||||
<p>From the seven facial expressions, an overall dominating emotion category is identified: negative, positive, or neutral emotion. These are defined with the facial expressions angry, disgust, fear and sad for the negative category, happy for the positive category, and surprise and neutral for the neutral category.</p>
|
||||
<p>A similar threshold as for the emotion recognition is set for the race/ethnicity detection, <code class="docutils literal notranslate"><span class="pre">race_threshold</span></code>, with the default set to 50% so that a confidence for the race above 0.5 only will return a value in the analysis.</p>
|
||||
<p>Gender and age probabilistic detection do not allow access to the confidence value, so that no threshold can be set for these.</p>
|
||||
<p>A similar threshold as for the emotion recognition is set for the race/ethnicity and gender detection, <code class="docutils literal notranslate"><span class="pre">race_threshold</span></code> and <code class="docutils literal notranslate"><span class="pre">gender_threshold</span></code>, with the default set to 50% so that a confidence for race / gender above 0.5 only will return a value in the analysis.</p>
|
||||
<p>For age unfortunately no confidence value is accessible so that no threshold values can be set for this type of analysis. The <a class="reference external" href="https://sefiks.com/2019/02/13/apparent-age-and-gender-prediction-in-keras/">reported MAE of the model is Β± 4.65</a>.</p>
|
||||
<p>You may also pass the name of the environment variable that determines if you accept or reject the ethical disclosure statement. By default, the variable is named <code class="docutils literal notranslate"><span class="pre">DISCLOSURE_AMMICO</span></code>.</p>
|
||||
<p>Summarizing, the face detection is carried out using the following method call and keywords, where <code class="docutils literal notranslate"><span class="pre">emotion_threshold</span></code>, <code class="docutils literal notranslate"><span class="pre">race_threshold</span></code>, <code class="docutils literal notranslate"><span class="pre">accept_disclosure</span></code> are optional:</p>
|
||||
<p>Summarizing, the face detection is carried out using the following method call and keywords, where <code class="docutils literal notranslate"><span class="pre">emotion_threshold</span></code>, <code class="docutils literal notranslate"><span class="pre">race_threshold</span></code>, <code class="docutils literal notranslate"><span class="pre">gender_threshold</span></code>, <code class="docutils literal notranslate"><span class="pre">accept_disclosure</span></code> are optional:</p>
|
||||
<div class="nbinput nblast docutils container">
|
||||
<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[ ]:
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">image_dict</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span>
|
||||
<span class="n">image_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">ammico</span><span class="o">.</span><span class="n">EmotionDetector</span><span class="p">(</span><span class="n">image_dict</span><span class="p">[</span><span class="n">key</span><span class="p">],</span> <span class="n">emotion_threshold</span><span class="o">=</span><span class="mi">50</span><span class="p">,</span> <span class="n">race_threshold</span><span class="o">=</span><span class="mi">50</span><span class="p">,</span>
|
||||
<span class="n">gender_threshold</span><span class="o">=</span><span class="mi">50</span><span class="p">,</span>
|
||||
<span class="n">accept_disclosure</span><span class="o">=</span><span class="s2">"DISCLOSURE_AMMICO"</span><span class="p">)</span><span class="o">.</span><span class="n">analyse_image</span><span class="p">()</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
|
||||
@ -845,7 +845,7 @@
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Detection of faces and facial expression analysis\n",
|
||||
"Faces and facial expressions are detected and analyzed using the `EmotionDetector` class from the `faces` module. Initially, it is detected if faces are present on the image using RetinaFace, followed by analysis if face masks are worn (Face-Mask-Detection). The detection of age, gender, race, and emotions is carried out with deepface, but only if the disclosure statement has been accepted (see above).\n",
|
||||
"Faces and facial expressions are detected and analyzed using the `EmotionDetector` class from the `faces` module. Initially, it is detected if faces are present on the image using RetinaFace, followed by analysis if face masks are worn (Face-Mask-Detection). The probabilistic detection of age, gender, race, and emotions is carried out with deepface, but only if the disclosure statement has been accepted (see above).\n",
|
||||
"\n",
|
||||
"<img src=\"../_static/emotion_detector.png\" width=\"800\" />\n",
|
||||
"\n",
|
||||
@ -855,13 +855,13 @@
|
||||
"\n",
|
||||
"From the seven facial expressions, an overall dominating emotion category is identified: negative, positive, or neutral emotion. These are defined with the facial expressions angry, disgust, fear and sad for the negative category, happy for the positive category, and surprise and neutral for the neutral category.\n",
|
||||
"\n",
|
||||
"A similar threshold as for the emotion recognition is set for the race/ethnicity detection, `race_threshold`, with the default set to 50% so that a confidence for the race above 0.5 only will return a value in the analysis. \n",
|
||||
"A similar threshold as for the emotion recognition is set for the race/ethnicity and gender detection, `race_threshold` and `gender_threshold`, with the default set to 50% so that a confidence for race / gender above 0.5 only will return a value in the analysis.\n",
|
||||
"\n",
|
||||
"Gender and age probabilistic detection do not allow access to the confidence value, so that no threshold can be set for these.\n",
|
||||
"For age unfortunately no confidence value is accessible so that no threshold values can be set for this type of analysis. The [reported MAE of the model is ± 4.65](https://sefiks.com/2019/02/13/apparent-age-and-gender-prediction-in-keras/).\n",
|
||||
"\n",
|
||||
"You may also pass the name of the environment variable that determines if you accept or reject the ethical disclosure statement. By default, the variable is named `DISCLOSURE_AMMICO`.\n",
|
||||
"\n",
|
||||
"Summarizing, the face detection is carried out using the following method call and keywords, where `emotion_threshold`, `race_threshold`, `accept_disclosure` are optional:"
|
||||
"Summarizing, the face detection is carried out using the following method call and keywords, where `emotion_threshold`, `race_threshold`, `gender_threshold`, `accept_disclosure` are optional:"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -872,6 +872,7 @@
|
||||
"source": [
|
||||
"for key in image_dict.keys():\n",
|
||||
" image_dict[key] = ammico.EmotionDetector(image_dict[key], emotion_threshold=50, race_threshold=50,\n",
|
||||
" gender_threshold=50,\n",
|
||||
" accept_disclosure=\"DISCLOSURE_AMMICO\").analyse_image()"
|
||||
]
|
||||
},
|
||||
|
||||
ΠΠ²ΠΎΠΈΡΠ½ΡΠ΅ Π΄Π°Π½Π½ΡΠ΅
build/html/objects.inv
ΠΠ²ΠΎΠΈΡΠ½ΡΠ΅ Π΄Π°Π½Π½ΡΠ΅
build/html/objects.inv
ΠΠ²ΠΎΠΈΡΠ½ΡΠΉ ΡΠ°ΠΉΠ» Π½Π΅ ΠΎΡΠΎΠ±ΡΠ°ΠΆΠ°Π΅ΡΡΡ.
@ -140,7 +140,7 @@
|
||||
<li><p>Performing person and face recognition in images</p>
|
||||
<ol class="arabic simple">
|
||||
<li><p>Face mask detection</p></li>
|
||||
<li><p>Probabilistic detection of age, gender and race detection</p></li>
|
||||
<li><p>Probabilistic detection of age, gender and race</p></li>
|
||||
<li><p>Emotion recognition</p></li>
|
||||
</ol>
|
||||
</li>
|
||||
|
||||
Π Π°Π·Π»ΠΈΡΠΈΡ ΡΠ°ΠΉΠ»ΠΎΠ² ΡΠΊΡΡΡΡ, ΠΏΠΎΡΠΎΠΌΡ ΡΡΠΎ ΠΎΠ΄Π½Π° ΠΈΠ»ΠΈ Π½Π΅ΡΠΊΠΎΠ»ΡΠΊΠΎ ΡΡΡΠΎΠΊ ΡΠ»ΠΈΡΠΊΠΎΠΌ Π΄Π»ΠΈΠ½Π½Ρ
@ -845,7 +845,7 @@
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Detection of faces and facial expression analysis\n",
|
||||
"Faces and facial expressions are detected and analyzed using the `EmotionDetector` class from the `faces` module. Initially, it is detected if faces are present on the image using RetinaFace, followed by analysis if face masks are worn (Face-Mask-Detection). The detection of age, gender, race, and emotions is carried out with deepface, but only if the disclosure statement has been accepted (see above).\n",
|
||||
"Faces and facial expressions are detected and analyzed using the `EmotionDetector` class from the `faces` module. Initially, it is detected if faces are present on the image using RetinaFace, followed by analysis if face masks are worn (Face-Mask-Detection). The probabilistic detection of age, gender, race, and emotions is carried out with deepface, but only if the disclosure statement has been accepted (see above).\n",
|
||||
"\n",
|
||||
"<img src=\"../_static/emotion_detector.png\" width=\"800\" />\n",
|
||||
"\n",
|
||||
@ -855,13 +855,13 @@
|
||||
"\n",
|
||||
"From the seven facial expressions, an overall dominating emotion category is identified: negative, positive, or neutral emotion. These are defined with the facial expressions angry, disgust, fear and sad for the negative category, happy for the positive category, and surprise and neutral for the neutral category.\n",
|
||||
"\n",
|
||||
"A similar threshold as for the emotion recognition is set for the race/ethnicity detection, `race_threshold`, with the default set to 50% so that a confidence for the race above 0.5 only will return a value in the analysis. \n",
|
||||
"A similar threshold as for the emotion recognition is set for the race/ethnicity and gender detection, `race_threshold` and `gender_threshold`, with the default set to 50% so that a confidence for race / gender above 0.5 only will return a value in the analysis.\n",
|
||||
"\n",
|
||||
"Gender and age probabilistic detection do not allow access to the confidence value, so that no threshold can be set for these.\n",
|
||||
"For age unfortunately no confidence value is accessible so that no threshold values can be set for this type of analysis. The [reported MAE of the model is ± 4.65](https://sefiks.com/2019/02/13/apparent-age-and-gender-prediction-in-keras/).\n",
|
||||
"\n",
|
||||
"You may also pass the name of the environment variable that determines if you accept or reject the ethical disclosure statement. By default, the variable is named `DISCLOSURE_AMMICO`.\n",
|
||||
"\n",
|
||||
"Summarizing, the face detection is carried out using the following method call and keywords, where `emotion_threshold`, `race_threshold`, `accept_disclosure` are optional:"
|
||||
"Summarizing, the face detection is carried out using the following method call and keywords, where `emotion_threshold`, `race_threshold`, `gender_threshold`, `accept_disclosure` are optional:"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -872,6 +872,7 @@
|
||||
"source": [
|
||||
"for key in image_dict.keys():\n",
|
||||
" image_dict[key] = ammico.EmotionDetector(image_dict[key], emotion_threshold=50, race_threshold=50,\n",
|
||||
" gender_threshold=50,\n",
|
||||
" accept_disclosure=\"DISCLOSURE_AMMICO\").analyse_image()"
|
||||
]
|
||||
},
|
||||
|
||||
ΠΠ°Π³ΡΡΠ·ΠΊΠ°β¦
x
Π‘ΡΡΠ»ΠΊΠ° Π² Π½ΠΎΠ²ΠΎΠΉ Π·Π°Π΄Π°ΡΠ΅
Block a user