updated PyPi version

This commit is contained in:
root 2021-08-18 22:44:56 +00:00
parent fc3e151fdd
commit 9bef448c9f
8 changed files with 64 additions and 65 deletions

View File

@ -1,9 +1,6 @@
import gradio as gr
import random
import time
def calculator(num1, operation, num2):
print(num1, operation, num2)
if operation == "add":
return num1 + num2
elif operation == "subtract":

Binary file not shown.

View File

@ -60,8 +60,8 @@ export class GradioInterface extends React.Component {
process.env.REACT_APP_BACKEND_URL +
(this.props.examples_dir === null
? "file" +
this.props.examples_dir +
(this.props.examples_dir.endswith("/") ? "" : "/")
this.props.examples_dir +
(this.props.examples_dir.endswith("/") ? "" : "/")
: "file");
}
get_default_state = () => {
@ -184,8 +184,8 @@ export class GradioInterface extends React.Component {
this.setState({ interpretation: null });
};
queueCallback = (queue_index) => {
this.setState({"queue_index": queue_index});
}
this.setState({ queue_index: queue_index });
};
takeScreenshot = () => {
html2canvas(ReactDOM.findDOMNode(this).parentNode).then((canvas) => {
saveAs(canvas.toDataURL(), "screenshot.png");
@ -207,10 +207,10 @@ export class GradioInterface extends React.Component {
i < this.props.input_components.length
? input_component_map[this.props.input_components[i].name][1]
: output_component_map[
this.props.output_components[
i - this.props.input_components.length
].name
][1];
this.props.output_components[
i - this.props.input_components.length
].name
][1];
state_change[i] = ExampleComponent.preprocess(
item,
this.examples_dir
@ -224,7 +224,9 @@ export class GradioInterface extends React.Component {
if (this.state.submitting) {
status = (
<div className="loading">
{this.state.queue_index !== null ? "queued @ " + this.state.queue_index : false}
{this.state.queue_index !== null
? "queued @ " + this.state.queue_index
: false}
<img alt="loading" src={logo_loading} />
</div>
);
@ -425,14 +427,14 @@ class GradioInterfaceExamples extends React.Component {
return <th key={i}>{component.label}</th>;
})}
{this.props.examples[0].length >
this.props.input_components.length
this.props.input_components.length
? this.props.output_components.map((component, i) => {
return (
<th key={i + this.props.input_components.length}>
{component.label}
</th>
);
})
return (
<th key={i + this.props.input_components.length}>
{component.label}
</th>
);
})
: false}
</tr>
</thead>
@ -449,7 +451,7 @@ class GradioInterfaceExamples extends React.Component {
{example_row.map((example_data, j) => {
let ExampleComponent =
input_component_map[
this.props.input_components[j].name
this.props.input_components[j].name
][1];
return (
<td>

View File

@ -4,37 +4,35 @@ import { GradioPage } from "./gradio";
import Login from "./login";
function delay(n) {
return new Promise(function(resolve){
setTimeout(resolve,n*1000);
return new Promise(function (resolve) {
setTimeout(resolve, n * 1000);
});
}
let postData = async (url, body) => {
const output = await fetch(
process.env.REACT_APP_BACKEND_URL + url,
{
method: "POST",
body: JSON.stringify(body),
headers: {"Content-Type": "application/json"}
}
);
const output = await fetch(process.env.REACT_APP_BACKEND_URL + url, {
method: "POST",
body: JSON.stringify(body),
headers: { "Content-Type": "application/json" }
});
return output;
}
};
let fn = async (queue, data, action, queue_callback) => {
if (queue && ["predict", "interpret"].includes(action)) {
const output = await postData(
"api/queue/push/", { data: data, action:action },
);
const output = await postData("api/queue/push/", {
data: data,
action: action
});
let hash = await output.text();
let status = "UNKNOWN";
while (status != "COMPLETE" && status != "FAILED") {
if (status != "UNKNOWN") {
await delay(1);
}
const status_response = await postData(
"api/queue/status/", { hash: hash },
);
const status_response = await postData("api/queue/status/", {
hash: hash
});
var status_obj = await status_response.json();
status = status_obj["status"];
if (status === "QUEUED") {
@ -49,10 +47,8 @@ let fn = async (queue, data, action, queue_callback) => {
return status_obj["data"];
}
} else {
const output = await postData(
"api/" + action + "/", { data: data },
);
return await output.json();
const output = await postData("api/" + action + "/", { data: data });
return await output.json();
}
};

View File

@ -1,25 +1,29 @@
import("./themes/defaults.scss");
export default function Login(props) {
return (
<div class="login">
<form
id="login"
method="POST"
action={process.env.REACT_APP_BACKEND_URL + "login"}
>
<h2>login</h2>
{props.auth_message ? (
<div dangerouslySetInnerHTML={{ __html: props.auth_message }}></div>
) : (
false
)}
<label for="username">username</label>
<input type="text" name="username"></input>
<label for="password">password</label>
<input type="password" name="password"></input>
<input class="link" type="submit" className="submit"></input>
</form>
</div>
);
if (props.auth_message && props.auth_message.trim().startsWith("<main")) {
return <div dangerouslySetInnerHTML={{ __html: props.auth_message }}></div>;
} else {
return (
<div class="login">
<form
id="login"
method="POST"
action={process.env.REACT_APP_BACKEND_URL + "login"}
>
<h2>login</h2>
{props.auth_message ? (
<div dangerouslySetInnerHTML={{ __html: props.auth_message }}></div>
) : (
false
)}
<label for="username">username</label>
<input type="text" name="username"></input>
<label for="password">password</label>
<input type="password" name="password"></input>
<input class="link" type="submit" className="submit"></input>
</form>
</div>
);
}
}

View File

@ -1,6 +1,6 @@
Metadata-Version: 1.0
Name: gradio
Version: 2.2.12
Version: 2.2.13
Summary: Python library for easily interacting with trained machine learning models
Home-page: https://github.com/gradio-app/gradio-UI
Author: Abubakar Abid

View File

@ -1 +1 @@
2.2.12
2.2.13

View File

@ -5,7 +5,7 @@ except ImportError:
setup(
name='gradio',
version='2.2.12',
version='2.2.13',
include_package_data=True,
description='Python library for easily interacting with trained machine learning models',
author='Abubakar Abid',