Using tensorflow models in web applications - php

So I've recently became very interested in machine learning, and have been using tensorflow (python) in some of my projects at work.
However, I've now found a use for digit classification in one of my web projects which is all written in PHP for server-side code. Ideally, I'd like to be able to upload a picture via a Javascript interface, and on the PHP receiving end process the picture, slide a window to find the set of digits I'm looking for, and then process this through my trained neural network. I guess I'll summarise in one question: is this possible? Thank you!

Tensorflow provides serving project for communication, so you need to implement gRPC client for PHP, then use it to talk to Tensorflow serving environment.
That's how I work with Ruby and Tensorflow, it should be working for you as well!

You can try one of these PHP extensions:
https://github.com/absalomedia/tensile
https://github.com/wan2land/php-tensorflow

Related

Is an iAMP setup possible?

I'd like to get apache, mysql, and php running in an iphone app. This is because I'm finding objective c to be quite difficult, and if I can get those three running and figure out how to set up a full-page browser or something, I can code my app like that.
The MySQL aspect isn't really a necessity since I can very easily code a flat file database in php for this.
Is this possible? Has it been done? If not, what frameworks should I use to make creating an app easier?
I am assuming what you are saying is that you are more familiar with HTML and JavaScript, and would like to code with those tools.
If so, take a look at PhoneGap and Titanium. They are frameworks to code iOS apps with web technologies. Basically, it is like running a local file in a web browser (with interfaces to access device functions such as the GPS). No need to have a PHP and Apache stack there.
There is also a quasi-standard to write web applications that can work offline once downloaded. Mobile Safari supports this, and it can almost look like a native app.
If you're looking for any other options, there's Mono Touch, which is C# for iPhone. It's garbage collected, managed, strongly typed, and has access to all the device functions just like PhoneGap.
There's not really any simple way to get PHP running on an iPhone. You could try to get it to compile yourself, but that sounds like you'd be spending more time trying to get the framework working rather than working on your actual project.

PHP part in Python based website

I need to write a small addition to a Python+Django based website, hosted on Google Apps. Trouble is that I don't have any experience with Python.
The addition is pretty straight forward, it requires little database access
So thought of 2 possible solution's:
Quickly dive into Python and get it done with Python.
Run PHP on Quercus and write this particular addition in PHP, then somehow combine it into the website as a dingle PHP page.
Edit: There is another option I thought of:
Writing it in PHP and hosting it on an external server, embedding it in an iframe. The addition I am writing has no need to be SEO friendly, so an iframe will have no negative effect on the website.
What do you suggest?
I am not sure about how you will run php on GAE since it only support Java and Python.
I'd go with solution 1. Python isn't hard to apprehend, you should find ready-to-go code snippets in GAE documentation, and its Datastore doesn't seem too hard to use :D
there's a nice tutorial in GAE documentation: here
Quercus on App Engine runs on the Java runtime, while Python runs on, er, the Python runtime. While you can run one app with multiple runtimes, they have to be different major versions, which means that communication between them will be awkward - you'd have to make URLFetches between them.
I think you'll find it's far simpler to learn enough Python to make the changes. And trust me, you won't regret learning Python. ;)

Python or PHP for small windows administration scripts?

I'm choosing between these two languages, in contrast to another question here. My program going to be set of scripts checking files, free space, checking that apps are running etc. and writing information to database. Then PHP web page will show results.
Python have more examples of winapi calls (at least at StackOverflow) and more attractive to learn and use in different areas of programming, but I didn't use it before. With PHP I have small experience and I will be using it for results web page anyway.
PHP seems to be easier to install on network (to use one network installation for many workstations). Both languages can work with COM objects (I will need ADO).
Scripts will be small, not complex, but their number will grow.
Can someone with experience in similar tasks advise on choice between these two?
Don't shrink from using a language just because you haven't used it before. Learning a new language is one of ways to expand your overall capabilities as a programmer. True, you won't be as productive with it at first but learning how the language tackles common problems (manipulation of data structures, creation and lifetime of objects, etc.) will teach you new ways to think about computing.
That said, I would suggest you use the ActiveState version of Python (http://www.activestate.com/). It has the Windows integration included. I'm not sure about network install with Python. I've installed it across a net by running a remote desktop of the target and running the installer. Windows wants things registered in the registry so running a language is not like running an .exe sitting on a remote file share.
I asked question first time as anonymous so have no other option to reply now except to write an answer.
Thank you verisimilidude for ActivePython advice!
Installed ActivePython at home, reading Dive into Python 3.
Installed RadPHP XE at work (company bought it).
So for work it will be PHP. For me, if have free time (and may be for kids, when grew and if interested) it will be Python.
As someone who uses both on a regular basis, I tend toward using python for windows scripting and php for web apps. It's mostly just my preference, but I think they're each ideally suited toward different things. I love using Python in windows, it is really versatile.
a ) python is a nice alternative because you can generate an executable, otherwise (running as script) php is more suitable because it does not required an installation.
b ) try to not to connect directly to the database. Instead, you can create a web page then the clients can connect to it instead to do a direct connection to the database.
for example in php (in the client)
$fp=fopen("http://192.168.0.200/update?id=mymachine&value=200","r");
fclose($fp);
ps: For api calls, both (php and python) can do the same. Thought, for php and Windows Vista (and higher) exist some restriction when you are running it as a apache-module and apache is running as a service but i don't think it is the case.

Old desktop programmer wants to create S+S project

I have an idea for a product that I want to be web-based. But because I live in a part of the world where the internet is not always available, there needs to be a client desktop component that is available for when the internet is down. Also, I have been a SQL programmer, a desktop application programmer using dBase, VB and Pascal, and I have created simple websites using HTML and website creation tools, such as Frontpage.
So from my research, I think I have the following options; PHP, Ruby on Rails, Python or .NET for the programming side. MySQL for the DB. And Apache, or possibly IIS, for the webserver.
I will probably start with a local ISP provider for the cloud servce. But then maybe move to something more "robust" and universal in the future, ie. Amazon, or Azure, or something along that line.
My question then is this. What would you recommend for something like this? I'm sure that I have not listed all of the possibilities, but the ones I have researched and thought of.
Thanks everyone,
Craig
If you want a 'desktop component' that is available for you to do development on whenever your internet is out, you could really choose any of those technologies. You can always have a local server (like apache) running on your machine, as well as a local sql database, though if your database contains a large amount of data you may need to scale it down.
Ruby on Rails may be the easiest for you to get started with, though, since it comes packaged with WEBrick (a ruby library that provides HTTP services), and SQLite, a lightweight SQL database management system. Ruby on Rails is configured by default to use these.
The languages you list are all serverside components. The big question is whether you can sensibly build a thick client - effectively you could develop a multi-tier application where the webserver sits on the client and uses a webservice as a datafeed if/when its available but the solution is not very portable.
You could build a purely ajax driven website in javascript then deploy it to the client as signed javascripts on the local filesystem (they need to be signed to get around the restriction that javscripts can only connect back to the server where they served from normally).
Another approach would be to use Google Gears - but that would be a single browser solution.
C.
If you wan't to run a version of the server on desktops, your best options would be Python, Rails, or Java servlets, all of which can be easily packaged into small self contained servers with no dependencies.
My recommendation for the desktop would be HTML 5 local storage. The standard hasn't been finalized, but there is experimental support in Google Chrome. If you can force your users to use a specific browser version, you should be OK, until it is finalized.
I would recommend looking at Django and Rails before any other framework. They have different design philosophies, so one of them might be better suited for your application. Another framework to consider is Grails, which is essentially a clone of Rails in the groovy language.

php library iPhone

I'm wondering if anyone knows of a PHP library that I could compile into my app for the iPhone? Basically I'm wanting to allow the phone to display pages stored locally that have PHP in them and display them in a UIWebView.
Apple are extremely strict about not allowing 3rd-party code execution engines in apps, which would prohibit running a PHP interpreter.
If PHP is a true requirement, you'll have to host it on an external server and access the pages remotely.
Consider Javascript as an alternative language if you need to stay local, it's really the only way to execute run-time-generated code on the iPhone.
In order for that to work you would need:
A PHP compatible webserver running on your iPhone
Some sort of a PHP interpreter (not that there are so many different types of them out there) running on it too
I don't think this is/will be possible when thinking of Apple's strictness regarding 3rd party software and the low chances of someone even planning a port of PHP for the iPhone.
You mean like this PHP library? http://php.net/downloads.php
Running your debugged PHP code in an iOS app makes a lot of sense to me. Getting a PHP library in an iOS app and approved by Apple isn't easy, but it's been done. See: Running PHP on iOS? for details.

Categories