mirror of
https://github.com/gradio-app/gradio.git
synced 2025-01-06 10:25:17 +08:00
restore
This commit is contained in:
parent
8cecfc29e4
commit
9c017bf6aa
@ -180,7 +180,11 @@ class Interface:
|
||||
return
|
||||
raise RuntimeError("Validation did not pass")
|
||||
|
||||
<<<<<<< HEAD
|
||||
def launch(self, inline=None, inbrowser=None, share=False, validate=True, title=None, description=None):
|
||||
=======
|
||||
def launch(self, inline=None, inbrowser=None, share=False, validate=True):
|
||||
>>>>>>> 2bd16c2f9c360c98583b94e2f6a6ea7259a98217
|
||||
"""
|
||||
Standard method shared by interfaces that creates the interface and sets up a websocket to communicate with it.
|
||||
:param inline: boolean. If True, then a gradio interface is created inline (e.g. in jupyter or colab notebook)
|
||||
@ -290,6 +294,11 @@ class Interface:
|
||||
|
||||
config = self.get_config_file()
|
||||
config["share_url"] = share_url
|
||||
<<<<<<< HEAD
|
||||
config["title"] = title
|
||||
config["description"] = description
|
||||
=======
|
||||
>>>>>>> 2bd16c2f9c360c98583b94e2f6a6ea7259a98217
|
||||
networking.set_config(config, output_directory)
|
||||
|
||||
return httpd, path_to_local_server, share_url
|
||||
|
@ -31,14 +31,28 @@ nav img {
|
||||
padding: 4px;
|
||||
border-radius: 2px;
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
#title {
|
||||
text-align: center;
|
||||
}
|
||||
.container {
|
||||
max-width: 1028px;
|
||||
width: 100%;
|
||||
margin: 0 auto;
|
||||
}
|
||||
=======
|
||||
>>>>>>> 2bd16c2f9c360c98583b94e2f6a6ea7259a98217
|
||||
.panels {
|
||||
display: flex;
|
||||
flex-flow: row;
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
max-width: 1028px;
|
||||
width: 100%;
|
||||
margin: 0 auto;
|
||||
>>>>>>> 2bd16c2f9c360c98583b94e2f6a6ea7259a98217
|
||||
}
|
||||
button.primary {
|
||||
color: white;
|
||||
|
@ -1,7 +1,11 @@
|
||||
function gradio(config, fn, target) {
|
||||
target = $(target);
|
||||
target.html(`
|
||||
<<<<<<< HEAD
|
||||
<div class="panels container">
|
||||
=======
|
||||
<div class="panels">
|
||||
>>>>>>> 2bd16c2f9c360c98583b94e2f6a6ea7259a98217
|
||||
<div class="panel input_panel">
|
||||
<div class="input_interfaces">
|
||||
</div>
|
||||
|
@ -20,16 +20,27 @@ const webcam = {
|
||||
},
|
||||
submit: function() {
|
||||
var io = this;
|
||||
<<<<<<< HEAD
|
||||
Webcam.snap(function(image_data) {
|
||||
io.io_master.input(io.id, image_data);
|
||||
});
|
||||
// Webcam.freeze();
|
||||
=======
|
||||
Webcam.freeze();
|
||||
Webcam.snap(function(image_data) {
|
||||
io.io_master.input(io.id, image_data);
|
||||
});
|
||||
>>>>>>> 2bd16c2f9c360c98583b94e2f6a6ea7259a98217
|
||||
this.state = "SNAPPED";
|
||||
},
|
||||
clear: function() {
|
||||
if (this.state == "SNAPPED") {
|
||||
this.state = "CAMERA_ON";
|
||||
<<<<<<< HEAD
|
||||
// Webcam.unfreeze();
|
||||
=======
|
||||
Webcam.unfreeze();
|
||||
>>>>>>> 2bd16c2f9c360c98583b94e2f6a6ea7259a98217
|
||||
}
|
||||
},
|
||||
state: "NOT_STARTED",
|
||||
|
@ -34,6 +34,13 @@
|
||||
Live at <a id="share-link"></a>.
|
||||
<button id="share-copy">Copy Link</button>
|
||||
</div>
|
||||
<<<<<<< HEAD
|
||||
<div class="container">
|
||||
<h1 id="title"></h1>
|
||||
<p id="description"></p>
|
||||
</div>
|
||||
=======
|
||||
>>>>>>> 2bd16c2f9c360c98583b94e2f6a6ea7259a98217
|
||||
<div id="interface_target"></div>
|
||||
<script src="../static/js/vendor/jquery.min.js"></script>
|
||||
<!-- TUI EDITOR -->
|
||||
@ -82,12 +89,25 @@
|
||||
});
|
||||
});
|
||||
}, "#interface_target");
|
||||
<<<<<<< HEAD
|
||||
if (config["title"]) {
|
||||
$("#title").text(config["title"]);
|
||||
}
|
||||
if (config["description"]) {
|
||||
$("#description").text(config["description"]);
|
||||
}
|
||||
=======
|
||||
>>>>>>> 2bd16c2f9c360c98583b94e2f6a6ea7259a98217
|
||||
if (config["share_url"]) {
|
||||
let share_url = config["share_url"];
|
||||
$("#share").removeClass("invisible");
|
||||
$("#share-link").text(share_url).attr("href", share_url);
|
||||
$("#share-copy").click(function() {
|
||||
copyToClipboard(share_url);
|
||||
<<<<<<< HEAD
|
||||
$("#share-copy").text("Copied!");
|
||||
=======
|
||||
>>>>>>> 2bd16c2f9c360c98583b94e2f6a6ea7259a98217
|
||||
})
|
||||
}
|
||||
});
|
||||
|
@ -18,4 +18,8 @@ gr.Interface(answer_question,
|
||||
gr.outputs.Textbox(label="out", lines=8),
|
||||
"key_values"
|
||||
]
|
||||
<<<<<<< HEAD
|
||||
).launch(title="Demo", description="Trying out a funky model!")
|
||||
=======
|
||||
).launch(share=True)
|
||||
>>>>>>> 2bd16c2f9c360c98583b94e2f6a6ea7259a98217
|
||||
|
@ -7,7 +7,7 @@ automatically added to a registry, which allows them to be easily referenced in
|
||||
from abc import ABC, abstractmethod
|
||||
from gradio import preprocessing_utils, validation_data
|
||||
import numpy as np
|
||||
from PIL import Image, ImageOps
|
||||
import PIL.Image, PIL.ImageOps
|
||||
import time
|
||||
import warnings
|
||||
import json
|
||||
@ -84,11 +84,11 @@ class Sketchpad(AbstractInput):
|
||||
Default preprocessing method for the SketchPad is to convert the sketch to black and white and resize 28x28
|
||||
"""
|
||||
im_transparent = preprocessing_utils.decode_base64_to_image(inp)
|
||||
im = Image.new("RGBA", im_transparent.size, "WHITE") # Create a white background for the alpha channel
|
||||
im = PIL.Image.new("RGBA", im_transparent.size, "WHITE") # Create a white background for the alpha channel
|
||||
im.paste(im_transparent, (0, 0), im_transparent)
|
||||
im = im.convert('L')
|
||||
if self.invert_colors:
|
||||
im = ImageOps.invert(im)
|
||||
im = PIL.ImageOps.invert(im)
|
||||
im = im.resize((self.image_width, self.image_height))
|
||||
if self.flatten:
|
||||
array = np.array(im).flatten().reshape(1, self.image_width * self.image_height)
|
||||
@ -261,6 +261,7 @@ class Slider(AbstractInput):
|
||||
"checkbox": {},
|
||||
}
|
||||
|
||||
|
||||
class Checkbox(AbstractInput):
|
||||
def __init__(self, label=None):
|
||||
super().__init__(label)
|
||||
@ -272,7 +273,7 @@ class Checkbox(AbstractInput):
|
||||
}
|
||||
|
||||
|
||||
class ImageIn(AbstractInput):
|
||||
class Image(AbstractInput):
|
||||
def __init__(self, cast_to=None, shape=(224, 224, 3), image_mode='RGB',
|
||||
scale=1/127.5, shift=-1, cropper_aspect_ratio=None, label=None):
|
||||
self.cast_to = cast_to
|
||||
|
@ -195,7 +195,7 @@ class Interface:
|
||||
return
|
||||
raise RuntimeError("Validation did not pass")
|
||||
|
||||
def launch(self, inline=None, inbrowser=None, share=False, validate=True):
|
||||
def launch(self, inline=None, inbrowser=None, share=False, validate=True, title=None, description=None):
|
||||
"""
|
||||
Standard method shared by interfaces that creates the interface and sets up a websocket to communicate with it.
|
||||
:param inline: boolean. If True, then a gradio interface is created inline (e.g. in jupyter or colab notebook)
|
||||
@ -306,6 +306,8 @@ class Interface:
|
||||
|
||||
config = self.get_config_file()
|
||||
config["share_url"] = share_url
|
||||
config["title"] = title
|
||||
config["description"] = description
|
||||
networking.set_config(config, output_directory)
|
||||
|
||||
return httpd, path_to_local_server, share_url
|
||||
|
@ -31,14 +31,19 @@ nav img {
|
||||
padding: 4px;
|
||||
border-radius: 2px;
|
||||
}
|
||||
#title {
|
||||
text-align: center;
|
||||
}
|
||||
.container {
|
||||
max-width: 1028px;
|
||||
width: 100%;
|
||||
margin: 0 auto;
|
||||
}
|
||||
.panels {
|
||||
display: flex;
|
||||
flex-flow: row;
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
max-width: 1028px;
|
||||
width: 100%;
|
||||
margin: 0 auto;
|
||||
}
|
||||
button.primary {
|
||||
color: white;
|
||||
|
@ -1,7 +1,7 @@
|
||||
function gradio(config, fn, target) {
|
||||
target = $(target);
|
||||
target.html(`
|
||||
<div class="panels">
|
||||
<div class="panels container">
|
||||
<div class="panel input_panel">
|
||||
<div class="input_interfaces">
|
||||
</div>
|
||||
|
@ -34,6 +34,10 @@
|
||||
Live at <a id="share-link"></a>.
|
||||
<button id="share-copy">Copy Link</button>
|
||||
</div>
|
||||
<div class="container">
|
||||
<h1 id="title"></h1>
|
||||
<p id="description"></p>
|
||||
</div>
|
||||
<div id="interface_target"></div>
|
||||
<script src="../static/js/vendor/jquery.min.js"></script>
|
||||
<!-- TUI EDITOR -->
|
||||
@ -82,12 +86,19 @@
|
||||
});
|
||||
});
|
||||
}, "#interface_target");
|
||||
if (config["title"]) {
|
||||
$("#title").text(config["title"]);
|
||||
}
|
||||
if (config["description"]) {
|
||||
$("#description").text(config["description"]);
|
||||
}
|
||||
if (config["share_url"]) {
|
||||
let share_url = config["share_url"];
|
||||
$("#share").removeClass("invisible");
|
||||
$("#share-link").text(share_url).attr("href", share_url);
|
||||
$("#share-copy").click(function() {
|
||||
copyToClipboard(share_url);
|
||||
$("#share-copy").text("Copied!");
|
||||
})
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user