Skip to content

Commit

Permalink
Debug 10
Browse files Browse the repository at this point in the history
  • Loading branch information
fabasoad committed Jan 3, 2025
1 parent 3985ff8 commit b7d834b
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ runs:

- name: Classify files
if: ${{ steps.changed-files.outputs.any_changed == 'true' }}
id: classify-files
env:
INPUT_PROVIDER: ${{ inputs.provider }}
INPUT_API_KEY: ${{ inputs.api-key }}
Expand All @@ -67,3 +68,7 @@ runs:
"${{ steps.changed-files.outputs.all_changed_files }}" \
"${INPUT_API_KEY}"
shell: sh

- name: Print scores
run: echo "${{ steps.classify-files.outputs.scores }}"
shell: sh
10 changes: 10 additions & 0 deletions src/providers/cloudmersive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ main() {
files="${1}"
api_key="${2}"

result="[]"
for file_path in ${files}; do
log_debug "Classifying ${file_path}..."
response=$(curl -sL \
Expand All @@ -20,13 +21,22 @@ main() {
--header "Apikey: ${api_key}" \
--form "imageFile=@${file_path}")
if [ "$(echo "${response}" | jq -r '.Successful')" = "true" ]; then
# Getting score
score=$(echo "${response}" | jq -r '.Score')
# Build object for the output
obj="$(jq -n \
--arg f "${file_path}" \
--arg s "${score}" \
'{file: $f, score: $s | tonumber}')"
# Add object to the resulting array
result=$(echo "${result}" | jq --argjson obj "${obj}" '. += [$obj]')
log_info "Classified ${file_path} with score ${score}"
else
msg="There was a problem during ${file_path} file classification."
log_warning "${msg}"
fi
done
echo "scores=${result}" >> "$GITHUB_OUTPUT"
}

main "$@"
9 changes: 9 additions & 0 deletions src/providers/picpurify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,15 @@ main() {
-F "task=porn_moderation,suggestive_nudity_moderation" \
-F "file_image=@${file_path}")
if [ "$(echo "${response}" | jq -r '.status')" = "success" ]; then
# Getting score
score=$(echo "${response}" | jq -r '.confidence_score_decision')
# Build object for the output
obj="$(jq -n \
--arg f "${file_path}" \
--arg s "${score}" \
'{file: $f, score: $s | tonumber}')"
# Add object to the resulting array
result=$(echo "${result}" | jq --argjson obj "${obj}" '. += [$obj]')
log_info "Classified ${file_path} with score ${score}"
else
msg="There was a problem during ${file_path} file classification."
Expand All @@ -30,6 +38,7 @@ main() {
log_warning "${msg}"
fi
done
echo "scores=${result}" >> "$GITHUB_OUTPUT"
}

main "$@"
9 changes: 9 additions & 0 deletions src/providers/sightengine.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,15 @@ main() {
-F "api_user=${api_user}" \
-F "api_secret=${api_secret}")
if [ "$(echo "${response}" | jq -r '.status')" = "success" ]; then
# Getting maximum score
score=$(echo "${response}" | jq -r '.nudity | [.sexual_activity, .sexual_display, .erotica] | max')
# Build object for the output
obj="$(jq -n \
--arg f "${file_path}" \
--arg s "${score}" \
'{file: $f, score: $s | tonumber}')"
# Add object to the resulting array
result=$(echo "${result}" | jq --argjson obj "${obj}" '. += [$obj]')
log_info "Classified ${file_path} with score ${score}"
else
msg="There was a problem during ${file_path} file classification."
Expand All @@ -32,6 +40,7 @@ main() {
log_warning "${msg}"
fi
done
echo "scores=${result}" >> "$GITHUB_OUTPUT"
}

main "$@"

0 comments on commit b7d834b

Please sign in to comment.