diff --git a/demo/disease_report.py b/demo/disease_report.py index 81c5949dce..be46ec2657 100644 --- a/demo/disease_report.py +++ b/demo/disease_report.py @@ -1,5 +1,8 @@ import gradio as gr import numpy as np +from fpdf import FPDF +import os +import tempfile def disease_report(img, scan_for, generate_report): results = [] @@ -7,7 +10,18 @@ def disease_report(img, scan_for, generate_report): color_filter = np.array([0, 0, 0]) color_filter[i] = 1 results.append([mode, img * color_filter]) - return results, "files/titanic.csv" if generate_report else None + tmp_dir = tempfile.gettempdir() + report = os.path.join(tmp_dir, "report.pdf") + if generate_report: + pdf = FPDF() + pdf.add_page() + pdf.set_font("Arial", size=15) + pdf.cell(200, 10, txt="Disease Report", + ln=1, align='C') + pdf.cell(200, 10, txt="A Gradio Demo.", + ln=2, align='C') + pdf.output(report) + return results, report if generate_report else None iface = gr.Interface(disease_report, [ @@ -22,7 +36,8 @@ iface = gr.Interface(disease_report, title="Disease Report", description="Upload an Xray and select the diseases to scan for.", theme="compact", - flagging_options=["good", "bad", "etc"] + flagging_options=["good", "bad", "etc"], + allow_flagging="auto" ) if __name__ == "__main__": diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 37c5c23e5e..fa194df72e 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -2768,17 +2768,6 @@ "resolved": "https://registry.npmjs.org/@types/q/-/q-1.5.4.tgz", "integrity": "sha512-1HcDas8SEj4z1Wc696tH56G8OlRaH/sqZOynNNB+HF0WOeXPaxTtbYzJY2oEfiUxjSKjhCKr+MvR7dCHcEelug==" }, - "node_modules/@types/react": { - "version": "17.0.6", - "resolved": "https://registry.npmjs.org/@types/react/-/react-17.0.6.tgz", - "integrity": "sha512-u/TtPoF/hrvb63LdukET6ncaplYsvCvmkceasx8oG84/ZCsoLxz9Z/raPBP4lTAiWW1Jb889Y9svHmv8R26dWw==", - "peer": true, - "dependencies": { - "@types/prop-types": "*", - "@types/scheduler": "*", - "csstype": "^3.0.2" - } - }, "node_modules/@types/resolve": { "version": "0.0.8", "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-0.0.8.tgz", @@ -2787,12 +2776,6 @@ "@types/node": "*" } }, - "node_modules/@types/scheduler": { - "version": "0.16.1", - "resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.1.tgz", - "integrity": "sha512-EaCxbanVeyxDRTQBkdLb3Bvl/HK7PBK6UJjsSixB0iHKoWxE5uu2Q/DgtpOhPIojN0Zl1whvOd7PoHs2P0s5eA==", - "peer": true - }, "node_modules/@types/source-list-map": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/@types/source-list-map/-/source-list-map-0.1.2.tgz", @@ -3440,6 +3423,11 @@ "safe-buffer": "~5.1.0" } }, + "node_modules/arg": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/arg/-/arg-5.0.0.tgz", + "integrity": "sha512-4P8Zm2H+BRS+c/xX1LrHw0qKpEhdlZjLCgWy+d78T9vqa2Z2SiD2wMrYuWIAFy5IZUD7nnNXroRttz+0RzlrzQ==" + }, "node_modules/argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", @@ -4281,7 +4269,7 @@ "version": "2.6.12", "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.12.tgz", "integrity": "sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ==", - "deprecated": "core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.", + "deprecated": "core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.", "hasInstallScript": true }, "node_modules/babel-runtime/node_modules/regenerator-runtime": { @@ -6472,9 +6460,9 @@ } }, "node_modules/didyoumean": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/didyoumean/-/didyoumean-1.2.1.tgz", - "integrity": "sha1-6S7f2tplN9SE1zwBcv0eugxJdv8=" + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/didyoumean/-/didyoumean-1.2.2.tgz", + "integrity": "sha512-gxtyfqMg7GKyhQmb056K7M3xszy/myH8w+B4RT+QXBQsvAOdc3XymqDDPHx1BgPgsdAA5SIifona89YtRATDzw==" }, "node_modules/diff-sequences": { "version": "26.6.2", @@ -9149,45 +9137,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/glob-base": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/glob-base/-/glob-base-0.3.0.tgz", - "integrity": "sha1-27Fk9iIbHAscz4Kuoyi0l98Oo8Q=", - "dependencies": { - "glob-parent": "^2.0.0", - "is-glob": "^2.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/glob-base/node_modules/glob-parent": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-2.0.0.tgz", - "integrity": "sha1-gTg9ctsFT8zPUzbaqQLxgvbtuyg=", - "dependencies": { - "is-glob": "^2.0.0" - } - }, - "node_modules/glob-base/node_modules/is-extglob": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-1.0.0.tgz", - "integrity": "sha1-rEaBd8SUNAWgkvyPKXYMb/xiBsA=", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/glob-base/node_modules/is-glob": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz", - "integrity": "sha1-0Jb5JqPe1WAPP9/ZEZjLCIjC2GM=", - "dependencies": { - "is-extglob": "^1.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/glob-parent": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", @@ -10310,14 +10259,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/is-dotfile": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/is-dotfile/-/is-dotfile-1.0.3.tgz", - "integrity": "sha1-pqLzL/0t+wT1yiXs0Pa4PPeYoeE=", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/is-extendable": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", @@ -11786,6 +11727,14 @@ "node": ">= 0.8.0" } }, + "node_modules/lilconfig": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-2.0.3.tgz", + "integrity": "sha512-EHKqr/+ZvdKCifpNrJCKxBTgk5XupZA3y/aCPY9mxfgBzmgh93Mt/WqjjQ38oMxXuvDokaKiM3lAgvSH2sjtHg==", + "engines": { + "node": ">=10" + } + }, "node_modules/lines-and-columns": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.1.6.tgz", @@ -12880,9 +12829,9 @@ } }, "node_modules/object-hash": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/object-hash/-/object-hash-2.1.1.tgz", - "integrity": "sha512-VOJmgmS+7wvXf8CjbQmimtCnEx3IAoLxI3fp2fbWehxrWBcAQFbk+vcwb6vzR0VZv/eNCJ/27j151ZTwqW/JeQ==", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/object-hash/-/object-hash-2.2.0.tgz", + "integrity": "sha512-gScRMn0bS5fH+IuwyIFgnh9zBdo4DV+6GhygmWM9HyNJSgS0hScp1f5vjtm7oIIOiT9trXrShAkLFSc2IqKNgw==", "engines": { "node": ">= 6" } @@ -13288,39 +13237,6 @@ "safe-buffer": "^5.1.1" } }, - "node_modules/parse-glob": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/parse-glob/-/parse-glob-3.0.4.tgz", - "integrity": "sha1-ssN2z7EfNVE7rdFz7wu246OIORw=", - "dependencies": { - "glob-base": "^0.3.0", - "is-dotfile": "^1.0.0", - "is-extglob": "^1.0.0", - "is-glob": "^2.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/parse-glob/node_modules/is-extglob": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-1.0.0.tgz", - "integrity": "sha1-rEaBd8SUNAWgkvyPKXYMb/xiBsA=", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/parse-glob/node_modules/is-glob": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz", - "integrity": "sha1-0Jb5JqPe1WAPP9/ZEZjLCIjC2GM=", - "dependencies": { - "is-extglob": "^1.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/parse-json": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz", @@ -15253,14 +15169,25 @@ "node": ">= 6" } }, + "node_modules/purgecss/node_modules/nanoid": { + "version": "3.1.23", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.23.tgz", + "integrity": "sha512-FiB0kzdP0FFVGDKlRLEQ1BgDzU87dy5NnzjeW9YZNt+/c3+q82EQDUwniSAUxp/F0gFNI1ZhKU1FqYsMuqZVnw==", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, "node_modules/purgecss/node_modules/postcss": { - "version": "8.2.14", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.2.14.tgz", - "integrity": "sha512-+jD0ZijcvyCqPQo/m/CW0UcARpdFylq04of+Q7RKX6f/Tu+dvpUI/9Sp81+i6/vJThnOBX09Quw0ZLOVwpzX3w==", + "version": "8.3.5", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.3.5.tgz", + "integrity": "sha512-NxTuJocUhYGsMiMFHDUkmjSKT3EdH4/WbGF6GCi1NDGk+vbcUTun4fpbOqaPtD8IIsztA2ilZm2DhYCuyN58gA==", "dependencies": { "colorette": "^1.2.2", - "nanoid": "^3.1.22", - "source-map": "^0.6.1" + "nanoid": "^3.1.23", + "source-map-js": "^0.6.2" }, "engines": { "node": "^10 || ^12 || >=14" @@ -15303,6 +15230,7 @@ "version": "0.2.1", "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.1.tgz", "integrity": "sha512-wkvS7mL/JMugcup3/rMitHmd9ecIGd2lhFhK9N3UUQ450h66d1r3Y9nvXzQAW1Lq+wyx61k/1pfKS5KuKiyEbg==", + "deprecated": "The", "engines": { "node": ">=0.4.x" } @@ -16211,6 +16139,7 @@ "version": "3.4.0", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", + "deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.", "bin": { "uuid": "bin/uuid" } @@ -16680,6 +16609,7 @@ "version": "4.1.0", "resolved": "https://registry.npmjs.org/sane/-/sane-4.1.0.tgz", "integrity": "sha512-hhbzAgTIX8O7SHfp2c8/kREfEn4qO/9q8C9beyY6+tvZ87EpoZ3i1RIEvp27YBswnNbY9mWd6paKVmKbAgLfZA==", + "deprecated": "some dependency vulnerabilities fixed, support for node < 10 dropped, and newer ECMAScript syntax/features added", "dependencies": { "@cnakazawa/watch": "^1.0.3", "anymatch": "^2.0.0", @@ -17610,6 +17540,7 @@ "version": "3.4.0", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", + "deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.", "bin": { "uuid": "bin/uuid" } @@ -17638,6 +17569,14 @@ "node": ">=0.10.0" } }, + "node_modules/source-map-js": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-0.6.2.tgz", + "integrity": "sha512-/3GptzWzu0+0MBQFrDKzw/DvvMTUORvgY6k6jd/VS6iCR4RDTKWH6v6WPwQoUO8667uQEf9Oe38DxAYWY5F/Ug==", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/source-map-resolve": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.6.0.tgz", @@ -18379,46 +18318,184 @@ }, "node_modules/tailwindcss": { "name": "@tailwindcss/postcss7-compat", - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/@tailwindcss/postcss7-compat/-/postcss7-compat-2.1.2.tgz", - "integrity": "sha512-bH2kw6uyqLnDMP8wzDUsis5ovrsRzfHEyiL1McADvqlW54g6y0KVHX1xzO7PH8Fl5s0Sq8vDOAp4+3V8MEcZ9g==", + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/@tailwindcss/postcss7-compat/-/postcss7-compat-2.2.4.tgz", + "integrity": "sha512-lFIBdD1D2w3RgHFg7kNB7U5LOlfbd+KXTzcLyC/RlQ9eVko6GjNCKpN/kdmfF9wiGxbSDT/3mousXeMZdOOuBg==", "dependencies": { "@fullhuman/postcss-purgecss": "^3.1.3", + "arg": "^5.0.0", "autoprefixer": "^9", "bytes": "^3.0.0", - "chalk": "^4.1.0", - "chokidar": "^3.5.1", + "chalk": "^4.1.1", + "chokidar": "^3.5.2", "color": "^3.1.3", + "cosmiconfig": "^7.0.0", "detective": "^5.2.0", "didyoumean": "^1.2.1", "dlv": "^1.1.3", "fast-glob": "^3.2.5", - "fs-extra": "^9.1.0", + "fs-extra": "^10.0.0", + "glob-parent": "^6.0.0", "html-tags": "^3.1.0", + "is-glob": "^4.0.1", "lodash": "^4.17.21", "lodash.topath": "^4.5.2", - "modern-normalize": "^1.0.0", + "modern-normalize": "^1.1.0", "node-emoji": "^1.8.1", "normalize-path": "^3.0.0", - "object-hash": "^2.1.1", - "parse-glob": "^3.0.4", + "object-hash": "^2.2.0", "postcss": "^7", "postcss-functions": "^3", "postcss-js": "^2", + "postcss-load-config": "^3.1.0", "postcss-nested": "^4", - "postcss-selector-parser": "^6.0.4", + "postcss-selector-parser": "^6.0.6", "postcss-value-parser": "^4.1.0", "pretty-hrtime": "^1.0.3", "quick-lru": "^5.1.1", "reduce-css-calc": "^2.1.8", - "resolve": "^1.20.0" - }, - "bin": { - "tailwind": "lib/cli.js", - "tailwindcss": "lib/cli.js" + "resolve": "^1.20.0", + "tmp": "^0.2.1" + } + }, + "node_modules/tailwindcss/node_modules/chalk": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.1.tgz", + "integrity": "sha512-diHzdDKxcU+bAsUboHLPEDQiw0qEe0qd7SYUn3HgcFlWgbDcfLGswOHYeGrHKzG9z6UYf01d9VFMfZxPM1xZSg==", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" }, "engines": { - "node": ">=12.13.0" + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/tailwindcss/node_modules/chokidar": { + "version": "3.5.2", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.2.tgz", + "integrity": "sha512-ekGhOnNVPgT77r4K/U3GDhu+FQ2S8TnK/s2KbIGXi0SZWuwkZ2QNyfWdZW+TVfn84DpEP7rLeCt2UI6bJ8GwbQ==", + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/tailwindcss/node_modules/chokidar/node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/tailwindcss/node_modules/fs-extra": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.0.0.tgz", + "integrity": "sha512-C5owb14u9eJwizKGdchcDUQeFtlSHHthBk8pbX9Vc1PFZrLombudjDnNns88aYslCyF6IY5SUw3Roz6xShcEIQ==", + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/tailwindcss/node_modules/glob-parent": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.0.tgz", + "integrity": "sha512-Hdd4287VEJcZXUwv1l8a+vXC1GjOQqXe+VS30w/ypihpcnu9M1n3xeYeJu5CBpeEQj2nAab2xxz28GuA3vp4Ww==", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/tailwindcss/node_modules/import-cwd": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/import-cwd/-/import-cwd-3.0.0.tgz", + "integrity": "sha512-4pnzH16plW+hgvRECbDWpQl3cqtvSofHWh44met7ESfZ8UZOWWddm8hEyDTqREJ9RbYHY8gi8DqmaelApoOGMg==", + "dependencies": { + "import-from": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/tailwindcss/node_modules/import-from": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/import-from/-/import-from-3.0.0.tgz", + "integrity": "sha512-CiuXOFFSzkU5x/CR0+z7T91Iht4CXgfCxVOFRhh2Zyhg5wOpWvvDLQUsWl+gcN+QscYBjez8hDCt85O7RLDttQ==", + "dependencies": { + "resolve-from": "^5.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/tailwindcss/node_modules/postcss-load-config": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/postcss-load-config/-/postcss-load-config-3.1.0.tgz", + "integrity": "sha512-ipM8Ds01ZUophjDTQYSVP70slFSYg3T0/zyfII5vzhN6V57YSxMgG5syXuwi5VtS8wSf3iL30v0uBdoIVx4Q0g==", + "dependencies": { + "import-cwd": "^3.0.0", + "lilconfig": "^2.0.3", + "yaml": "^1.10.2" + }, + "engines": { + "node": ">= 10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + "peerDependencies": { + "ts-node": ">=9.0.0" + }, + "peerDependenciesMeta": { + "ts-node": { + "optional": true + } + } + }, + "node_modules/tailwindcss/node_modules/postcss-selector-parser": { + "version": "6.0.6", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.0.6.tgz", + "integrity": "sha512-9LXrvaaX3+mcv5xkg5kFwqSzSH1JIObIx51PrndZwlmznwXRfxMddDvo9gve3gVR8ZTKgoFDdWkbRFmEhT4PMg==", + "dependencies": { + "cssesc": "^3.0.0", + "util-deprecate": "^1.0.2" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/tailwindcss/node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" } }, "node_modules/tailwindcss/node_modules/resolve": { @@ -18743,6 +18820,17 @@ "resolved": "https://registry.npmjs.org/timsort/-/timsort-0.3.0.tgz", "integrity": "sha1-QFQRqOfmM5/mTbmiNN4R3DHgK9Q=" }, + "node_modules/tmp": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.1.tgz", + "integrity": "sha512-76SUhtfqR2Ijn+xllcI5P1oyannHNHByD80W1q447gU3mp9G9PSpGdWmjUOHRDPiHYacIk66W7ubDTuPF3BEtQ==", + "dependencies": { + "rimraf": "^3.0.0" + }, + "engines": { + "node": ">=8.17.0" + } + }, "node_modules/tmpl": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.4.tgz", @@ -19022,19 +19110,6 @@ "is-typedarray": "^1.0.0" } }, - "node_modules/typescript": { - "version": "4.2.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.2.4.tgz", - "integrity": "sha512-V+evlYHZnQkaz8TRBuxTA92yZBPotr5H+WhQ7bD3hZUndx5tGOa1fuCgeSjxAzM1RiN5IzvadIXTVefuuwZCRg==", - "peer": true, - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=4.2.0" - } - }, "node_modules/unbox-primitive": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.1.tgz", @@ -19302,6 +19377,7 @@ "version": "0.2.0", "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz", "integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=", + "deprecated": "The", "engines": { "node": ">=0.4.x" } @@ -20513,6 +20589,7 @@ "version": "3.4.0", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", + "deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.", "bin": { "uuid": "bin/uuid" } @@ -23511,17 +23588,6 @@ "resolved": "https://registry.npmjs.org/@types/q/-/q-1.5.4.tgz", "integrity": "sha512-1HcDas8SEj4z1Wc696tH56G8OlRaH/sqZOynNNB+HF0WOeXPaxTtbYzJY2oEfiUxjSKjhCKr+MvR7dCHcEelug==" }, - "@types/react": { - "version": "17.0.6", - "resolved": "https://registry.npmjs.org/@types/react/-/react-17.0.6.tgz", - "integrity": "sha512-u/TtPoF/hrvb63LdukET6ncaplYsvCvmkceasx8oG84/ZCsoLxz9Z/raPBP4lTAiWW1Jb889Y9svHmv8R26dWw==", - "peer": true, - "requires": { - "@types/prop-types": "*", - "@types/scheduler": "*", - "csstype": "^3.0.2" - } - }, "@types/resolve": { "version": "0.0.8", "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-0.0.8.tgz", @@ -23530,12 +23596,6 @@ "@types/node": "*" } }, - "@types/scheduler": { - "version": "0.16.1", - "resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.1.tgz", - "integrity": "sha512-EaCxbanVeyxDRTQBkdLb3Bvl/HK7PBK6UJjsSixB0iHKoWxE5uu2Q/DgtpOhPIojN0Zl1whvOd7PoHs2P0s5eA==", - "peer": true - }, "@types/source-list-map": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/@types/source-list-map/-/source-list-map-0.1.2.tgz", @@ -24049,6 +24109,11 @@ } } }, + "arg": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/arg/-/arg-5.0.0.tgz", + "integrity": "sha512-4P8Zm2H+BRS+c/xX1LrHw0qKpEhdlZjLCgWy+d78T9vqa2Z2SiD2wMrYuWIAFy5IZUD7nnNXroRttz+0RzlrzQ==" + }, "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", @@ -26480,9 +26545,9 @@ } }, "didyoumean": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/didyoumean/-/didyoumean-1.2.1.tgz", - "integrity": "sha1-6S7f2tplN9SE1zwBcv0eugxJdv8=" + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/didyoumean/-/didyoumean-1.2.2.tgz", + "integrity": "sha512-gxtyfqMg7GKyhQmb056K7M3xszy/myH8w+B4RT+QXBQsvAOdc3XymqDDPHx1BgPgsdAA5SIifona89YtRATDzw==" }, "diff-sequences": { "version": "26.6.2", @@ -28601,38 +28666,6 @@ "path-is-absolute": "^1.0.0" } }, - "glob-base": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/glob-base/-/glob-base-0.3.0.tgz", - "integrity": "sha1-27Fk9iIbHAscz4Kuoyi0l98Oo8Q=", - "requires": { - "glob-parent": "^2.0.0", - "is-glob": "^2.0.0" - }, - "dependencies": { - "glob-parent": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-2.0.0.tgz", - "integrity": "sha1-gTg9ctsFT8zPUzbaqQLxgvbtuyg=", - "requires": { - "is-glob": "^2.0.0" - } - }, - "is-extglob": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-1.0.0.tgz", - "integrity": "sha1-rEaBd8SUNAWgkvyPKXYMb/xiBsA=" - }, - "is-glob": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz", - "integrity": "sha1-0Jb5JqPe1WAPP9/ZEZjLCIjC2GM=", - "requires": { - "is-extglob": "^1.0.0" - } - } - } - }, "glob-parent": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", @@ -29492,11 +29525,6 @@ "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.0.tgz", "integrity": "sha512-K4GwB4i/HzhAzwP/XSlspzRdFTI9N8OxJOyOU7Y5Rz+p+WBokXWVWblaJeBkggthmoSV0OoGTH5thJNvplpkvQ==" }, - "is-dotfile": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/is-dotfile/-/is-dotfile-1.0.3.tgz", - "integrity": "sha1-pqLzL/0t+wT1yiXs0Pa4PPeYoeE=" - }, "is-extendable": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", @@ -30619,6 +30647,11 @@ "type-check": "~0.4.0" } }, + "lilconfig": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-2.0.3.tgz", + "integrity": "sha512-EHKqr/+ZvdKCifpNrJCKxBTgk5XupZA3y/aCPY9mxfgBzmgh93Mt/WqjjQ38oMxXuvDokaKiM3lAgvSH2sjtHg==" + }, "lines-and-columns": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.1.6.tgz", @@ -31515,9 +31548,9 @@ } }, "object-hash": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/object-hash/-/object-hash-2.1.1.tgz", - "integrity": "sha512-VOJmgmS+7wvXf8CjbQmimtCnEx3IAoLxI3fp2fbWehxrWBcAQFbk+vcwb6vzR0VZv/eNCJ/27j151ZTwqW/JeQ==" + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/object-hash/-/object-hash-2.2.0.tgz", + "integrity": "sha512-gScRMn0bS5fH+IuwyIFgnh9zBdo4DV+6GhygmWM9HyNJSgS0hScp1f5vjtm7oIIOiT9trXrShAkLFSc2IqKNgw==" }, "object-inspect": { "version": "1.9.0", @@ -31816,32 +31849,6 @@ "safe-buffer": "^5.1.1" } }, - "parse-glob": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/parse-glob/-/parse-glob-3.0.4.tgz", - "integrity": "sha1-ssN2z7EfNVE7rdFz7wu246OIORw=", - "requires": { - "glob-base": "^0.3.0", - "is-dotfile": "^1.0.0", - "is-extglob": "^1.0.0", - "is-glob": "^2.0.0" - }, - "dependencies": { - "is-extglob": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-1.0.0.tgz", - "integrity": "sha1-rEaBd8SUNAWgkvyPKXYMb/xiBsA=" - }, - "is-glob": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz", - "integrity": "sha1-0Jb5JqPe1WAPP9/ZEZjLCIjC2GM=", - "requires": { - "is-extglob": "^1.0.0" - } - } - } - }, "parse-json": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz", @@ -33418,14 +33425,19 @@ "resolved": "https://registry.npmjs.org/commander/-/commander-6.2.1.tgz", "integrity": "sha512-U7VdrJFnJgo4xjrHpTzu0yrHPGImdsmD95ZlgYSEajAn2JKzDhDTPG9kBTefmObL2w/ngeZnilk+OV9CG3d7UA==" }, + "nanoid": { + "version": "3.1.23", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.23.tgz", + "integrity": "sha512-FiB0kzdP0FFVGDKlRLEQ1BgDzU87dy5NnzjeW9YZNt+/c3+q82EQDUwniSAUxp/F0gFNI1ZhKU1FqYsMuqZVnw==" + }, "postcss": { - "version": "8.2.14", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.2.14.tgz", - "integrity": "sha512-+jD0ZijcvyCqPQo/m/CW0UcARpdFylq04of+Q7RKX6f/Tu+dvpUI/9Sp81+i6/vJThnOBX09Quw0ZLOVwpzX3w==", + "version": "8.3.5", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.3.5.tgz", + "integrity": "sha512-NxTuJocUhYGsMiMFHDUkmjSKT3EdH4/WbGF6GCi1NDGk+vbcUTun4fpbOqaPtD8IIsztA2ilZm2DhYCuyN58gA==", "requires": { "colorette": "^1.2.2", - "nanoid": "^3.1.22", - "source-map": "^0.6.1" + "nanoid": "^3.1.23", + "source-map-js": "^0.6.2" } } } @@ -35291,6 +35303,11 @@ "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==" }, + "source-map-js": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-0.6.2.tgz", + "integrity": "sha512-/3GptzWzu0+0MBQFrDKzw/DvvMTUORvgY6k6jd/VS6iCR4RDTKWH6v6WPwQoUO8667uQEf9Oe38DxAYWY5F/Ug==" + }, "source-map-resolve": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.6.0.tgz", @@ -35892,41 +35909,141 @@ } }, "tailwindcss": { - "version": "npm:@tailwindcss/postcss7-compat@2.1.2", - "resolved": "https://registry.npmjs.org/@tailwindcss/postcss7-compat/-/postcss7-compat-2.1.2.tgz", - "integrity": "sha512-bH2kw6uyqLnDMP8wzDUsis5ovrsRzfHEyiL1McADvqlW54g6y0KVHX1xzO7PH8Fl5s0Sq8vDOAp4+3V8MEcZ9g==", + "version": "npm:@tailwindcss/postcss7-compat@2.2.4", + "resolved": "https://registry.npmjs.org/@tailwindcss/postcss7-compat/-/postcss7-compat-2.2.4.tgz", + "integrity": "sha512-lFIBdD1D2w3RgHFg7kNB7U5LOlfbd+KXTzcLyC/RlQ9eVko6GjNCKpN/kdmfF9wiGxbSDT/3mousXeMZdOOuBg==", "requires": { "@fullhuman/postcss-purgecss": "^3.1.3", + "arg": "^5.0.0", "autoprefixer": "^9", "bytes": "^3.0.0", - "chalk": "^4.1.0", - "chokidar": "^3.5.1", + "chalk": "^4.1.1", + "chokidar": "^3.5.2", "color": "^3.1.3", + "cosmiconfig": "^7.0.0", "detective": "^5.2.0", "didyoumean": "^1.2.1", "dlv": "^1.1.3", "fast-glob": "^3.2.5", - "fs-extra": "^9.1.0", + "fs-extra": "^10.0.0", + "glob-parent": "^6.0.0", "html-tags": "^3.1.0", + "is-glob": "^4.0.1", "lodash": "^4.17.21", "lodash.topath": "^4.5.2", - "modern-normalize": "^1.0.0", + "modern-normalize": "^1.1.0", "node-emoji": "^1.8.1", "normalize-path": "^3.0.0", - "object-hash": "^2.1.1", - "parse-glob": "^3.0.4", + "object-hash": "^2.2.0", "postcss": "^7", "postcss-functions": "^3", "postcss-js": "^2", + "postcss-load-config": "^3.1.0", "postcss-nested": "^4", - "postcss-selector-parser": "^6.0.4", + "postcss-selector-parser": "^6.0.6", "postcss-value-parser": "^4.1.0", "pretty-hrtime": "^1.0.3", "quick-lru": "^5.1.1", "reduce-css-calc": "^2.1.8", - "resolve": "^1.20.0" + "resolve": "^1.20.0", + "tmp": "^0.2.1" }, "dependencies": { + "chalk": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.1.tgz", + "integrity": "sha512-diHzdDKxcU+bAsUboHLPEDQiw0qEe0qd7SYUn3HgcFlWgbDcfLGswOHYeGrHKzG9z6UYf01d9VFMfZxPM1xZSg==", + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "chokidar": { + "version": "3.5.2", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.2.tgz", + "integrity": "sha512-ekGhOnNVPgT77r4K/U3GDhu+FQ2S8TnK/s2KbIGXi0SZWuwkZ2QNyfWdZW+TVfn84DpEP7rLeCt2UI6bJ8GwbQ==", + "requires": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "fsevents": "~2.3.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "dependencies": { + "glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "requires": { + "is-glob": "^4.0.1" + } + } + } + }, + "fs-extra": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.0.0.tgz", + "integrity": "sha512-C5owb14u9eJwizKGdchcDUQeFtlSHHthBk8pbX9Vc1PFZrLombudjDnNns88aYslCyF6IY5SUw3Roz6xShcEIQ==", + "requires": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + } + }, + "glob-parent": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.0.tgz", + "integrity": "sha512-Hdd4287VEJcZXUwv1l8a+vXC1GjOQqXe+VS30w/ypihpcnu9M1n3xeYeJu5CBpeEQj2nAab2xxz28GuA3vp4Ww==", + "requires": { + "is-glob": "^4.0.1" + } + }, + "import-cwd": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/import-cwd/-/import-cwd-3.0.0.tgz", + "integrity": "sha512-4pnzH16plW+hgvRECbDWpQl3cqtvSofHWh44met7ESfZ8UZOWWddm8hEyDTqREJ9RbYHY8gi8DqmaelApoOGMg==", + "requires": { + "import-from": "^3.0.0" + } + }, + "import-from": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/import-from/-/import-from-3.0.0.tgz", + "integrity": "sha512-CiuXOFFSzkU5x/CR0+z7T91Iht4CXgfCxVOFRhh2Zyhg5wOpWvvDLQUsWl+gcN+QscYBjez8hDCt85O7RLDttQ==", + "requires": { + "resolve-from": "^5.0.0" + } + }, + "postcss-load-config": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/postcss-load-config/-/postcss-load-config-3.1.0.tgz", + "integrity": "sha512-ipM8Ds01ZUophjDTQYSVP70slFSYg3T0/zyfII5vzhN6V57YSxMgG5syXuwi5VtS8wSf3iL30v0uBdoIVx4Q0g==", + "requires": { + "import-cwd": "^3.0.0", + "lilconfig": "^2.0.3", + "yaml": "^1.10.2" + } + }, + "postcss-selector-parser": { + "version": "6.0.6", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.0.6.tgz", + "integrity": "sha512-9LXrvaaX3+mcv5xkg5kFwqSzSH1JIObIx51PrndZwlmznwXRfxMddDvo9gve3gVR8ZTKgoFDdWkbRFmEhT4PMg==", + "requires": { + "cssesc": "^3.0.0", + "util-deprecate": "^1.0.2" + } + }, + "readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "requires": { + "picomatch": "^2.2.1" + } + }, "resolve": { "version": "1.20.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.20.0.tgz", @@ -36171,6 +36288,14 @@ "resolved": "https://registry.npmjs.org/timsort/-/timsort-0.3.0.tgz", "integrity": "sha1-QFQRqOfmM5/mTbmiNN4R3DHgK9Q=" }, + "tmp": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.1.tgz", + "integrity": "sha512-76SUhtfqR2Ijn+xllcI5P1oyannHNHByD80W1q447gU3mp9G9PSpGdWmjUOHRDPiHYacIk66W7ubDTuPF3BEtQ==", + "requires": { + "rimraf": "^3.0.0" + } + }, "tmpl": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.4.tgz", @@ -36393,12 +36518,6 @@ "is-typedarray": "^1.0.0" } }, - "typescript": { - "version": "4.2.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.2.4.tgz", - "integrity": "sha512-V+evlYHZnQkaz8TRBuxTA92yZBPotr5H+WhQ7bD3hZUndx5tGOa1fuCgeSjxAzM1RiN5IzvadIXTVefuuwZCRg==", - "peer": true - }, "unbox-primitive": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.1.tgz", diff --git a/frontend/src/gradio.jsx b/frontend/src/gradio.jsx index 9e79e8d2f9..aadf13017e 100644 --- a/frontend/src/gradio.jsx +++ b/frontend/src/gradio.jsx @@ -41,6 +41,7 @@ export class GradioInterface extends React.Component { state["just_flagged"] = false; state["has_changed"] = false; state["example_id"] = null; + state["flag_index"] = null; return state; } clear() { @@ -54,13 +55,19 @@ export class GradioInterface extends React.Component { } input_state[i] = this.state[i]; } - this.setState({ "submitting": true, "has_changed": false, "error": false }); + this.setState({ "submitting": true, "has_changed": false, "error": false, "flag_index": null }); this.props.fn(input_state, "predict").then(output => { let index_start = this.props.input_components.length; + let new_state = {}; for (let [i, value] of output["data"].entries()) { - this.setState({ [index_start + i]: value }); + new_state[index_start + i] = value; } - this.setState({ "submitting": false, "complete": true }); + if (output["flag_index"] !== null) { + new_state["flag_index"] = output["flag_index"]; + } + new_state["submitting"] = false + new_state["complete"] = true + this.setState(new_state) if (this.props.live && this.state.has_changed) { this.submit(); } @@ -77,11 +84,15 @@ export class GradioInterface extends React.Component { return; } let component_state = { "input_data": [], "output_data": [] }; - for (let i = 0; i < this.props.input_components.length; i++) { - component_state["input_data"].push(this.state[i]); - } - for (let i = 0; i < this.props.output_components.length; i++) { - component_state["output_data"].push(this.state[this.props.input_components.length + i]); + if (this.state.flag_index !== undefined) { + component_state["flag_index"] = this.state.flag_index; + } else { + for (let i = 0; i < this.props.input_components.length; i++) { + component_state["input_data"].push(this.state[i]); + } + for (let i = 0; i < this.props.output_components.length; i++) { + component_state["output_data"].push(this.state[this.props.input_components.length + i]); + } } this.setState({ "just_flagged": true }); window.setTimeout(() => { diff --git a/frontend/src/interfaces/input/checkbox_group.jsx b/frontend/src/interfaces/input/checkbox_group.jsx index e409292e4c..cc618c7393 100644 --- a/frontend/src/interfaces/input/checkbox_group.jsx +++ b/frontend/src/interfaces/input/checkbox_group.jsx @@ -9,7 +9,7 @@ class CheckboxGroupInput extends React.Component { this.handleChange = this.handleChange.bind(this); } handleChange(selected_item) { - let all_selected = this.props.value; + let all_selected = [...this.props.value]; if (all_selected.includes(selected_item)) { all_selected = all_selected.filter(item => item !== selected_item); } else { diff --git a/frontend/src/interfaces/input/textbox.jsx b/frontend/src/interfaces/input/textbox.jsx index 5713cf295b..aeea8c38d8 100644 --- a/frontend/src/interfaces/input/textbox.jsx +++ b/frontend/src/interfaces/input/textbox.jsx @@ -22,7 +22,7 @@ class TextboxInput extends React.Component { } else if (this.props.lines > 1) { return (
-
) diff --git a/gradio.egg-info/PKG-INFO b/gradio.egg-info/PKG-INFO index 70598f2a22..8f8acbae29 100644 --- a/gradio.egg-info/PKG-INFO +++ b/gradio.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: gradio -Version: 2.1.1 +Version: 2.1.3 Summary: Python library for easily interacting with trained machine learning models Home-page: https://github.com/gradio-app/gradio-UI Author: Abubakar Abid diff --git a/gradio.egg-info/SOURCES.txt b/gradio.egg-info/SOURCES.txt index 7dfee2f1cf..d6e8ec5b08 100644 --- a/gradio.egg-info/SOURCES.txt +++ b/gradio.egg-info/SOURCES.txt @@ -27,6 +27,14 @@ gradio.egg-info/requires.txt gradio.egg-info/top_level.txt gradio/frontend/asset-manifest.json gradio/frontend/index.html +gradio/frontend/static/bundle.css +gradio/frontend/static/bundle.css.map +gradio/frontend/static/bundle.js +gradio/frontend/static/bundle.js.LICENSE.txt +gradio/frontend/static/bundle.js.map +gradio/frontend/static/css/main.bc3b604e.css +gradio/frontend/static/css/main.bc3b604e.css.map +gradio/frontend/static/media/logo_loading.e93acd82.jpg test/test_demos.py test/test_inputs.py test/test_interfaces.py diff --git a/gradio.egg-info/requires.txt b/gradio.egg-info/requires.txt index 8e565209f9..b6135b3e41 100644 --- a/gradio.egg-info/requires.txt +++ b/gradio.egg-info/requires.txt @@ -1,15 +1,15 @@ -numpy -scipy -matplotlib -pandas -pillow +Flask-Cors>=3.0.8 +Flask-Login +Flask>=1.1.1 +analytics-python ffmpy +flask-cachebuster markdown2 +matplotlib +numpy +pandas +paramiko +pillow pycryptodome requests -paramiko -analytics-python -Flask>=1.1.1 -Flask-Cors>=3.0.8 -flask-cachebuster -Flask-Login +scipy diff --git a/gradio/frontend/asset-manifest.json b/gradio/frontend/asset-manifest.json index cf17eb2589..c6b750efc4 100644 --- a/gradio/frontend/asset-manifest.json +++ b/gradio/frontend/asset-manifest.json @@ -1,17 +1,17 @@ { "files": { - "main.css": "/static/css/main.0094f11b.css", + "main.css": "/static/css/main.bc3b604e.css", "main.js": "/static/bundle.js", "main.js.map": "/static/bundle.js.map", "index.html": "/index.html", "static/bundle.css.map": "/static/bundle.css.map", "static/bundle.js.LICENSE.txt": "/static/bundle.js.LICENSE.txt", - "static/css/main.0094f11b.css.map": "/static/css/main.0094f11b.css.map", + "static/css/main.bc3b604e.css.map": "/static/css/main.bc3b604e.css.map", "static/media/logo_loading.e93acd82.jpg": "/static/media/logo_loading.e93acd82.jpg" }, "entrypoints": [ "static/bundle.css", - "static/css/main.0094f11b.css", + "static/css/main.bc3b604e.css", "static/bundle.js" ] } \ No newline at end of file diff --git a/gradio/frontend/index.html b/gradio/frontend/index.html index 1674f8a90c..93c9237390 100644 --- a/gradio/frontend/index.html +++ b/gradio/frontend/index.html @@ -8,4 +8,4 @@ window.config = {{ config|tojson }}; } catch (e) { window.config = {}; - }Gradio
\ No newline at end of file + }Gradio
\ No newline at end of file diff --git a/gradio/networking.py b/gradio/networking.py index cb8516887b..6796fd0fa9 100644 --- a/gradio/networking.py +++ b/gradio/networking.py @@ -12,6 +12,7 @@ from flask_cors import CORS import threading import pkg_resources from distutils import dir_util +import datetime import time import json import urllib.request @@ -179,8 +180,12 @@ def predict(): output = {"data": prediction, "durations": durations} if app.interface.allow_flagging == "auto": try: - flag_data(raw_input, prediction) - except: + flag_index = flag_data(raw_input, prediction, + flag_option=(None if app.interface.flagging_options is None else ""), + username=current_user.id if current_user.is_authenticated else None) + output["flag_index"] = flag_index + except Exception as e: + print(str(e)) pass return jsonify(output) @@ -274,29 +279,47 @@ def predict_examples(): return jsonify(output) -def flag_data(input_data, output_data, flag_option=None): +def flag_data(input_data, output_data, flag_option=None, flag_index=None, username=None): flag_path = os.path.join(app.cwd, app.interface.flagging_dir) - csv_data = [] - encryption_key = app.interface.encryption_key if app.interface.encrypt else None - for i, interface in enumerate(app.interface.input_components): - csv_data.append(interface.save_flagged( - flag_path, app.interface.config["input_components"][i]["label"], input_data[i], encryption_key)) - for i, interface in enumerate(app.interface.output_components): - csv_data.append(interface.save_flagged( - flag_path, app.interface.config["output_components"][i]["label"], output_data[i], encryption_key)) - if flag_option: - csv_data.append(flag_option) - - headers = [interface["label"] - for interface in app.interface.config["input_components"]] - headers += [interface["label"] - for interface in app.interface.config["output_components"]] - if app.interface.flagging_options is not None: - headers.append("flag") - log_fp = "{}/log.csv".format(flag_path) + encryption_key = app.interface.encryption_key if app.interface.encrypt else None is_new = not os.path.exists(log_fp) + if flag_index is None: + csv_data = [] + for i, interface in enumerate(app.interface.input_components): + csv_data.append(interface.save_flagged( + flag_path, app.interface.config["input_components"][i]["label"], input_data[i], encryption_key)) + for i, interface in enumerate(app.interface.output_components): + csv_data.append(interface.save_flagged( + flag_path, app.interface.config["output_components"][i]["label"], output_data[i], encryption_key) if output_data[i] is not None else "") + if flag_option is not None: + csv_data.append(flag_option) + if username is not None: + csv_data.append(username) + csv_data.append(str(datetime.datetime.now())) + if is_new: + headers = [interface["label"] + for interface in app.interface.config["input_components"]] + headers += [interface["label"] + for interface in app.interface.config["output_components"]] + if app.interface.flagging_options is not None: + headers.append("flag") + if username is not None: + headers.append("username") + headers.append("timestamp") + + def replace_flag_at_index(file_content): + file_content = io.StringIO(file_content) + content = list(csv.reader(file_content)) + header = content[0] + flag_col_index = header.index("flag") + content[flag_index][flag_col_index] = flag_option + output = io.StringIO() + writer = csv.writer(output) + writer.writerows(content) + return output.getvalue() + if app.interface.encrypt: output = io.StringIO() if not is_new: @@ -304,28 +327,42 @@ def flag_data(input_data, output_data, flag_option=None): encrypted_csv = csvfile.read() decrypted_csv = encryptor.decrypt( app.interface.encryption_key, encrypted_csv) - output.write(decrypted_csv.decode()) + file_content = decrypted_csv.decode() + if flag_index is not None: + file_content = replace_flag_at_index(file_content) + output.write(file_content) writer = csv.writer(output) - if is_new: - writer.writerow(headers) - writer.writerow(csv_data) + if flag_index is None: + if is_new: + writer.writerow(headers) + writer.writerow(csv_data) with open(log_fp, "wb") as csvfile: csvfile.write(encryptor.encrypt( app.interface.encryption_key, output.getvalue().encode())) else: - with open(log_fp, "a") as csvfile: - writer = csv.writer(csvfile) - if is_new: - writer.writerow(headers) - writer.writerow(csv_data) - + if flag_index is None: + with open(log_fp, "a") as csvfile: + writer = csv.writer(csvfile) + if is_new: + writer.writerow(headers) + writer.writerow(csv_data) + else: + with open(log_fp) as csvfile: + file_content = csvfile.read() + file_content = replace_flag_at_index(file_content) + with open(log_fp, "w") as csvfile: + csvfile.write(file_content) + with open(log_fp, "r") as csvfile: + line_count = len([None for row in csv.reader(csvfile)]) - 1 + return line_count @app.route("/api/flag/", methods=["POST"]) @login_check def flag(): log_feature_analytics('flag') data = request.json['data'] - flag_data(data['input_data'], data['output_data'], data.get("flag_option")) + flag_data(data['input_data'], data['output_data'], data.get("flag_option"), data.get("flag_index"), + current_user.id if current_user.is_authenticated else None) return jsonify(success=True) diff --git a/gradio/outputs.py b/gradio/outputs.py index ccf82301c1..74a9298622 100644 --- a/gradio/outputs.py +++ b/gradio/outputs.py @@ -537,6 +537,14 @@ class Carousel(OutputComponent): else: raise ValueError("Unknown type. Please provide a list for the Carousel.") + def save_flagged(self, dir, label, data, encryption_key): + return json.dumps([ + [ + component.save_flagged(dir, f"{label}_{j}", data[i][j], encryption_key) + for j, component in enumerate(self.components) + ] for i, sample in enumerate(data)]) + + def get_output_instance(iface): if isinstance(iface, str): diff --git a/gradio/version.txt b/gradio/version.txt index 3e3c2f1e5e..ac2cdeba01 100644 --- a/gradio/version.txt +++ b/gradio/version.txt @@ -1 +1 @@ -2.1.1 +2.1.3 diff --git a/setup.py b/setup.py index ec1d4e1082..72efeed547 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ except ImportError: setup( name='gradio', - version='2.1.1', + version='2.1.3', include_package_data=True, description='Python library for easily interacting with trained machine learning models', author='Abubakar Abid', diff --git a/upload_to_pypi.sh b/upload_to_pypi.sh index eb9f689609..51b482e729 100755 --- a/upload_to_pypi.sh +++ b/upload_to_pypi.sh @@ -24,8 +24,8 @@ fi rm -r dist/* rm -r build/* -python setup.py sdist bdist_wheel -python -m twine upload dist/* +python3 setup.py sdist bdist_wheel +python3 -m twine upload dist/* git add -A git commit -m "updated PyPi version" git push origin master