From 732d3d0c8c12a5df7d1c1207e840e43533242d9f Mon Sep 17 00:00:00 2001 From: Fauzaan Qureshi <42518372+FauzaanQureshi@users.noreply.github.com> Date: Wed, 10 Feb 2021 16:17:59 +0530 Subject: [PATCH 1/3] Update preprocess method in Video class In preprocess method of Video class, included ff.run() in the if body so that no conversion occurs if self.type is None. --- gradio/inputs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradio/inputs.py b/gradio/inputs.py index a974fd70c3..daa269d59b 100644 --- a/gradio/inputs.py +++ b/gradio/inputs.py @@ -760,7 +760,7 @@ class Video(InputComponent): outputs={file_name + "." + self.type: None} ) file_name += "." + self.type - ff.run() + ff.run() return file_name def preprocess_example(self, x): From 14d2f772e5acf0f2e6a6357c6a14437171670c51 Mon Sep 17 00:00:00 2001 From: Ali Abid Date: Thu, 11 Feb 2021 09:30:06 -0800 Subject: [PATCH 2/3] flag styling --- gradio/static/css/gradio.css | 10 +++++----- gradio/static/js/gradio.js | 6 +----- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/gradio/static/css/gradio.css b/gradio/static/css/gradio.css index 96b9ff07cc..226f9aebd2 100644 --- a/gradio/static/css/gradio.css +++ b/gradio/static/css/gradio.css @@ -109,12 +109,12 @@ input.submit { input.submit:hover { background-color: #f39c12; } -.flagged { - background-color: pink !important; +.flag { + transition: background-color 100ms; +} +.flagged { + background-color: #e74c3c !important; } -/* label:hover { - background-color: lightgray; -} */ .overlay { position: absolute; height: 100vh; diff --git a/gradio/static/js/gradio.js b/gradio/static/js/gradio.js index 1a63283aef..3eccfeab34 100644 --- a/gradio/static/js/gradio.js +++ b/gradio/static/js/gradio.js @@ -191,8 +191,6 @@ function gradio(config, fn, target, example_file_path) { for (let output_interface of output_interfaces) { output_interface.clear(); } - target.find(".flag").removeClass("flagged"); - target.find(".flag").val("FLAG"); target.find(".flag_message").empty(); target.find(".loading").addClass("invisible"); target.find(".loading_time").text(""); @@ -498,8 +496,6 @@ function gradio(config, fn, target, example_file_path) { target.find(".submit").show(); target.find(".submit").click(function() { io_master.gather(); - target.find(".flag").removeClass("flagged"); - target.find(".flag").val("FLAG"); }) } if (!config.show_input) { @@ -509,7 +505,7 @@ function gradio(config, fn, target, example_file_path) { target.find(".flag").click(function() { if (io_master.last_output) { target.find(".flag").addClass("flagged"); - target.find(".flag").val("FLAGGED"); + window.setTimeout(() => {target.find(".flag").removeClass("flagged");}, 100); io_master.flag(); } }) From 2343512bb7bdcab4c6ed67e45d01af3ea150aa82 Mon Sep 17 00:00:00 2001 From: Ali Abid Date: Thu, 11 Feb 2021 09:50:38 -0800 Subject: [PATCH 3/3] add example hyperlinking --- gradio/static/js/gradio.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/gradio/static/js/gradio.js b/gradio/static/js/gradio.js index 3eccfeab34..4f179cb5e5 100644 --- a/gradio/static/js/gradio.js +++ b/gradio/static/js/gradio.js @@ -251,6 +251,17 @@ function gradio(config, fn, target, example_file_path) { $(".examples_body > tr").removeClass("current_example"); $(".examples_body > tr[row='" + example_id + "'").addClass("current_example"); io_master.current_example = example_id; + window.location.hash = example_id + 1; + } + function hash_handler() { + let hash = window.location.hash; + if (hash == "") { + return; + } + hash = hash.substring(1) + if (!isNaN(parseInt(hash))) { + load_example(parseInt(hash) - 1); + } } function next_example() { current_example = io_master.current_example; @@ -324,6 +335,8 @@ function gradio(config, fn, target, example_file_path) { target.find(".pages").append(html); } load_page(); + window.onhashchange = hash_handler; + hash_handler(); target.on("click", ".examples_body > tr", function() { let example_id = parseInt($(this).attr("row")); load_example(example_id);