return & render base64 instead of saving imgs

master
michael 2022-10-12 12:27:52 -07:00
parent b1d0252465
commit aaba03c50b
3 changed files with 47 additions and 45 deletions

60
Pipfile.lock generated
View File

@ -172,37 +172,37 @@
},
"numpy": {
"hashes": [
"sha256:004f0efcb2fe1c0bd6ae1fcfc69cc8b6bf2407e0f18be308612007a0762b4089",
"sha256:09f6b7bdffe57fc61d869a22f506049825d707b288039d30f26a0d0d8ea05164",
"sha256:0ea3f98a0ffce3f8f57675eb9119f3f4edb81888b6874bc1953f91e0b1d4f440",
"sha256:17c0e467ade9bda685d5ac7f5fa729d8d3e76b23195471adae2d6a6941bd2c18",
"sha256:1f27b5322ac4067e67c8f9378b41c746d8feac8bdd0e0ffede5324667b8a075c",
"sha256:22d43376ee0acd547f3149b9ec12eec2f0ca4a6ab2f61753c5b29bb3e795ac4d",
"sha256:2ad3ec9a748a8943e6eb4358201f7e1c12ede35f510b1a2221b70af4bb64295c",
"sha256:301c00cf5e60e08e04d842fc47df641d4a181e651c7135c50dc2762ffe293dbd",
"sha256:39a664e3d26ea854211867d20ebcc8023257c1800ae89773cbba9f9e97bae036",
"sha256:51bf49c0cd1d52be0a240aa66f3458afc4b95d8993d2d04f0d91fa60c10af6cd",
"sha256:78a63d2df1d947bd9d1b11d35564c2f9e4b57898aae4626638056ec1a231c40c",
"sha256:7cd1328e5bdf0dee621912f5833648e2daca72e3839ec1d6695e91089625f0b4",
"sha256:8355fc10fd33a5a70981a5b8a0de51d10af3688d7a9e4a34fcc8fa0d7467bb7f",
"sha256:8c79d7cf86d049d0c5089231a5bcd31edb03555bd93d81a16870aa98c6cfb79d",
"sha256:91b8d6768a75247026e951dce3b2aac79dc7e78622fc148329135ba189813584",
"sha256:94c15ca4e52671a59219146ff584488907b1f9b3fc232622b47e2cf832e94fb8",
"sha256:98dcbc02e39b1658dc4b4508442a560fe3ca5ca0d989f0df062534e5ca3a5c1a",
"sha256:a64403f634e5ffdcd85e0b12c08f04b3080d3e840aef118721021f9b48fc1460",
"sha256:bc6e8da415f359b578b00bcfb1d08411c96e9a97f9e6c7adada554a0812a6cc6",
"sha256:bdc9febce3e68b697d931941b263c59e0c74e8f18861f4064c1f712562903411",
"sha256:c1ba66c48b19cc9c2975c0d354f24058888cdc674bebadceb3cdc9ec403fb5d1",
"sha256:c9f707b5bb73bf277d812ded9896f9512a43edff72712f31667d0a8c2f8e71ee",
"sha256:d5422d6a1ea9b15577a9432e26608c73a78faf0b9039437b075cf322c92e98e7",
"sha256:e5d5420053bbb3dd64c30e58f9363d7a9c27444c3648e61460c1237f9ec3fa14",
"sha256:e868b0389c5ccfc092031a861d4e158ea164d8b7fdbb10e3b5689b4fc6498df6",
"sha256:efd9d3abe5774404becdb0748178b48a218f1d8c44e0375475732211ea47c67e",
"sha256:f8c02ec3c4c4fcb718fdf89a6c6f709b14949408e8cf2a2be5bfa9c49548fd85",
"sha256:ffcf105ecdd9396e05a8e58e81faaaf34d3f9875f137c7372450baa5d77c9a54"
"sha256:0fe563fc8ed9dc4474cbf70742673fc4391d70f4363f917599a7fa99f042d5a8",
"sha256:12ac457b63ec8ded85d85c1e17d85efd3c2b0967ca39560b307a35a6703a4735",
"sha256:2341f4ab6dba0834b685cce16dad5f9b6606ea8a00e6da154f5dbded70fdc4dd",
"sha256:296d17aed51161dbad3c67ed6d164e51fcd18dbcd5dd4f9d0a9c6055dce30810",
"sha256:488a66cb667359534bc70028d653ba1cf307bae88eab5929cd707c761ff037db",
"sha256:4d52914c88b4930dafb6c48ba5115a96cbab40f45740239d9f4159c4ba779962",
"sha256:5e13030f8793e9ee42f9c7d5777465a560eb78fa7e11b1c053427f2ccab90c79",
"sha256:61be02e3bf810b60ab74e81d6d0d36246dbfb644a462458bb53b595791251911",
"sha256:7607b598217745cc40f751da38ffd03512d33ec06f3523fb0b5f82e09f6f676d",
"sha256:7a70a7d3ce4c0e9284e92285cba91a4a3f5214d87ee0e95928f3614a256a1488",
"sha256:7ab46e4e7ec63c8a5e6dbf5c1b9e1c92ba23a7ebecc86c336cb7bf3bd2fb10e5",
"sha256:8981d9b5619569899666170c7c9748920f4a5005bf79c72c07d08c8a035757b0",
"sha256:8c053d7557a8f022ec823196d242464b6955a7e7e5015b719e76003f63f82d0f",
"sha256:926db372bc4ac1edf81cfb6c59e2a881606b409ddc0d0920b988174b2e2a767f",
"sha256:95d79ada05005f6f4f337d3bb9de8a7774f259341c70bc88047a1f7b96a4bcb2",
"sha256:95de7dc7dc47a312f6feddd3da2500826defdccbc41608d0031276a24181a2c0",
"sha256:a0882323e0ca4245eb0a3d0a74f88ce581cc33aedcfa396e415e5bba7bf05f68",
"sha256:a8365b942f9c1a7d0f0dc974747d99dd0a0cdfc5949a33119caf05cb314682d3",
"sha256:a8aae2fb3180940011b4862b2dd3756616841c53db9734b27bb93813cd79fce6",
"sha256:c237129f0e732885c9a6076a537e974160482eab8f10db6292e92154d4c67d71",
"sha256:c67b833dbccefe97cdd3f52798d430b9d3430396af7cdb2a0c32954c3ef73894",
"sha256:ce03305dd694c4873b9429274fd41fc7eb4e0e4dea07e0af97a933b079a5814f",
"sha256:d331afac87c92373826af83d2b2b435f57b17a5c74e6268b79355b970626e329",
"sha256:dada341ebb79619fe00a291185bba370c9803b1e1d7051610e01ed809ef3a4ba",
"sha256:ed2cc92af0efad20198638c69bb0fc2870a58dabfba6eb722c933b48556c686c",
"sha256:f260da502d7441a45695199b4e7fd8ca87db659ba1c78f2bbf31f934fe76ae0e",
"sha256:f2f390aa4da44454db40a1f0201401f9036e8d578a25f01a6e237cea238337ef",
"sha256:f76025acc8e2114bb664294a07ede0727aa75d63a06d2fae96bf29a81747e4a7"
],
"markers": "python_version >= '3.7'",
"version": "==1.23.3"
"markers": "python_version >= '3.8'",
"version": "==1.23.4"
},
"opencv-python": {
"hashes": [

View File

@ -35,23 +35,25 @@ def ratio_pyro():
MIN_TEMP=float(request.form['min_temp'])
)
# img_orig_b64 = base64.b64encode(img_orig).decode()
img_orig_b64 = base64.b64encode(cv.imencode('.png', img_orig)[1]).decode(encoding='utf-8')
img_res_b64 = base64.b64encode(cv.imencode('.png', img_res)[1]).decode(encoding='utf-8')
# img_res_b64 = base64.b64encode(img_res).decode()
img_orig_fname = secure_filename(f'{f_name}.{f_ext}')
img_res_fname = secure_filename(f'{f_name}-{hex(int(random.random() * 10000000000000000000))}.{f_ext}')
# img_orig_fname = secure_filename(f'{f_name}.{f_ext}')
# img_res_fname = secure_filename(f'{f_name}-{hex(int(random.random() * 10000000000000000000))}.{f_ext}')
cv.imwrite(f'{app.config["STATIC_FOLDER"]}/{img_orig_fname}', img_orig)
cv.imwrite(f'{app.config["STATIC_FOLDER"]}/{img_res_fname}', img_res)
# cv.imwrite(f'{app.config["STATIC_FOLDER"]}/{img_orig_fname}', img_orig)
# cv.imwrite(f'{app.config["STATIC_FOLDER"]}/{img_res_fname}', img_res)
img_orig_path = f'{app.config["STATIC_URL_PATH"]}/{img_orig_fname}'
img_res_path = f'{app.config["STATIC_URL_PATH"]}/{img_res_fname}'
# img_orig_path = f'{app.config["STATIC_URL_PATH"]}/{img_orig_fname}'
# img_res_path = f'{app.config["STATIC_URL_PATH"]}/{img_res_fname}'
return render_template(
'results.jinja2',
img_orig_path=img_orig_path,
img_res_path=img_res_path,
# img_orig_b64=img_orig_b64,
# img_res_b64=img_res_b64,
# img_orig_path=img_orig_path,
# img_res_path=img_res_path,
img_orig_b64=img_orig_b64,
img_res_b64=img_res_b64,
legend=key
)

View File

@ -9,13 +9,13 @@
<tr>
{# Original image #}
<td class="img-table-cell" id="orig-cell">
{# <img src="data:image/png;base64,{{ img_orig_b64 }}" alt="original image"> #}
<img class="img-out" src="{{ img_orig_path }}" alt="original image">
<img class="img-out" src="data:image/png;base64,{{ img_orig_b64 }}" alt="original image">
{# <img class="img-out" src="{{ img_orig_path }}" alt="original image"> #}
</td>
{# Result image #}
<td class="img-table-cell" id="res-cell">
{# <img src="data:image/png;base64,{{ img_res_b64 }}" alt="result image"> #}
<img class="img-out" src="{{ img_res_path }}" alt="resulting heatmap">
<img class="img-out" src="data:image/png;base64,{{ img_res_b64 }}" alt="result image">
{# <img class="img-out" src="{{ img_res_path }}" alt="resulting heatmap"> #}
</td>
</tr>
{# Legend #}