Skip to content

Commit 871f238

Browse files
Merge pull request #2 from faustomorales/fdm/fix-vector-order
Fix vector order
2 parents 3c35e8d + b5ba216 commit 871f238

12 files changed

Lines changed: 186 additions & 163 deletions

File tree

.circleci/config.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.

.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
.venv
22
ThreatExchange
3-
!ThreatExchange/hashing/pdq/cpp
3+
!ThreatExchange/pdq
44
tests

.github/workflows/ci.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: pdqhash-python CI/CD
2+
3+
on:
4+
push:
5+
branches:
6+
- '**'
7+
8+
jobs:
9+
test:
10+
name: Test pdqhash-python
11+
strategy:
12+
matrix:
13+
python-version: [3.6]
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout Code
17+
uses: actions/checkout@v2
18+
- name: Get submodules
19+
run: |
20+
git submodule init
21+
git submodule update --remote
22+
- name: Set up Python ${{ matrix.python-version }}
23+
uses: actions/setup-python@v2
24+
with:
25+
python-version: ${{ matrix.python-version }}
26+
- name: Install Pipenv
27+
run: |
28+
pip install pipenv
29+
- name: Make Host Environment
30+
run: |
31+
make init
32+
- name: Test Source
33+
run: |
34+
make test

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[submodule "ThreatExchange"]
22
path = ThreatExchange
3-
url = git@github.com:facebook/ThreatExchange.git
3+
url = https://github.com/facebook/ThreatExchange.git

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ RUN pip install pipenv
55
# Install project
66
WORKDIR /usr/src
77
COPY ./Pipfile* ./
8-
COPY ./ThreatExchange/hashing/pdq ./ThreatExchange/hashing/pdq
8+
COPY ./ThreatExchange/pdq ./ThreatExchange/pdq
99
COPY ./setup* ./
1010
COPY ./pdqhash ./pdqhash
1111
COPY ./Makefile ./Makefile

Pipfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pylint = "==2.3.0"
88
pytest = "*"
99
yapf = "==0.25.0"
1010
numpy = "*"
11-
opencv-python = "*"
11+
opencv-python-headless = "*"
1212

1313
[requires]
14-
python_version = "3.7"
14+
python_version = "3.6"

ThreatExchange

Submodule ThreatExchange updated 502 files

pdqhash/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
11
from .bindings import compute, compute_dihedral, compute_float
2+
import warnings
3+
warnings.warn(
4+
"Hash vector order changed between version 0.1.8 and 0.2.0. "
5+
"See https://github.com/faustomorales/pdqhash-python/issues/1 for more details.")

pdqhash/bindings.pyx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
import numpy as np
44
cimport numpy as np
55

6-
cdef extern from "../ThreatExchange/hashing/pdq/cpp/common/pdqhashtypes.cpp" namespace "facebook::pdq::hashing":
6+
cdef extern from "pdq/cpp/common/pdqhashtypes.cpp" namespace "facebook::pdq::hashing":
77
cdef struct Hash256:
88
unsigned short w[16]
99

1010

11-
cdef extern from "../ThreatExchange/hashing/pdq/cpp/hashing/pdqhashing.cpp" namespace "facebook::pdq::hashing":
11+
cdef extern from "pdq/cpp/hashing/pdqhashing.cpp" namespace "facebook::pdq::hashing":
1212
void pdqHash256FromFloatLuma(
1313
float* fullBuffer1,
1414
float* fullBuffer2,
@@ -21,7 +21,7 @@ cdef extern from "../ThreatExchange/hashing/pdq/cpp/hashing/pdqhashing.cpp" name
2121
int& quality
2222
)
2323

24-
cdef extern from "../ThreatExchange/hashing/pdq/cpp/hashing/pdqhashing.cpp" namespace "facebook::pdq::hashing":
24+
cdef extern from "pdq/cpp/hashing/pdqhashing.cpp" namespace "facebook::pdq::hashing":
2525
void pdqFloat256FromFloatLuma(
2626
float* fullBuffer1,
2727
float* fullBuffer2,
@@ -33,7 +33,7 @@ cdef extern from "../ThreatExchange/hashing/pdq/cpp/hashing/pdqhashing.cpp" name
3333
int& quality
3434
)
3535

36-
cdef extern from "../ThreatExchange/hashing/pdq/cpp/hashing/pdqhashing.cpp" namespace "facebook::pdq::hashing":
36+
cdef extern from "pdq/cpp/hashing/pdqhashing.cpp" namespace "facebook::pdq::hashing":
3737
void pdqDihedralHash256esFromFloatLuma(
3838
float* fullBuffer1,
3939
float* fullBuffer2,
@@ -54,14 +54,14 @@ cdef extern from "../ThreatExchange/hashing/pdq/cpp/hashing/pdqhashing.cpp" name
5454
int& quality
5555
)
5656

57-
cdef extern from "../ThreatExchange/hashing/pdq/cpp/downscaling/downscaling.cpp" namespace "facebook::pdq::downscaling":
57+
cdef extern from "pdq/cpp/downscaling/downscaling.cpp" namespace "facebook::pdq::downscaling":
5858
int computeJaroszFilterWindowSize(int oldDimension, int newDimension)
5959

60-
cdef extern from "../ThreatExchange/hashing/pdq/cpp/hashing/torben.cpp" namespace "facebook::pdq::hashing":
60+
cdef extern from "pdq/cpp/hashing/torben.cpp" namespace "facebook::pdq::hashing":
6161
float torben(float m[], int n)
6262

6363
def hash_to_vector(hash_value):
64-
return np.array([(hash_value[(k & 255) >> 4] >> (k & 15)) & 1 for k in range(256)]).reshape(16, 16)[:, ::-1].flatten()
64+
return np.array([(hash_value[(k & 255) >> 4] >> (k & 15)) & 1 for k in range(256)])[::-1]
6565

6666
def compute(np.ndarray[char, ndim=3] image):
6767
cdef np.ndarray[float, ndim=2] gray = (image[:, :, 0]*0.299 + image[:, :, 1]*0.587 + image[:, :, 2] * 0.114).astype('float32')
@@ -109,7 +109,7 @@ def compute_float(np.ndarray[char, ndim=3] image):
109109
buffer16x64,
110110
buffer16x16,
111111
quality)
112-
return np.array(buffer16x16)[:, ::-1].flatten(), quality
112+
return np.array(buffer16x16).flatten()[::-1], quality
113113

114114
def compute_dihedral(np.ndarray[char, ndim=3] image):
115115
cdef np.ndarray[float, ndim=2] gray = (image[:, :, 0]*0.299 + image[:, :, 1]*0.587 + image[:, :, 2] * 0.114).astype('float32')

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ description = Python bindings for Facebook's PDQ hash
1010
long_description = file: README.md
1111
long_description_content_type = text/markdown
1212
url = https://github.com/faustomorales/pdqhash-python
13-
version = 0.1.8
13+
version = 0.2.0
1414
license = MIT
1515
classifiers =
1616
Development Status :: 5 - Production/Stable

0 commit comments

Comments
 (0)