How can I use Tensorflow in tizen studio? - tensorflow

I want to use tensorflow in tizen.
Tizen studio's architecture is x86.
But tensorflow is only 64-bit.
How can I use tensorflow in tizen studio??

Download packages for target device
tensorflow
python
db4
mkdir tmp
cd tmp
BASE_URL='http://download.tizen.org/snapshots/tizen/5.0-base/latest/repos/standard/packages/armv7l/'
wget -O - $BASE_URL 2>/dev/null | egrep 'db4-[0-9]' | awk -F'"' '{print $2}' | xargs -i wget $BASE_URL{}
wget -O - $BASE_URL 2>/dev/null | egrep 'python-[0-9]' | awk -F'"' '{print $2}' | xargs -i wget $BASE_URL{}
UNIFIED_URL='http://download.tizen.org/snapshots/tizen/5.0-unified/latest/repos/standard/packages/armv7l/'
wget -O - $UNIFIED_URL 2>/dev/null | grep 'tensorflow-v' | awk -F'"' '{print $2}' | xargs -i wget $UNIFIED_URL{}
Install packages on target device
sdb root on; sdb shell 'mount -o remount,rw /'
sdb push *.rpm /tmp
sdb shell 'cd /tmp; rpm -ivh --force db4*.rpm; rpm -ivh --force *python*.rpm; rpm -ivh --force tensorflow*.rpm'
cd ..
rm -r tmp
Download packages needed for building
tensorflow
tensorflow-devel
libpython-2.7
libgfortran
libgomp
mkdir tmp
cd tmp
BASE_URL='http://download.tizen.org/snapshots/tizen/5.0-base/latest/repos/standard/packages/armv7l/'
wget -O - $BASE_URL 2>/dev/null | grep 'libpython-2.7' | awk -F'"' '{print $2}' | xargs -i wget $BASE_URL{}
wget -O - $BASE_URL 2>/dev/null | grep 'libgfortran-' | awk -F'"' '{print $2}' | xargs -i wget $BASE_URL{}
wget -O - $BASE_URL 2>/dev/null | grep 'libgomp-' | awk -F'"' '{print $2}' | xargs -i wget $BASE_URL{}
UNIFIED_URL='http://download.tizen.org/snapshots/tizen/5.0-unified/latest/repos/standard/packages/armv7l/'
wget -O - $UNIFIED_URL 2>/dev/null | grep 'tensorflow' | grep -v 'lite' | awk -F'"' '{print $2}' | xargs -i wget $UNIFIED_URL{}
Extract header and so files and selectively import to project lib folder
ls *.rpm | xargs -i bash -c "rpm2cpio {} | cpio -idmv"
cd usr/lib/
ln -s libpython2.7.so.1.0 libpython2.7.so
ln -s libgfortran.so.3 libgfortran.so
cp libgfortran.so* libgomp.so.1* libpython2.7.so* libpywrap_tensorflow_internal.so ../../../lib/
cd ../include
cp -r tensorflow ../../../inc/
cd ../../..
rm -r tmp
Set up include path in Tizen Studio project
screenshot
Set up library path and add libraries to Tizen Studio project
screenshot
Note that if you want to build the project for emulator, you have to use library files for x86 architecture, so you would have to replace "armv7l" in all the URLs above with "i686"

Tizen studio is just development tool.
Tizen supports x86-64(AMD64) and you can use the tensorflow on Tizen.
If you want to use Tizen with tensorflow, you need to install some packages(tensorflow, python,...) yourself.

If you can afford using Tensorflow-Lite, you can use it directly in Tizen-latest. Soon, with Tizen 5.5 M2, there will be Machine Learning APIs that allows app developers to directly plugin .tflite models as well as their own native models (as .so files or as functions) without worrying about importing external libraries.
Anyway, if you want to do it right now, use the Tizen-latest (Tizen:Unified project in build.tizen.org), use tensorflow-lite-dev.rpm package directly or use nnstreamer-capi package, which gives you some easy-to-use interfaces. Note that nnstreamer (https://github.com/nnsuite/nnstreamer ) is going to be the main engine for Tizen-Machine-Learning (backend of its Machine Learning API sets). Although nnstreamer is compatible with Tensorflow (non-lite), Caffe2, PyTorch, ROS, and so on, they are not included in Tizen by default.

Related

How do I transfer small files quickly over the network with zstd?

As the question states, I want to backup many small files and send them via ssh to a destination. Does rsync speed things up significantly vs tar?
This works quite well, significantly faster than gzip.
Push (Upload)
tar -c --zstd src_dir | ssh user#dest_addr "cd dest_dir && tar -x --zstd"
This does the following
Creates a tar file using Zstd and outputs it via STDOUT
Connects via ssh, piping STDOUT over the network
Reads data from STDIN, and extracts it
Custom zstd flags
This uses maximum compression (default level is 3) and multithreading.
tar -c -I "zstd -19 -T0" src_dir | ssh user#dest_addr "cd dest_dir && tar -x --zstd"
With progress
tar -c --zstd src_dir | pv --timer --rate | ssh user#dst_addr "cd dest_dir && tar -x --zstd"
Pull (Download)
ssh user#dest_addr "tar --zstd -cf - src_dir" | tar -x --zstd --directory dest_dir

Clone all projects from cgit

I have to download all projects that are hosted on some cgit instance. There are several hundreds of repositories, so it is tedious to do this manually.
How can it be done?
Seems that it is possible to do it with curl by parsing pages one by one. By is there more convenient interface?
There does not seem to be any official or convenient API for CGit to export/clone all its repositories.
You can try those alternatives:
curl -s http://git.suckless.org/ |
xml sel -N x="http://www.w3.org/1999/xhtml" -t -m "//x:a" -v '#title' -n |
grep . |
while read repo
do git clone git://git.suckless.org/$repo
done
Or:
curl -s http://git.suckless.org/ | xml pyx | awk '$1 == "Atitle" { print $2 }'
Or:
curl -s http://git.suckless.org/ | xml pyx | awk '$1 == "Atitle" { printf("git clone %s\n",$2) }' | s
I suspect this work for one page of Git repositories as listed by CGit: you might still have to repeat that for all subsequent Git repositories pages.

Create License agreement screen in OSX

I am trying to implement license agreement as shown in the attached image, I can create a new WindowController and design in the same way, but i want to know if we have any default screens in Xcode to do this kind of stuff, as i noticed that most of the apps have similar kind of design.
That's a disk mount license agreement. You can embed a license agreement into a DMG disk image, to be displayed with this screen when a user mounts the image.
If your application is in example/Example.app, you can create example.dmg, embedding EULA.txt into it as follows:
hdiutil create -srcfolder example/ -volname "Example" "example.dmg"
./eula_into_dmg.sh "example.dmg" "EULA.txt"
# you should also codesign the dmg if you're going to distribute it:
codesign -s "$CODE_SIGN_IDENTITY" -v "$dmg"
This is eula_into_dmg.sh:
#!/bin/bash -u
if [[ $# -ne 2 ]]; then
echo "Usage: $0 <dmg> <license>"
exit 1
fi
prefix=$(base64 -D <<<\
H4sIAJtVUFoCA4VWW2vbSBh9bn7Fh3ahbci6o9FcLPahJJIMBbcNjaH7qjpyYupaiyW3pGX/+55vpJF1\
ianBYmTjo/Ody4zv8zqnl6v3t8uX9CqU8ysKlrfbdfCafl28+DMII6XIaGPIhFaTSawiKVSCW5ORsfxZ\
aGxAvdebS5qlxSY/7mpa5vuHY/5Al28YzWgpSMWAVEpb0hIroVVEZsFAGc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ntSvc/iogHYQYKAAA= | gunzip -)
suffix=$(base64 -D <<<\
H4sIANNVUFoCA6u15uJKSSxJVFAvLqnMUVfQMDUwMNBRUHLNS8/JLM5QCPZxVNJUqObiVFECShgrAAkD\
OOEMIiyBhKEJQkJJAQnoaynowcAxCKWgpQ81zUABgzAyRzMXp2nqEBNhphliMw3JXEewuThNAwEtZLeh\
+wqNQDEIbtoxZONAZtVacwEAUriwzWEBAAA= | gunzip -)
temp=$(mktemp)
echo -n "$prefix" > "$temp"
cat "$2" | dd conv=swab | hexdump -v -e '8/2 "%04x " "\n"' | sed -e 's/ *$//' -e 's/^/ $"/' -e 's/$/"/' >> "$temp"
echo -n "$suffix" >> "$temp"
hdiutil unflatten "$1"
Rez -a "$temp" -o "$1"
hdiutil flatten "$1"
rm "$temp"
There is no default UI Element for it, nor is there a well known community option. Best option is to design your own.

Comparing version strings in Zsh

I am using this script:
if [[ -f /usr/bin/atom ]]; then
ATOM_INSTALLED_VERSION=$(rpm -qi atom | grep "Version" | cut -d ':' -f 2 | cut -d ' ' -f 2)
else
ATOM_INSTALLED_VERSION=""
fi
ATOM_LATEST_VERSION=$(wget -q "https://api.github.com/repos/atom/atom/releases/latest" -O - | grep -E "https.*atom-amd64.tar.gz" | cut -d '"' -f 4 | cut -d '/' -f 8 | sed 's/v//g')
if [[ "$ATOM_INSTALLED_VERSION" -lt "$ATOM_LATEST_VERSION" ]]; then
sudo dnf install -y https://github.com/atom/atom/releases/download/v${ATOM_LATEST_VERSION}/atom.x86_64.rpm
fi
to check for Atom upgrades and install them if available. The problem is that the test:
[[ "$ATOM_INSTALLED_VERSION" -lt "$ATOM_LATEST_VERSION" ]]
returns:
zsh: bad floating point constant
where (showing input and output):
$ printf $ATOM_INSTALLED_VERSION
1.8.0%
$ printf $ATOM_LATEST_VERSION
1.12.7%
how do I write a test that will work? I have tried using (( $ATOM_INSTALLED_VERSION < $ATOM_LATEST_VERSION )) but that also failed giving:
zsh: bad floating point constant
zsh comes equipped with a function for version string comparisons, see zshcontrib(1).
installed=$(rpm -q --qf '%{VERSION}' atom)
latest=$(wget -q ...)
autoload is-at-least
is-at-least $latest ${installed:-0} || sudo dnf install -y ...

background xargs/wget not adhering to -P and -n limits

I'm having a problem with xargs and Wget when run as shell scripts in an Applescript app. I want Wget to run 4 parallel processes in the background. The problem: basically, when I try to run the process in the background with
cat urls.txt | xargs -P 4 -n 1 /usr/local/bin/wget -q -E -b 1> NUL 2> NUL
a Wget process is apparently started for each URL passed in from the .txt file. This is too burdensome on the user's memory. When I run it in the foreground, however, with something like:
cat urls.txt | xargs -P 4 -n 1 /usr/local/bin/wget -q -E
I seem to get the four parallel Wget processes I need. Does anybody know how to get this script to run in the background with only 4 processes? I'm a bit of a novice, and I'm afraid I can't figure out why backgrounding the process causes this change.
You might run xargs on the background instead:
cat urls.txt | xargs -P4 -n1 wget -q &
Or if you want to return control to the AppleScript, disown the xargs process:
do shell script "cat urls.txt | xargs -P4 -n1 /usr/local/bin/wget -q & disown $!"
As far as I can tell, I have solved the problem with
cat urls.txt| (xargs -P4 -n1 wget -q -E >/dev/null 2>&1) &
There may well be a better solution, though...