зеркало из
https://github.com/ssciwr/AMMICO.git
synced 2025-10-30 13:36:04 +02:00
more cleanup
Этот коммит содержится в:
родитель
4ba8b43659
Коммит
1839e98107
@ -146,7 +146,9 @@ def crop_posts_image(
|
|||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
get file lists from dir and sub dirs
|
get file lists from dir and sub dirs
|
||||||
ref_view:ref_view for crop the posts images
|
|
||||||
|
|
||||||
|
ref_view: ref_view for crop the posts images
|
||||||
view: posts image that need cropping
|
view: posts image that need cropping
|
||||||
rte: None - not cropped, or (crop_view, number of matches)
|
rte: None - not cropped, or (crop_view, number of matches)
|
||||||
"""
|
"""
|
||||||
@ -185,7 +187,7 @@ def crop_posts_image(
|
|||||||
def get_file_list(dir, filelist, ext=None, convert_unix=True):
|
def get_file_list(dir, filelist, ext=None, convert_unix=True):
|
||||||
"""
|
"""
|
||||||
get file lists from dir and sub dirs
|
get file lists from dir and sub dirs
|
||||||
dir:root dir for file lists
|
dir: root dir for file lists
|
||||||
ext: file extension
|
ext: file extension
|
||||||
rte: File list
|
rte: File list
|
||||||
"""
|
"""
|
||||||
@ -252,11 +254,9 @@ def crop_posts_from_files(
|
|||||||
|
|
||||||
def test_crop_from_file():
|
def test_crop_from_file():
|
||||||
# Load images
|
# Load images
|
||||||
# view1 = np.array(Image.open("data/ref/ref-00.png")) / 255
|
|
||||||
# view2 = np.array(Image.open("data/napsa/100539_ben.png")) / 255
|
|
||||||
view1 = np.array(Image.open("data/ref/ref-06.png"))
|
view1 = np.array(Image.open("data/ref/ref-06.png"))
|
||||||
view2 = np.array(Image.open("data/napsa/102956_eng.png"))
|
view2 = np.array(Image.open("data/napsa/102956_eng.png"))
|
||||||
crop_view, match_num = crop_posts_image(view1, view2, plt_match=True, plt_crop=True)
|
crop_view, _ = crop_posts_image(view1, view2, plt_match=True, plt_crop=True)
|
||||||
cv2.imwrite("data/crop_100489_ind.png", crop_view)
|
cv2.imwrite("data/crop_100489_ind.png", crop_view)
|
||||||
|
|
||||||
|
|
||||||
@ -267,10 +267,3 @@ def test_crop_from_folder():
|
|||||||
crop_posts_from_files(
|
crop_posts_from_files(
|
||||||
ref_dir, crop_dir, save_crop_dir, plt_match=False, plt_crop=False
|
ref_dir, crop_dir, save_crop_dir, plt_match=False, plt_crop=False
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# do tests:
|
|
||||||
|
|
||||||
# test_crop_from_file()
|
|
||||||
|
|
||||||
# test_crop_from_folder()
|
|
||||||
|
|||||||
@ -1,127 +0,0 @@
|
|||||||
{
|
|
||||||
"v9_4": {
|
|
||||||
"order": 169,
|
|
||||||
"variable_label": "4=PICTURE_SPECIFIC_VisualONLY",
|
|
||||||
"variable_explanation": "Person visible",
|
|
||||||
"variable_coding": "Bool",
|
|
||||||
"variable_comment": "Yes if there's someone shown",
|
|
||||||
"variable_mydict": "face",
|
|
||||||
"value_mydict": "Yes"
|
|
||||||
},
|
|
||||||
"v9_5a": {
|
|
||||||
"order": 170,
|
|
||||||
"variable_label": "5a=PICTURE_SPECIFIC_VisualONLY",
|
|
||||||
"variable_explanation": "More than one person shown",
|
|
||||||
"variable_coding": "Bool",
|
|
||||||
"variable_comment": "Yes if there are several individuals who appear in the post (do not count profile pictures)",
|
|
||||||
"variable_mydict": "multiple_faces",
|
|
||||||
"value_mydict": "Yes"
|
|
||||||
},
|
|
||||||
"v9_5b": {
|
|
||||||
"order": 171,
|
|
||||||
"variable_label": "5b=PICTURE_SPECIFIC_VisualONLY",
|
|
||||||
"variable_explanation": "How many people shown?",
|
|
||||||
"variable_coding": "Int",
|
|
||||||
"variable_comment": "If more than 15, put 99",
|
|
||||||
"variable_mydict": "no_faces",
|
|
||||||
"value_mydict": "0"
|
|
||||||
},
|
|
||||||
"v9_6": {
|
|
||||||
"order": 172,
|
|
||||||
"variable_label": "6=PICTURE_SPECIFIC_VisualONLY",
|
|
||||||
"variable_explanation": "Face fully visible",
|
|
||||||
"variable_coding": "Bool",
|
|
||||||
"variable_comment": "Yes if you can see all their face (no mask on)",
|
|
||||||
"variable_mydict": "wears_mask",
|
|
||||||
"value_mydict": "No"
|
|
||||||
},
|
|
||||||
"v9_7": {
|
|
||||||
"order": 173,
|
|
||||||
"variable_label": "7=PICTURE_SPECIFIC_VisualONLY",
|
|
||||||
"variable_explanation": "Face ONLY partially visible",
|
|
||||||
"variable_coding": "Bool",
|
|
||||||
"variable_comment": "Yes if you can only see part of their face, including when they are wearing a mask",
|
|
||||||
"variable_mydict": "wears_mask",
|
|
||||||
"value_mydict": "Yes"
|
|
||||||
},
|
|
||||||
"v9_8": {
|
|
||||||
"order": 174,
|
|
||||||
"variable_label": "8=PICTURE_SPECIFIC_VisualONLY",
|
|
||||||
"variable_explanation": "Facial positive expression",
|
|
||||||
"variable_coding": "Bool",
|
|
||||||
"variable_comment": "Yes if they display some kind of positive facial expression (smiling, happy, relieved, hopeful etc.)",
|
|
||||||
"variable_mydict": "emotion (category)",
|
|
||||||
"value_mydict": "Positive"
|
|
||||||
},
|
|
||||||
"v9_8a": {
|
|
||||||
"order": 175,
|
|
||||||
"variable_label": "8a=PICTURE_SPECIFIC_VisualONLY",
|
|
||||||
"variable_explanation": "Positive expression: happiness",
|
|
||||||
"variable_coding": "Bool",
|
|
||||||
"variable_comment": "Yes if they display happiness",
|
|
||||||
"variable_mydict": "emotion",
|
|
||||||
"value_mydict": "happy"
|
|
||||||
},
|
|
||||||
"v9_9": {
|
|
||||||
"order": 176,
|
|
||||||
"variable_label": "9=PICTURE_SPECIFIC_VisualONLY",
|
|
||||||
"variable_explanation": "Facial negative expression",
|
|
||||||
"variable_coding": "Bool",
|
|
||||||
"variable_comment": "Yes if they display some kind of negative facial expression (crying, showing ager, fear, disgust etc.)",
|
|
||||||
"variable_mydict": "emotion (category)",
|
|
||||||
"value_mydict": "Negative"
|
|
||||||
},
|
|
||||||
"v9_10": {
|
|
||||||
"order": 177,
|
|
||||||
"variable_label": "10=PICTURE_SPECIFIC_VisualONLY",
|
|
||||||
"variable_explanation": "Negative expression: anxiety",
|
|
||||||
"variable_coding": "Bool",
|
|
||||||
"variable_comment": "Yes if they show fear or anxiety. If you can't tell, choose No=0",
|
|
||||||
"variable_mydict": "emotion",
|
|
||||||
"value_mydict": "fear"
|
|
||||||
},
|
|
||||||
"v9_11": {
|
|
||||||
"order": 178,
|
|
||||||
"variable_label": "11=PICTURE_SPECIFIC_VisualONLY",
|
|
||||||
"variable_explanation": "Negative expression: anger",
|
|
||||||
"variable_coding": "Bool",
|
|
||||||
"variable_comment": "Yes if they show anger or outrage. If you can't tell, choose No=0",
|
|
||||||
"variable_mydict": "emotion",
|
|
||||||
"value_mydict": "angry"
|
|
||||||
},
|
|
||||||
"v9_12": {
|
|
||||||
"order": 179,
|
|
||||||
"variable_label": "12=PICTURE_SPECIFIC_VisualONLY",
|
|
||||||
"variable_explanation": "Negative expression: disgust",
|
|
||||||
"variable_coding": "Bool",
|
|
||||||
"variable_comment": "Yes if they show disgust. If you can't tell, choose No=0",
|
|
||||||
"variable_mydict": "emotion",
|
|
||||||
"value_mydict": "disgust"
|
|
||||||
},
|
|
||||||
"v9_13": {
|
|
||||||
"order": 180,
|
|
||||||
"variable_label": "13=PICTURE_SPECIFIC_VisualONLY",
|
|
||||||
"variable_explanation": "Negative expression: other, specify",
|
|
||||||
"variable_coding": "Bool",
|
|
||||||
"variable_comment": "Yes if they show any other negative emotion, please specify. If you can't tell, choose No=0",
|
|
||||||
"variable_mydict": "emotion",
|
|
||||||
"value_mydict": "sad"
|
|
||||||
},
|
|
||||||
"v9_13_text": {
|
|
||||||
"order": 181,
|
|
||||||
"variable_label": "13=PICTURE_SPECIFIC_VisualONLY",
|
|
||||||
"variable_explanation": "Negative expression: other, specify",
|
|
||||||
"variable_coding": "Str",
|
|
||||||
"variable_mydict": "emotion",
|
|
||||||
"value_mydict": ""
|
|
||||||
},
|
|
||||||
"v11_3": {
|
|
||||||
"order": 189,
|
|
||||||
"variable_label": "111_3=PICTURE_SPECIFIC_VisualONLY",
|
|
||||||
"variable_explanation": "Respect of the rules",
|
|
||||||
"variable_coding": "Bool",
|
|
||||||
"variable_comment": "Yes if the post shows mask wearing, vaccine taking, social distancing, any proof of respecting the rules",
|
|
||||||
"variable_mydict": "wears_mask",
|
|
||||||
"value_mydict": "Yes"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,7 +1,5 @@
|
|||||||
import cv2
|
import cv2
|
||||||
import cvlib as cv
|
import cvlib as cv
|
||||||
import numpy as np
|
|
||||||
from PIL import Image
|
|
||||||
|
|
||||||
|
|
||||||
def objects_from_cvlib(objects_list: list) -> dict:
|
def objects_from_cvlib(objects_list: list) -> dict:
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
import ammico.faces as fc
|
import ammico.faces as fc
|
||||||
import json
|
import json
|
||||||
import pytest
|
|
||||||
|
|
||||||
|
|
||||||
def test_analyse_faces(get_path):
|
def test_analyse_faces(get_path):
|
||||||
|
|||||||
@ -113,7 +113,6 @@ class TextDetector(utils.AnalysisMethod):
|
|||||||
self.subdict["text_english_correct"] = str(self.textblob.correct())
|
self.subdict["text_english_correct"] = str(self.textblob.correct())
|
||||||
|
|
||||||
def sentiment_analysis(self):
|
def sentiment_analysis(self):
|
||||||
# self.subdict["sentiment"] = self.doc._.blob.sentiment_assessments.assessments
|
|
||||||
# polarity is between [-1.0, 1.0]
|
# polarity is between [-1.0, 1.0]
|
||||||
self.subdict["polarity"] = self.doc._.blob.polarity
|
self.subdict["polarity"] = self.doc._.blob.polarity
|
||||||
# subjectivity is a float within the range [0.0, 1.0]
|
# subjectivity is a float within the range [0.0, 1.0]
|
||||||
|
|||||||
Загрузка…
x
Ссылка в новой задаче
Block a user