updates
Browse files- main.py +19 -17
- scripts/sign.sh +2 -1
- static/index.html +11 -1
main.py
CHANGED
@@ -37,25 +37,27 @@ def generate_image(prompt, model):
|
|
37 |
filename = str(uuid.uuid4()) + ".jpg"
|
38 |
image.save(filename)
|
39 |
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
|
55 |
subprocess.check_output(
|
56 |
[
|
57 |
"./scripts/sign.sh",
|
58 |
filename,
|
|
|
|
|
59 |
]
|
60 |
)
|
61 |
|
@@ -97,15 +99,15 @@ def verify_image(fileUpload: UploadFile):
|
|
97 |
|
98 |
c2pa_string = str(response_list[0])
|
99 |
c2pa = c2pa_string.split(":", 1)
|
100 |
-
c2pa = c2pa[1].
|
101 |
|
102 |
watermark_string = str(response_list[1])
|
103 |
watermark = watermark_string.split(":", 1)
|
104 |
-
watermark = watermark[1].
|
105 |
|
106 |
original_media_string = str(response_list[2])
|
107 |
original_media = original_media_string.split(":", 1)
|
108 |
-
original_media = original_media[1].
|
109 |
|
110 |
|
111 |
return {"response": fileUpload.filename, "contains_c2pa" : c2pa, "contains_watermark" : watermark, "original_media" : original_media}
|
|
|
37 |
filename = str(uuid.uuid4()) + ".jpg"
|
38 |
image.save(filename)
|
39 |
|
40 |
+
assertion = {
|
41 |
+
"assertions": [
|
42 |
+
{
|
43 |
+
"label": "com.truepic.custom.ai",
|
44 |
+
"data": {
|
45 |
+
"model_name": modelName,
|
46 |
+
"model_version": modelVersion,
|
47 |
+
"prompt": prompt,
|
48 |
+
},
|
49 |
+
}
|
50 |
+
]
|
51 |
+
}
|
52 |
+
|
53 |
+
json_object = json.dumps(assertion)
|
54 |
|
55 |
subprocess.check_output(
|
56 |
[
|
57 |
"./scripts/sign.sh",
|
58 |
filename,
|
59 |
+
"--assertions-inline",
|
60 |
+
json_object
|
61 |
]
|
62 |
)
|
63 |
|
|
|
99 |
|
100 |
c2pa_string = str(response_list[0])
|
101 |
c2pa = c2pa_string.split(":", 1)
|
102 |
+
c2pa = c2pa[1].strip(" ").strip("'")
|
103 |
|
104 |
watermark_string = str(response_list[1])
|
105 |
watermark = watermark_string.split(":", 1)
|
106 |
+
watermark = watermark[1].strip(" ").strip("'")
|
107 |
|
108 |
original_media_string = str(response_list[2])
|
109 |
original_media = original_media_string.split(":", 1)
|
110 |
+
original_media = original_media[1].strip(" ").strip("'")
|
111 |
|
112 |
|
113 |
return {"response": fileUpload.filename, "contains_c2pa" : c2pa, "contains_watermark" : watermark, "original_media" : original_media}
|
scripts/sign.sh
CHANGED
@@ -14,6 +14,7 @@ debug_echo() {
|
|
14 |
|
15 |
|
16 |
MEDIA_FILE=$(readlink -f "$1")
|
|
|
17 |
|
18 |
TRUEPIC_CLI=/home/user/app/truepic
|
19 |
STEG_SCRIPTS=/home/user/app/scripts/
|
@@ -34,7 +35,7 @@ fi
|
|
34 |
|
35 |
debug_echo -n "Signing media..."
|
36 |
signed_no_watermark=$(mktemp).${extension}
|
37 |
-
${TRUEPIC_CLI} sign $MEDIA_FILE --output ${signed_no_watermark} > /dev/null 2>&1
|
38 |
debug_echo " --> ${signed_no_watermark}"
|
39 |
|
40 |
debug_echo
|
|
|
14 |
|
15 |
|
16 |
MEDIA_FILE=$(readlink -f "$1")
|
17 |
+
shift
|
18 |
|
19 |
TRUEPIC_CLI=/home/user/app/truepic
|
20 |
STEG_SCRIPTS=/home/user/app/scripts/
|
|
|
35 |
|
36 |
debug_echo -n "Signing media..."
|
37 |
signed_no_watermark=$(mktemp).${extension}
|
38 |
+
${TRUEPIC_CLI} sign $MEDIA_FILE "$@" --output ${signed_no_watermark} > /dev/null 2>&1
|
39 |
debug_echo " --> ${signed_no_watermark}"
|
40 |
|
41 |
debug_echo
|
static/index.html
CHANGED
@@ -77,7 +77,14 @@
|
|
77 |
</div>
|
78 |
</div>
|
79 |
<div class="display-verify">
|
80 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
</div>
|
82 |
</div>
|
83 |
<div class="col right-column">
|
@@ -253,6 +260,9 @@
|
|
253 |
console.log("contains_watermark", data.contains_watermark);
|
254 |
console.log("original_media", data.original_media);
|
255 |
|
|
|
|
|
|
|
256 |
|
257 |
/*
|
258 |
const path = "/" + data.response;
|
|
|
77 |
</div>
|
78 |
</div>
|
79 |
<div class="display-verify">
|
80 |
+
<p>Contains Credentials: <span id="contentCredentialResults"></span></p>
|
81 |
+
<p>Digital Watermark: <span id="digitalWatermarkResults"></span></p>
|
82 |
+
<p>Original Media: <span id="originalMedia"></span></p>
|
83 |
+
<!--
|
84 |
+
<div class="image-container">
|
85 |
+
|
86 |
+
</div>
|
87 |
+
-->
|
88 |
</div>
|
89 |
</div>
|
90 |
<div class="col right-column">
|
|
|
260 |
console.log("contains_watermark", data.contains_watermark);
|
261 |
console.log("original_media", data.original_media);
|
262 |
|
263 |
+
document.getElementById("contentCredentialResults").innerHTML = data.contains_c2pa;
|
264 |
+
document.getElementById("digitalWatermarkResults").innerHTML = data.contains_watermark;
|
265 |
+
document.getElementById("originalMedia").innerHTML = data.original_media;
|
266 |
|
267 |
/*
|
268 |
const path = "/" + data.response;
|