autotag: fix bug when reading file from stdin.

Another attempt at fixing #2. b216057 had a bug where you couldn't pass
a file through stdin because we tried to read the file twice, which we
can't do if the input is a pipe.
This commit is contained in:
evazion
2022-06-29 20:02:18 -05:00
parent 069af1c0c4
commit aaaae88e77
3 changed files with 13 additions and 12 deletions
+3 -1
View File
@@ -4,6 +4,7 @@ from os import getenv
from dotenv import load_dotenv
from autotagger import Autotagger
from base64 import b64encode
from fastai.vision.core import PILImage
from flask import Flask, request, render_template, jsonify, abort
from werkzeug.exceptions import HTTPException
@@ -26,7 +27,8 @@ def evaluate():
output = request.values.get("format", "html")
limit = int(request.values.get("limit", 50))
predictions = autotagger.predict(files, threshold=threshold, limit=limit)
images = [PILImage.create(file) for file in files]
predictions = autotagger.predict(images, threshold=threshold, limit=limit)
if output == "html":
for file in files: