Revert "Print correct filenames when files are skipped"

This reverts commit b0b93eb471.

Broke the webapp output.
This commit is contained in:
evazion
2022-06-29 14:47:29 -05:00
parent 24a842d847
commit 7c4f52f7d5
2 changed files with 4 additions and 6 deletions
+1 -1
View File
@@ -33,7 +33,7 @@ def main(files, threshold, limit, bs, csv, input_file, group_tags, name_only, mo
files = [click.open_file(filepath, "rb") for filepath in filepaths]
predictions = autotagger.predict(files, threshold=threshold, limit=limit, bs=bs)
for filepath, tags in predictions:
for filepath, tags in zip(filepaths, predictions):
output_result(filepath, tags, csv, group_tags, name_only)
def output_result(filepath, tags, csv, group_tags, name_only):
+3 -5
View File
@@ -35,14 +35,12 @@ class Autotagger:
except:
print("skipped file " + file.name, file=sys.stderr)
return None
images = [create_image(file) for file in files]
files = [files[i] for i in range(len(files)) if images[i] != None]
images = [image for image in images if image != None]
images = list(filter(lambda i: i != None, [create_image(file) for file in files]))
dl = self.learn.dls.test_dl(images, bs=bs)
batch, _ = self.learn.get_preds(dl=dl)
for scores, f in zip(batch, files):
for scores in batch:
df = DataFrame({ "tag": self.learn.dls.vocab, "score": scores })
df = df[df.score >= threshold].sort_values("score", ascending=False).head(limit)
tags = dict(zip(df.tag, df.score))
yield f.name, tags
yield tags