updates
Browse files- main.py +21 -0
- static/index.html +23 -23
main.py
CHANGED
@@ -17,6 +17,10 @@ from diffusers import (
|
|
17 |
|
18 |
app = FastAPI()
|
19 |
|
|
|
|
|
|
|
|
|
20 |
|
21 |
@app.get("/generate")
|
22 |
def generate_image(prompt, model):
|
@@ -109,6 +113,20 @@ def verify_image(fileUpload: UploadFile):
|
|
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}
|
114 |
|
@@ -120,3 +138,6 @@ app.mount("/", StaticFiles(directory="static", html=True), name="static")
|
|
120 |
@app.get("/")
|
121 |
def index() -> FileResponse:
|
122 |
return FileResponse(path="/app/static/index.html", media_type="text/html")
|
|
|
|
|
|
|
|
17 |
|
18 |
app = FastAPI()
|
19 |
|
20 |
+
def file_extension(filename):
|
21 |
+
filename_list = filename.split(".")
|
22 |
+
return filename_list[1]
|
23 |
+
|
24 |
|
25 |
@app.get("/generate")
|
26 |
def generate_image(prompt, model):
|
|
|
113 |
original_media = original_media_string.split(":", 1)
|
114 |
original_media = original_media[1].strip(" ").strip("'")
|
115 |
|
116 |
+
if original_media != 'n/a':
|
117 |
+
original_media_extension = file_extension(original_media)
|
118 |
+
logging.warning(original_media_extension)
|
119 |
+
|
120 |
+
filename = str(uuid.uuid4()) + original_media_extension
|
121 |
+
|
122 |
+
response = subprocess.check_output(
|
123 |
+
[
|
124 |
+
"cp",
|
125 |
+
original_media,
|
126 |
+
"static/" + filename,
|
127 |
+
]
|
128 |
+
)
|
129 |
+
|
130 |
|
131 |
return {"response": fileUpload.filename, "contains_c2pa" : c2pa, "contains_watermark" : watermark, "original_media" : original_media}
|
132 |
|
|
|
138 |
@app.get("/")
|
139 |
def index() -> FileResponse:
|
140 |
return FileResponse(path="/app/static/index.html", media_type="text/html")
|
141 |
+
|
142 |
+
|
143 |
+
|
static/index.html
CHANGED
@@ -80,11 +80,11 @@
|
|
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">
|
@@ -202,7 +202,7 @@
|
|
202 |
const imagePrompt = document.getElementById("prompt");
|
203 |
const model = document.getElementById("model");
|
204 |
const generateImageContainer = document.querySelector(".display-generate .image-container");
|
205 |
-
|
206 |
|
207 |
generateTab.addEventListener("click", (event) => {
|
208 |
event.target.classList.add("active");
|
@@ -264,32 +264,32 @@
|
|
264 |
document.getElementById("digitalWatermarkResults").innerHTML = data.contains_watermark;
|
265 |
document.getElementById("originalMedia").innerHTML = data.original_media;
|
266 |
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
var resultsContainer = document.getElementById("image-container");
|
271 |
|
272 |
-
|
273 |
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
|
|
|
|
282 |
|
283 |
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
|
289 |
-
|
290 |
|
291 |
-
|
292 |
-
|
293 |
// Handle response data
|
294 |
})
|
295 |
.catch((error) => {
|
|
|
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">
|
|
|
202 |
const imagePrompt = document.getElementById("prompt");
|
203 |
const model = document.getElementById("model");
|
204 |
const generateImageContainer = document.querySelector(".display-generate .image-container");
|
205 |
+
const verifyImageContainer = document.querySelector(".display-verify .image-container");
|
206 |
|
207 |
generateTab.addEventListener("click", (event) => {
|
208 |
event.target.classList.add("active");
|
|
|
264 |
document.getElementById("digitalWatermarkResults").innerHTML = data.contains_watermark;
|
265 |
document.getElementById("originalMedia").innerHTML = data.original_media;
|
266 |
|
267 |
+
if (data.original_media != 'n/a') {
|
268 |
+
const path = "/" + data.original_media;
|
|
|
|
|
269 |
|
270 |
+
var truepicDisplay = document.createElement("truepic-display");
|
271 |
|
272 |
+
/*
|
273 |
+
truepicDisplay.addEventListener(
|
274 |
+
"validate",
|
275 |
+
setVerificationOutputFromValidation
|
276 |
+
);
|
277 |
+
truepicDisplay.addEventListener(
|
278 |
+
"validate",
|
279 |
+
setCertificateOutputFromValidation
|
280 |
+
);
|
281 |
+
*/
|
282 |
|
283 |
|
284 |
+
truepicDisplay.setAttribute("id", "result");
|
285 |
+
truepicDisplay.setAttribute("active", "");
|
286 |
+
var truepic = document.createElement("img");
|
287 |
+
truepic.src = path;
|
288 |
|
289 |
+
truepicDisplay.appendChild(truepic);
|
290 |
|
291 |
+
verifyImageContainer.appendChild(truepicDisplay);
|
292 |
+
}
|
293 |
// Handle response data
|
294 |
})
|
295 |
.catch((error) => {
|