Skip to content

Commit

Permalink
Adds a refinement task to label the images in categories;
Browse files Browse the repository at this point in the history
  • Loading branch information
hauck-jvsh committed Feb 20, 2025
1 parent 69db9bf commit d9020ca
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 1 deletion.
10 changes: 9 additions & 1 deletion iped-app/resources/config/conf/CategoriesConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,14 @@
{"name": "Journeys", "mimes": ["application/x-ufed-journey"]},
{"name": "Networks Usage", "mimes": ["application/x-ufed-networkusage"]},
{"name": "Recognized Devices", "mimes": ["application/x-ufed-recognizeddevice"]},
{"name": "Social Media Activities", "mimes": ["application/x-ufed-socialmediaactivity"]}
{"name": "Social Media Activities", "mimes": ["application/x-ufed-socialmediaactivity"]},
{"name": "Classified by AI", "categories":[
{"name": "AI Label: Child Sexual Abuse"},
{"name": "AI Label: Likely Child Sexual Abuse"},
{"name": "AI Label: Drawing"},
{"name": "AI Label: People"},
{"name": "AI Label: Pornography"},
{"name": "AI Label: Other"}
]}
]
}
2 changes: 2 additions & 0 deletions iped-app/resources/config/conf/RemoteImageClassifier.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ url = http://192.168.160.208:8000/zip
# max size number of thumbs to be included in the zip file sent to the server
batch_size = 50

# threshold used to decide if an image is labeled in one category
categorization_threshold=0.99
1 change: 1 addition & 0 deletions iped-app/resources/config/conf/TaskInstaller.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
<task class="iped.engine.task.PhotoDNATask"></task>
<task class="iped.engine.task.PhotoDNALookup"></task>
<task class="iped.engine.task.RemoteImageClassifier"></task>
<task script="AIRefineCategoryTask.js"></task>
<task script="NSFWNudityDetectTask.py"></task>
<task script="FaceRecognitionTask.py"></task>
<task script="SearchHardwareWallets.py"></task>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,10 @@ Journeys=Jornadas
Networks\ Usage=Uso\ de\ Redes
Recognized\ Devices=Dispositivos\ Identificados
Social\ Media\ Activities=Atividades\ em\ Redes\ Sociais
Classified\ by\ AI=Classificados\ por\ IA
AI\ Label\:\ Child\ Sexual\ Abuse=Rótulo\ IA:\ Abuso\ Sexual\ Infantil
AI\ Label\:\ Likely\ Child\ Sexual\ Abuse=Rótulo\ IA:\ Possível\ Abuso\ Sexual\ Infantil
AI\ Label\:\ Drawing=Rótulo\ IA:\ Desenho
AI\ Label\:\ People=Rótulo\ IA:\ Pessoas
AI\ Label\:\ Pornography=Rótulo\ IA:\ Pornografia
AI\ Label\:\ Other=Rótulo\ IA:\ Outros
50 changes: 50 additions & 0 deletions iped-app/resources/scripts/tasks/AIRefineCategoryTask.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Script of Category Specialization based on item properties.
* Uses javascript language to allow flexibility in definitions.
*/

/* Name of processing task
*/

var categorizationThreshold=0.5;
var RemoteImageClassifierConfig=Java.type("iped.engine.config.RemoteImageClassifierConfig")
var Arrays=Java.type("java.util.Arrays")

function getName(){
return "AIRefineCategoryTask";
}


function getConfigurables() {

return Arrays.asList(new RemoteImageClassifierConfig());
}

function init(configurationManager) {
config=configurationManager.findObject(RemoteImageClassifierConfig.class)
categorizationThreshold=config.getCategorizationThreshold()
}

function finish(){}

/*
* Changes category of items based on their properties
*
*/
function process(e){

listcategories={
"ASI":"AI Label: Child Sexual Abuse",
"ASI_SUSP":"AI Label: Likely Child Sexual Abuse",
"Desenhos":"AI Label: Drawing",
"Outros":"AI Label: Other",
"Pessoas":"AI Label: People",
"Porn":"AI Label: Pornography",
}
for(cat in listcategories){
if (e.getExtraAttribute(cat)>0.5){
e.addCategory(listcategories[cat]);
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@ public class RemoteImageClassifierConfig extends AbstractTaskPropertiesConfig {

private static final String URL_KEY = "url";
private static final String BATCH_SIZE_KEY = "batch_size";
private static final String CATEGORIZATION_THRESHOLD = "categorization_threshold";

private String url;
private int batchSize;
private double categorizationThreshold = 0.5;
@Override
void processProperties(UTF8Properties properties) {
// TODO Auto-generated method stub
setUrl(properties.getProperty(URL_KEY).trim());
setBatchSize(Integer.parseInt(properties.getProperty(BATCH_SIZE_KEY).trim()));
setCategorizationThreshold(Double.parseDouble(properties.getProperty(CATEGORIZATION_THRESHOLD).trim()));

}

Expand Down Expand Up @@ -48,4 +51,12 @@ public void setBatchSize(int batchSize) {
this.batchSize = batchSize;
}

public double getCategorizationThreshold() {
return categorizationThreshold;
}

public void setCategorizationThreshold(double categorizationThreshold) {
this.categorizationThreshold = categorizationThreshold;
}

}

0 comments on commit d9020ca

Please sign in to comment.