upgraded to 0.1.3

This commit is contained in:
Abubakar Abid 2019-02-19 02:10:46 -08:00
parent f4acd3b1fc
commit a553ed60cd
11 changed files with 67 additions and 73 deletions

34
.idea/workspace.xml generated
View File

@ -2,9 +2,7 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="fd73cd66-e80f-470e-a2ec-e220d3b6b864" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/Test Notebook.ipynb" beforeDir="false" afterPath="$PROJECT_DIR$/Test Notebook.ipynb" afterDir="false" />
<change beforePath="$PROJECT_DIR$/gradio/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/gradio/__init__.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/gradio/js/all-io.js" beforeDir="false" afterPath="$PROJECT_DIR$/gradio/js/all-io.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/setup.py" beforeDir="false" afterPath="$PROJECT_DIR$/setup.py" afterDir="false" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
@ -97,7 +95,7 @@
<entry key="gitignore" value="2" />
<entry key="html" value="112" />
<entry key="js" value="272" />
<entry key="py" value="4442" />
<entry key="py" value="4443" />
</counts>
</usages-collector>
<usages-collector id="statistics.file.types.edit">
@ -106,26 +104,26 @@
<entry key="HTML" value="112" />
<entry key="JavaScript" value="272" />
<entry key="PLAIN_TEXT" value="21" />
<entry key="Python" value="4442" />
<entry key="Python" value="4443" />
</counts>
</usages-collector>
</session>
</component>
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file pinned="false" current-in-tab="false">
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/setup.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="175">
<caret line="7" column="19" selection-start-line="7" selection-start-column="19" selection-end-line="7" selection-end-column="19" />
<caret line="7" column="18" selection-start-line="7" selection-start-column="18" selection-end-line="7" selection-end-column="18" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="true">
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/gradio/__init__.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="325">
<state relative-caret-position="1750">
<caret line="70" selection-start-line="70" selection-end-line="70" />
<folding>
<element signature="e#0#14#0" expanded="true" />
@ -257,8 +255,8 @@
<option value="$PROJECT_DIR$/js/all-io.js" />
<option value="$PROJECT_DIR$/gradio.py" />
<option value="$PROJECT_DIR$/gradio/inputs.py" />
<option value="$PROJECT_DIR$/setup.py" />
<option value="$PROJECT_DIR$/gradio/__init__.py" />
<option value="$PROJECT_DIR$/setup.py" />
</list>
</option>
</component>
@ -590,16 +588,9 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/setup.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="175">
<caret line="7" column="19" selection-start-line="7" selection-start-column="19" selection-end-line="7" selection-end-column="19" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/gradio/__init__.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="325">
<state relative-caret-position="1750">
<caret line="70" selection-start-line="70" selection-end-line="70" />
<folding>
<element signature="e#0#14#0" expanded="true" />
@ -608,5 +599,12 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/setup.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="175">
<caret line="7" column="18" selection-start-line="7" selection-start-column="18" selection-end-line="7" selection-end-column="18" />
</state>
</provider>
</entry>
</component>
</project>

View File

@ -7,6 +7,8 @@ from bs4 import BeautifulSoup
from gradio import inputs
from gradio import outputs
from gradio import networking
import os
import shutil
nest_asyncio.apply()
@ -15,6 +17,10 @@ INITIAL_WEBSOCKET_PORT = 9200
TRY_NUM_PORTS = 100
JS_FILE = pkg_resources.resource_filename('gradio', 'js/all-io.js')
JS_PATH_LIB = pkg_resources.resource_filename('gradio', 'js/')
JS_PATH_LOCAL = os.path.realpath('js/')
CSS_PATH_LIB = pkg_resources.resource_filename('gradio', 'css/')
CSS_PATH_LOCAL = os.path.realpath('css/')
class Interface():
@ -54,8 +60,20 @@ class Interface():
f = open(self.build_template_path, "w")
f.write(str(all_io_soup.prettify))
self._copy_files(JS_PATH_LIB, JS_PATH_LOCAL)
self._copy_files(CSS_PATH_LIB, CSS_PATH_LOCAL)
return self.build_template_path
def _copy_files(self, src_dir, dest_dir):
if not os.path.exists(dest_dir):
os.makedirs(dest_dir)
src_files = os.listdir(src_dir)
for file_name in src_files:
full_file_name = os.path.join(src_dir, file_name)
if os.path.isfile(full_file_name):
shutil.copy(full_file_name, dest_dir)
def _set_socket_url_in_js(self, socket_url):
with open(JS_FILE) as fin:

View File

@ -23,27 +23,40 @@ body {
}
.uploader {position:relative; overflow:hidden; width:300px; height:350px; background:#f3f3f3; border:2px dashed #e8e8e8;}
.uploader {position:relative; overflow:hidden; width:400px; height:400px; background:#f3f3f3; border:2px dashed #e8e8e8; font-family: "Arial"; font-size: 40px; color: darkolivegreen;}
#filePhoto{
position:absolute;
width:300px;
width:400px;
height:400px;
top:-50px;
left:0;
z-index:2;
opacity:0;
cursor:pointer;
}
.uploader img{
position:absolute;
width:302px;
height:352px;
width:400px;
height:400px;
top:-1px;
left:-1px;
z-index:1;
border:none;
object-fit: cover;
}
#predict_div {
text-align: center;
vertical-align: middle;
font-family: 'Arial';
color: white;
font-size: 60px;
word-wrap: break-word;
}
#textbox-input {
border-radius: 25px;

View File

@ -1,12 +1,12 @@
var NGROK_URL = "ws://b2208ab1.ngrok.io"
var SOCKET_PORT = 9201
var NGROK_URL = "ws://b09c2edb.ngrok.io"
var SOCKET_PORT = 9200
try {
var origin = window.location.origin;
if (origin.includes("ngrok")){
var ws = new WebSocket(NGROK_URL)
} else {
var ws = new WebSocket("ws://127.0.0.1:" + SOCKET_PORT + "/")
var ws = new WebSocket("ws://127.0.0.1:9200/")
}
ws.onerror = function(evt) {
console.log(evt)

View File

@ -28,15 +28,16 @@ try {
ws.onmessage = function (event) {
console.log(event.data);
sleep(300).then(() => {
if (event.data.length == 1) {
$("#predict_div").css({ 'font-size':'300px'});
} else {
$("#predict_div").css({ 'font-size':'60px'});
}
$("#predict_div").text(event.data);
$("#predict_div").css("font-family", "Arial");
$("#predict_div").css("color", "White");
$("#predict_div").css("font-size", "20vw");
$("#predict_div").css("text-align", "center");
$("#predict_div").css("vertical-align", "middle");
})
}
} catch (e) {
notifyError(e)
}

View File

@ -1,36 +1,3 @@
// function previewFile(){
// var preview = document.querySelector('img'); //selects the query named img
// var file = document.querySelector('input[type=file]').files[0]; //sames as here
// var reader = new FileReader();
// reader.onloadend = function () {
// preview.src = reader.result;
// }
// if (file) {
// reader.readAsDataURL(file); //reads the data as a URL
// console.log(file)
// } else {
// preview.src = "";
// }
// }
// previewFile(); //calls the function named previewFile()
// $('#submit-button').click(function(e){
// var file = document.querySelector('input[type=file]').files[0]; //sames as here
// var reader = new FileReader();
// var preview = document.querySelector('img'); //selects the query named img
// if (file) {
// reader.readAsDataURL(file); //reads the data as a URL
// console.log(preview.src)
// ws.send(preview.src, function(e){
// notifyError(e)
// });
// }
// })
var imageLoader = document.getElementById('filePhoto');
imageLoader.addEventListener('change', handleImage, false);
@ -45,9 +12,6 @@ function handleImage(e) {
}
$('#submit-button').click(function(e){
// var reader = new FileReader();
// reader.readAsDataURL(e.target.files[0]);
var src = $('.uploader img').attr('src');
ws.send(src, function(e){
notifyError(e)

View File

@ -1,5 +1,5 @@
<div class="col-6">
<h5>Class Output:</h5>
<h5></h5><br>
<div id="predict_div" style="background-color:grey">
</div>

View File

@ -14,11 +14,11 @@
-->
<div class="col-6">
<h5>Image Upload Input:</h5>
<h5 style="text-align: center">Image Upload Input:</h5>
<div class="uploader" onclick="$('#filePhoto').click()">
click here or drag your images for preview
<img src=""/>
<div class="uploader" style="text-align: center; vertical-align: middle" onclick="$('#filePhoto').click()">
<br>Click here <br> or <br> drag and drop <br>an image
<img/>
<input type="file" name="userprofile_picture" id="filePhoto" />
</div>
<div class="btn-group" role="group" aria-label="Basic example">

View File

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

View File

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