Collaborative training possible in ml5.js or Tensorflow.js? - javascript

I would like to build an image classifier with ml5.js or Tensorflow.js. I want the user to be able to add their own labels, ie. train the model. Daniel Shiffman's tutorial in transfer learning is excellent for this: https://www.youtube.com/watch?v=kRpZ5OqUY6Y
However, I would want several users to be able to train the same model. People would contribute to the same model with their own classifications.
Ideally one participant could contribute from their own browser in country X and other in country Y. Or, at least, two users in the same space doing the labeling from their own browsers. Displayed images would probably come from a JSON file.
I have tested Socket.io for collaborative mouse drawing using p5.js, but that's basically all my relevant experience in this kind of collaborative apps. So: is it possible for multiple users to train the same ml5.js/Tensorflow.js model using Socket.io or something similar?
Warm thanks for any advice!

I once used TogetherJS from Mozilla in a simple way to collaboratively add to the training dataset across any number of browsers. But each instance needed to run tf.fit on the extended dataset. Federated Learning would be the next step to avoid all this redundant computation.

Perhaps you don't need real time collaboration for this? The users can supply images and labels from their browsers and press an upload button.
There can be a train button in the client that tells the server to start training again. The model is only on the server so everyone can contribute to it.
While the server is training and it receives a new train command, it will just send back a message already in training process.
This way you won't need socket.io...

Related

web page with multiple users or sessions

I'm working on a project where I want 1-to-n number of people to be able to access the same instance of a web page simultaneously.
An example of this would be something like iscribble.net where a person can create a drawing board, and other users can enter this board and draw simultaneously on the same board and chat etc...
what is this called? I can't find the right search term to look up a tutorial or something
You might try "real-time collaboration," which is often achieved through WebSockets or similar technology.
Socket.IO is a popular JavaScript implementation of WebSockets.
What you're looking for is indeed websockets. However, push notifications, depending on complexity and interaction of your idea may be what you really need. There are different services that offer these things, as well as many open source solutions that come packaged with such capability.
Parse.com is great for a beginner for a small push enabled app with a limited number of requests. (I do not work for Parse).
A websocket app in my opinion is for an advanced developer even when the websockets are handled by a server side game solution with functionality ready to go. I'd check out push on parse.com first in a prototype to get your feet wet and see if it works.

Web App Creation Toolchain with CSS/HTML/Javascript

I want to create a score keeping app that allows me to enter scores into the app, save score history by user, and have a webpage that can display the score in real-time as well as pump out some stats on previous games.
I've been doing some front-end development the past few years and I would say that my CSS/HTML/Javascript skills are intermediate. I have a rough game plan on how it would work, but having very little backend experience there are some gaps in my knowledge that I need help with.
The app: I would build it with what I know: CSS/HTML/Javascript. I would it to be assessable via a webpage or native app. The plan for the latter was putting it through PhoneGap.
Database: SQL? This is were I would save the scores.
The webpage: This is where things get tricky. I need live reporting for the current game status. Web sockets?
I would use a Javascript graphing library to create charts of stats based on current and previous game history. I need that data to be automatically refreshed (AJAX) but how would I do that with a SQL/JS interaction?
Also, ideally the graphs on the webpage would allow visitors to copy and paste iframe code so they can paste the stuff into their own website. I don't even know where to get started with that.
I'm not sure if I'm even asking the right questions so any help would be greatly appreciated!
Since you're a front-end developer I think you'll really like http://nobackend.org/
There are a number of Back-end as a Service solutions which handle both data persistence and data synchronising across multiple devices.
These solutions answer your SQL and WebSockets questions. You could implement these yourself using either open source solutions or by combining a number of services. But I'd give the BaaS options a go.

Turn based multiplayer for iOS using CouchDB and IrisCouch

Me and my startup app company is working on a turn based multiplayer iPhone application. Let it be said that neither one of us have any database, or server, knowledge whatsoever. Though, we are willing to learn.
The flow of the game will be similar to such games as: WordFeud, WordsWithFriends, Rumble etc.
Let me start of by where a lot of searching on the web has gotten us:
We have decided to use CouchDB as a tool for storing information about users, game sessions and other stuff. CouchDB is an open source noSQL database system. The reason is that we have been taught, that it should support a lot off concurring users. Besides, that it scales - we are hoping to go big, of course.
Our CouchDB, is hosted on IrisCouch. IrisCouch is an "in cloud" hosting service designed for running CouchDb.
So, we've got a CouchDB server up and running, and we know the basics on how to query data from the server.
Our biggest confusion right now, is how we should set up the system to work according to best practices. Right now we are at the point where we are able to receive and submit data to the server.
Our game is supposed to have Facebook integration, so that the users can register via our app or through Facebook. After that they can play with random matched opponents, or play with friends. After a match is started, one player will get a set of question to be asked, after he has answered, the other player should be notified, through push notification, that it's their turn. After a few rounds the game is finished.
At this point, we think this might be the best solution for the flow of the application:
A user connects to another user -> a game session is opened as a
document in a database called "games".
The newly created document contains both player names, question,
answers etc
A field named "whos_turn" decides which of the two players turn it is.
After the game has ended, the session is erased.
Again, and as you may see, we are in the dark as of how to really do it, but this is the general idea.
So, my questions goes as following:
Is it best to query the data directly from the iPhone application, or through a web service?
What is the best way to set up the database, to best manage the flow of the application?
Any information, that could lead us closer will be gladly appreciated :)
In advance, thank you!
Olav Gundersen
EDIT#1 : Our Objective-C programmer managed to connect two iPhone devices using CouchDb. The iPhone application consists of a table view, that has a concurrent connection with the database, so that when someone POST to the database, it shows up on the tableview of all the other connected phones. Behold: a severely ineffective chat system.
If is a multiplayer you would need to have the app to communicate to the remote iriscouch.db but I am concerned by the point where you state that neither you or your friends have any database experience. You are willing to learn so I think the best place to start is:
http://guide.couchdb.org/editions/1/en/index.html
There are several issue you might find with scalability if you plan to erase documents continuously. DB Size can be considerable on couchdb and you will need to compact &cleanup the db regularly. But I don't think is a major issue for now as this is at a start up level.
The question "best way to setup the database and best manage the flow of the application" should be addressed by your team. If you do not have someone with any database experience you should try to find someone willing to help you. It should be someone with extensive experience in databases. You might find some fairly reasonable professionals at http://www.odesk.com
In total honestly I don't think you will be successful if you don't have such a figure - either as a freelancer or contributor - to help you having a solid database logic in the game that will ensure a great user experience.
For example: have you considered the latency-delay issue by using a db based in the USA (Iriscouch) vs. where your users are located?
For this reason you might want to do as much as possible client side (embedded database like sqlite or touchDB that is essentially couchDB for iPhone)
For an iPhone application you might want to try TouchDB that is made exactly for that
https://github.com/couchbaselabs/TouchDB-iOS (caveat: being that you need connectivity to check turns etc this might not be the ideal solution but it could work to store some information locally).
To lay this out you would need someone with experience with couchdb to set up a proper, usable application. There is nothing wrong in being enthusiast about your idea but to make it a success you need a technical mind in the database side. Of course you might be well capable to learn this yourself. After reading the CouchDB book you should be in position to create a basic flow to fit your needs.
Of course other more experienced users might come with a more comprehensive answer or a sample layout but I don't think would be the best approach. Even if someone posts a full layout of the doc structure and how to query it how are you going to service the app if something goes awry e.g. sessions don't get deleted, conflicts etc. ? hence my sincere advice to get some ad-hoc expertise for your case.
This might also result in analyzing suitable alternatives. I don't think you should buy into the idea that CouchDB can scale and hence is the best/only option for you (of course this might well be the case and if you feel that is a good option..go for it). For example twitter, google adwords and many other online apps are using mysql to store their data so for sure CouchDB is not the only database that can scale!
I think this demo app could be a good example to follow: iOS Couchbase Demo

Building an interactive website for multiple clients

I am a programming novice, so please forgive the technical ambiguity here. I will try to be as specific as possible about what I am trying to accomplish.
I am trying to build an interactive website where multiple clients can log on and view a board game. The board game consists of regions on a map with color (player who controls it) and number (armies) variables, as well as draggable tokens.
I have built a client-end version in JavaScript using the Raphael interface for SVG graphics, and would like to build a server that can process any changes one client makes to the board and update the boards of the other clients. In my mind, the sequence would be something like:
Action performed by the user
Action listener updates client view
Update sent to server
Server changes database to reflect change
Server notifies all clients
Clients update view
I've read up on Ajax/XML a bit, but the tutorials I have found have mostly been about getting static data, and I haven't seen an example of actually CHANGING dynamic data on a server, nor have I been able to find any examples of what the server functions should look like.
So basically my question is, can anyone point me in the right direction here? I would very much appreciate a general outline about how I could go about accomplishing this, as well as direction to a tutorial or two that relates to the task. Thank you!
You may look at nodeJS and socket.io.
With this technology it is possibile to create real time web applications.
Its a bit older, but here is a game we did some time ago:
https://github.com/stravid/unitacs
It also uses raphaelJS.

Real-time collaborative drawing whiteboard in HTML5/JS and websockets?

I'm trying to put together a small(ish) summer school project for some of my advanced students and am researching how to do it best and what to use - hopefully somebody here could point me in the right direction.
What we are interested in is researching if HTML5 came far enough to create a real-time collaborative drawing whiteboard in it - purely by using web technologies without plugins (so CSS, HTML5/DOM and Javascript). What we'd ultimatelly strive for is this - for example have an online canvas/page on a central server displayed on a big screen in the classroom. Then our students/users would take out their smartphones, load the page in their mobile browsers (I'm perfectly ok with limiting this to webkit mobile browsers for now) and draw on their screens with touch/fingers (or on PCs with the mouse - guessing this doesn't make a lot of difference) and it would get updated in real time for everybody - both on their screens and on the central big screen in the classroom.
I'm guessing push/get requests would be too slow for this - could it be solved by websockets? Does anybody have any good JS libraries to recommend for this?
Also what would the ideal (but easier for students to understand) architecture look like. Lets say you have 30 simultaneous users in a clasroom - each of them would connect with websockets to the server and the server would pool/combine all of their requests into one and then return the combined file (some sort of minimal JSON or even just coordinates) for every connected user?
Would websockets and (I'm guessing) canvas be able to take this? So that everything still looks snappy? Are there (jQuery-like) JS libraries available to make our lives easier - or do you think its something thats too complex for a 2-week summer school project?
here's a tutorial describing how to create a multiuser whiteboard with javascript/html5/canvas:
http://www.unionplatform.com/?page_id=2762
the example uses a collaboration framework and server named "union platform". even if you decide to roll your own server and client framework, the messaging in the example should give you an idea of how to structure the code.
for an apples-to-apples speed comparison of websocket vs comet, see:
http://www.unionplatform.com/?page_id=2954
in my tests, a basic ping over WebSocket is normally about twice as fast as the ping over http. both websocket and coment are more than fast enough to create a collaborative whiteboard.
Definitely check this out:
http://wesbos.com/html5-canvas-websockets-nodejs/
For the networking side of things, try looking at node.js for the server, along with socket.io for the client.
As for the drawing itself, a few popular choices are processing, raphael and cakejs.
When it comes to the implementation, you may want to look at how networked games deal with similar issues (gamedev.stackexchange.com could be useful).
What you are going to be doing is essentialy the same as a simple top down multiplayer game, with each 'player' in this case being a students fingertip, and the 'level' being the canvas. You need to update the server as to their position and whether or not they are 'shooting' (drawing).
I'm guessing push/get requests would be too slow for this - could it be solved by websockets? Does anybody have any good JS libraries to recommend for this?
If you need real-time infrastructure I've created a list of real-time technologies which might be of use to you. These include hosted service, such as Pusher who I work for, and self-install technologies such as WebSocket and Comet solutions.
WebSocket sounds like the idea choice of technology for you since they have become part of HTML5 and offer the most efficient for of realtime bi-directional communication between a web server and a browser (or other clients).
Also what would the ideal (but easier for students to understand) architecture look like. Lets say you have 30 simultaneous users in a clasroom - each of them would connect with websockets to the server and the server would pool/combine all of their requests into one and then return the combined file (some sort of minimal JSON or even just coordinates) for every connected user?
It sounds like you should probably store the current state somewhere and on the initial load of the application display that state. Then use your real-time infrastructure to send deltas on that state, or if it's a drawing on canvas, just information on the line etc. that has been drawn and information about who drew it.
Would websockets and (I'm guessing) canvas be able to take this? So that everything still looks snappy? Are there (jQuery-like) JS libraries available to make our lives easier - or do you think its something thats too complex for a 2-week summer school project?
Real-time collaborative drawing is most definitely achievable and there have been a number of examples created of this. A google bring up a number of possibilities.
If this technology is completely new to you and you would prefer to concentrate on building the collaborative application then I would consider using a service for your app rather than going through the hassle of learning how to install and configure, or even code, your own infrastructure (I'm not just saying this because I work for such a service. I honestly think it makes the most sense).

Categories

Resources