mirror of
https://github.com/gradio-app/gradio.git
synced 2024-12-21 02:19:59 +08:00
changes
This commit is contained in:
parent
abda96bf30
commit
9e20377204
21
build/lib/gradio/embeddings.py
Normal file
21
build/lib/gradio/embeddings.py
Normal file
File diff suppressed because one or more lines are too long
@ -3,6 +3,7 @@ README.md
|
||||
setup.py
|
||||
gradio/__init__.py
|
||||
gradio/component.py
|
||||
gradio/embeddings.py
|
||||
gradio/inputs.py
|
||||
gradio/interface.py
|
||||
gradio/interpretation.py
|
||||
|
@ -38,35 +38,18 @@ var io_master_template = {
|
||||
this.target.find(".loading_failed").show();
|
||||
});
|
||||
},
|
||||
score_similarity: function() {
|
||||
score_similarity: function(callback) {
|
||||
this.target.find(".loading").removeClass("invisible");
|
||||
this.target.find(".loading_in_progress").show();
|
||||
this.target.find(".loading_failed").hide();
|
||||
this.target.find(".output_interfaces").css("opacity", 0.5);
|
||||
|
||||
this.fn(this.last_input, "score_similarity").then((output) => {
|
||||
output = output["data"];
|
||||
this.target.find(".loading").addClass("invisible");
|
||||
this.target.find(".output_interfaces").css("opacity", 1);
|
||||
let html = "<th>SIMILARITY</th>"
|
||||
this.target.find(".examples > table > thead > tr").append(html);
|
||||
for (let i = 0; i < output["data"].length; i++) {
|
||||
let html = "<td>" + output["data"][i] + "</td>"
|
||||
this.target.find(".examples_body tr[row='" + i + "']").append(html);
|
||||
}
|
||||
|
||||
function getCellValue(row, index){ return $(row).children('td').eq(index).text() }
|
||||
|
||||
function comparer(index) {
|
||||
return function(a, b) {
|
||||
var valA = getCellValue(a, index), valB = getCellValue(b, index)
|
||||
return $.isNumeric(valA) && $.isNumeric(valB) ? valA - valB : valA.toString().localeCompare(valB)
|
||||
}
|
||||
}
|
||||
|
||||
var table = $(".examples > table").eq(0)
|
||||
var rows = table.find('tr:gt(0)').toArray().sort(comparer(-1)).reverse() // sort by last column
|
||||
table.find("tr:gt(0)").remove()
|
||||
for (var i = 0; i < rows.length; i++){table.append(rows[i]); console.log(i)}
|
||||
this.order_mapping = sortWithIndices(output);
|
||||
callback();
|
||||
})
|
||||
},
|
||||
submit_examples: function() {
|
||||
|
@ -6,6 +6,21 @@ String.prototype.format = function() {
|
||||
return a
|
||||
}
|
||||
|
||||
function sortWithIndices(toSort) {
|
||||
for (var i = 0; i < toSort.length; i++) {
|
||||
toSort[i] = [toSort[i], i];
|
||||
}
|
||||
toSort.sort(function(left, right) {
|
||||
return left[0] < right[0] ? -1 : 1;
|
||||
});
|
||||
toSort.sortIndices = [];
|
||||
for (var j = 0; j < toSort.length; j++) {
|
||||
toSort.sortIndices.push(toSort[j][1]);
|
||||
toSort[j] = toSort[j][0];
|
||||
}
|
||||
return toSort.sortIndices;
|
||||
}
|
||||
|
||||
function toDataURL(url, callback) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.onload = function() {
|
||||
|
Loading…
Reference in New Issue
Block a user