Windows, setting environment in jupyter for tensorflow

April 28, 2018 Leave a comment

After installing Anacoda and tensorflow, you might face challenge of running jupyter and choosing the environment. First you should install ipykernel.

activate tensorflow
conda install ipykernel

Then add your environment to the jupyter

python -m ipykernel install --user --name tensorflow --display-name "Python (tensorflow)"

For more details have a look at https://stackoverflow.com/questions/39604271/conda-environments-not-showing-up-in-jupyter-notebook/43617908

Advertisements

Starting with Tensorflow on Windows

April 28, 2018 Leave a comment

As usual, follow all the paths stated in the Tensorflow’s official post. If you chose the option of Anaconda (I will strongly urge to choose that) after the installation, you will be stuck into what to do.

  • Begin by starting conda environment.
  • If you have python2.7, typing in python you will be taken to python2.7 environment. Tensorflow does not work in 2.7 for windows, why? I wish I knew. At this moment I just want to move forward, so do following.  (following is copied from the above mentioned official post)
:> activate tensorflow
  • You command prompt will change
(tensorflow)C:>  # Your prompt should change
  • Now type in python and you are in the game.

 

working with fastHOG; moving towards fast object detection

July 9, 2013 Leave a comment

Although HOG calculations don’t take much portion of time when running object detectors, but the dot products do. Sending HOG pyramid to the GPU steals away all the benefits of calculating dot product on GPU, only way is to calculate HOG also on GPU for different scales of pyramid.

Therefore I am trying to fastHOG. It requires quite a bit of libraries.

one of the libray is FLTK

if you don’t want to put it in the default location (which might be restricted) the following will help make install prefix=New_Dictionary_location

or you can set up through configure file

./configure –bindir=/location/fltk/bin –libdir=/location/fltk/lib –includedir=/location/fltk/include/ –prefix=/location/fltk

Categories: Uncategorized Tags: , ,

C++ Using template type to make decision about how to extend class

June 4, 2013 Leave a comment

so the problem was a follow, I had a parent template class and as usual template child class extended from the parent class. Objective was depending upon what type of the Child class to select the type of the parent template.

Therefore went looking for how to pick up the  type of the variable depending upon the template. Found this really nice post. http://stackoverflow.com/questions/8243134/c-templates-select-different-type-based-on-value-of-template-parameter

Using information in it and little experimentation following code shows how to do it.

//============================================================================
// Name        : forTestingAndTrying.cpp
// Author      : Mohsen Ali
// Version     :
// Copyright   : use freely on your own risk, but contribute
// Description : testing template
//============================================================================
#include <iostream>
#include <type_traits>
using namespace std;

/*Parent Class*/
template<typename T>
struct parentMe{
T myData;
void print(void){
cout << "parentMe datasize " << sizeof(myData) <<endl;
}

};

template<bool B>
struct stUseless: parentMe<typename std::conditional<B, double, float>::type>{
typedef typename std::conditional<B, char, int>::type T;
typedef typename std::conditional<B, double, float>::type T2;

T dat;
void print(){
cout <<"Size is " <<  sizeof(dat) <<endl;
parentMe<T2>::print();
cout <<" --------------------  " <<  endl;
}
};

int main() {
stUseless<false> a;
a.print();

stUseless<true> b;
b.print();

cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
return 0;
}

and the output is below

Size is 4
parentMe datasize 4
——————–
Size is 1
parentMe datasize 8
——————–
!!!Hello World!!!

Categories: C++ Tags: , , ,

jsoncpp writing back the structures and arrays

May 24, 2013 Leave a comment

Well successfully read the json file of the matlab mat structure. Lots of things to care of, not as simple as it looks.

Now writing back, that is taking the C++ class, structure and basic data types and outputting a json structure. Since I have already written the reader to the writer should match the reader’s expectation.

This one is quite decent information and advice on how to design class for such activity. http://www.danielsoltyka.com/programming/2011/04/15/simple-class-serialization-with-jsoncpp/

 

Will follow the writing part now and later will try to implement the reader in much more structured way.

Categories: C++, code, jsoncpp Tags: , , , ,

parsing jason nested array using jsoncpp

May 22, 2013 Leave a comment

so first experiments with the json and json cpp.

the json string is as follow

{“id”: 1,”tags”: [ [800, 99.7], [], [76] ],”stock”: {“warehouse”: 300,”retail”: 20}}

Wanted to read the nested arrays of “tags” as you can see such an array could be e.g. cell datatype in the matlab or could be represented as the array of vectors

int main (){</pre>
unsigned int i,j;
char fileName[] ="abc.json";

ifstream infile;
infile.exceptions (ios::failbit|ios::badbit);
try
{
infile.open (fileName);
}
catch (ifstream::failure& e)
{
cerr<<"\n Exception opening file "<<fileName<<": "<<e.what ();
return 0;
}

string input;
Json::Reader reader;
Json::Value root;
bool parsingSuccessful;

try
{
while (getline (infile,input,'\n'))
{
if (false == (parsingSuccessful = reader.parse (input,root)))
{
cerr<<"\nFailed to parse configuration:"
<<reader.getFormatedErrorMessages ();
return 0;
}
else
{

int verbName = root.get ("id","").asInt ();
Json::Value data = root.get ("tags",0);
cout << "size is " << data.size() <<endl;

//vector<float> freq (mWidth * mHeight);
for (int i = 0; i < data.size(); i++){
int sizeint = data[i].size();
cout <<endl <<"---------------" <<endl;
cout << "Size of individual is " <<sizeint << endl;
Json::Value dat1 = data[i];

for(int j=0; j< dat1.size(); j++){
cout << dat1[j].asDouble() << " ,";
}

}
}
}
}
catch (ifstream::failure& e)
{

}

return 0;
}
<pre>
Categories: C++, code, jsoncpp, matlab Tags: , , , , , ,

matlab and OpenCV development kit

January 26, 2013 Leave a comment

mexopencv comes from Kota Yamaguchi. It is a development kit which is collection of mex functions for bridging matlab and OpenCV. I have not used it till now, but it looks easy to use. Especially interesting to me is it provides the data conversion utility to transfer matlab data to OpenCV datatypes, so one can use them to write their own mex functions. 

So do use and provide feed back. 

 

http://www.cs.stonybrook.edu/~kyamagu/mexopencv/

Categories: Uncategorized Tags: ,