1973
Posts
1225
Kudos Received
124
Solutions
My Accepted Solutions
| Title | Views | Posted |
|---|---|---|
| 1907 | 04-03-2024 06:39 AM | |
| 3008 | 01-12-2024 08:19 AM | |
| 1641 | 12-07-2023 01:49 PM | |
| 2416 | 08-02-2023 07:30 AM | |
| 3350 | 03-29-2023 01:22 PM |
07-24-2018
04:21 PM
1 Kudo
I would recommend an HDF cluster of 5 nodes at least in a cluster and follow Matt's flow with added tasks. I do have a design with 100+ small MiniFi Java agents running in docker containers each handling one table. I did this for Kafka one per topic, but you could do the same. My worry would be you would kill Oracle. It's usually not used to have fast NiFi can pull especially if you are doing 50, 100+ concurrent reads. Have you looked at Sqoop, that can be trigger by NiFi and is good for a one time bulk extracts. You can use your entire Hadoop c luster to pull data. It's pretty fast and easy. Simple command line tool. https://docs.hortonworks.com/HDPDocuments/HDP3/HDP-3.0.0/migrating-data/content/hive_import_rdbms_data_into_hive.html You can even do an import all tables https://sqoop.apache.org/docs/1.4.7/SqoopUserGuide.html#_literal_sqoop_import_all_tables_literal If it's a one time export do that. Then for keeping Hive in sync with Oracle use Apache NiFi.
... View more
07-24-2018
03:45 PM
2 Kudos
Add one processor: ConvertRecord: Use AvroReader Use CSVRecordSetWriter
... View more
07-19-2018
01:49 PM
3 Kudos
Topic: IoT Edge Processing with Apache NiFi and MiniFi and Multiple Deep Learning Libraries Part 1: Multiple Devices with Data Keywords: Deep Learning On The Edge, GPS Ingestion, Sense-Hat and Rainbow Hat Sensor Ingest, WebCam Image Ingest In preparation for my talk at Strata in NYC, I am updating my IoT demos for more devices, more data types and more actions. I have three streams coming from each device including web camera images. When we are sending data from a MiniFi agent we need to define a port on an Apache NiFi server/cluster to receive it. So I design my MiniFi flow in the Apache NiFi UI (pretty soon there will be a special designer for this). You then highlight everything there and hit Create Template. You can then export it and convert to config.yml. Again, this process will be automated and connected with the NiFi Registry very shortly to make this less clicks. This is an example. When you connect to it in your flow you design in Apache NiFi UI you will connect to this port on the Remote Processor Group. If you are manually editing one (okay never do this, but sometimes I have to). You can copy that ID from this Port Details and past it in the file. Once MiniFi has it's config.yml and it's started, we will start getting messages to that Port. You can see I have two inputs, one for Movidius and one for Rainbow. I could just have one and route to what I want. It's up to you how you want to segment these flows. Welcome to Apache NiFi registry v0.2.0, this one works just as well. Very stable, but with some new magic. You can now connect to Git and Github!!!! We have structured JSON, so let's Infer a schema, clean it up and store it in the Hortonworks Schema Registry. That will make it versioned and REST enabled. I add one for the each of the two JSON file types I am sending from the rainbow device. You can see the schemas in full at the bottom of the article. The data is received from MiniFi on my local NiFi edge server for simple event processing, filtering and analysis. I route based on the two types of files, apply their schema, do a simple filter via SQL and send the converted AVRO formatted file to my cloud hosted cluster. Once I get the data I send it from my edge server to my cloud HDF 3.2 cluster. For images, I send them to my existing image storage processor group. For my other two types of files I convert them to Apache ORC and store in HDFS as Apache Hive tables. Server Dashboard Rainbow Processing Routing is Easy On High Humidity, Send a Slack Message (Query on humidity value) We can dive into any flowfile as it travels through the system and examine it's data and metadata. Now that my data is saved in HDFS with Hive tables on top I can use the latest version of Apache Zeppelin to analyze the data. I added some maps to Zeppelin via Helium, which is now available in HDP 3.0. I found a bunch of new chart types, this one could be insightful. So with the latest NiFi 1.7.1 and HDP 3.0 I can do a lot of interesting things. Next up, let's run some Dockerized TensorFlow application in my HDP 3.0 cluster. Strata Talk: https://conferences.oreilly.com/strata/strata-ny/public/schedule/detail/68140 Python Scripts https://github.com/tspannhw/StrataNYC2018/tree/master Schemas rainbow {
"type": "record",
"name": "rainbow",
"fields": [
{
"name": "tempf",
"type": "double",
"doc": "Type inferred from '84.15'"
},
{
"name": "cputemp",
"type": "double",
"doc": "Type inferred from '53.0'"
},
{
"name": "pressure",
"type": "double",
"doc": "Type inferred from '101028.56'"
},
{
"name": "host",
"type": "string",
"doc": "Type inferred from '\"rainbow\"'"
},
{
"name": "uniqueid",
"type": "string",
"doc": "Type inferred from '\"rainbow_uuid_20180718234222\"'"
},
{
"name": "ipaddress",
"type": "string",
"doc": "Type inferred from '\"192.168.1.165\"'"
},
{
"name": "temp",
"type": "double",
"doc": "Type inferred from '38.58'"
},
{
"name": "diskfree",
"type": "string",
"doc": "Type inferred from '\"4831.2 MB\"'"
},
{
"name": "altitude",
"type": "double",
"doc": "Type inferred from '80.65'"
},
{
"name": "ts",
"type": "string",
"doc": "Type inferred from '\"2018-07-18 23:42:22\"'"
},
{
"name": "tempf2",
"type": "double",
"doc": "Type inferred from '28.97'"
},
{
"name": "memory",
"type": "double",
"doc": "Type inferred from '32.3'"
}
]
}
gps {
"type": "record",
"name": "gps",
"fields": [
{
"name": "speed",
"type": "string",
"doc": "Type inferred from '\"0.066\"'"
},
{
"name": "diskfree",
"type": "string",
"doc": "Type inferred from '\"4830.3 MB\"'"
},
{
"name": "altitude",
"type": "string",
"doc": "Type inferred from '\"43.0\"'"
},
{
"name": "ts",
"type": "string",
"doc": "Type inferred from '\"2018-07-18 23:46:39\"'"
},
{
"name": "cputemp",
"type": "double",
"doc": "Type inferred from '54.0'"
},
{
"name": "latitude",
"type": "string",
"doc": "Type inferred from '\"40.2681555\"'"
},
{
"name": "track",
"type": "string",
"doc": "Type inferred from '\"0.0\"'"
},
{
"name": "memory",
"type": "double",
"doc": "Type inferred from '32.3'"
},
{
"name": "host",
"type": "string",
"doc": "Type inferred from '\"rainbow\"'"
},
{
"name": "uniqueid",
"type": "string",
"doc": "Type inferred from '\"gps_uuid_20180718234640\"'"
},
{
"name": "ipaddress",
"type": "string",
"doc": "Type inferred from '\"192.168.1.165\"'"
},
{
"name": "epd",
"type": "string",
"doc": "Type inferred from '\"nan\"'"
},
{
"name": "utc",
"type": "string",
"doc": "Type inferred from '\"2018-07-18T23:46:40.000Z\"'"
},
{
"name": "epx",
"type": "string",
"doc": "Type inferred from '\"40.135\"'"
},
{
"name": "epy",
"type": "string",
"doc": "Type inferred from '\"42.783\"'"
},
{
"name": "epv",
"type": "string",
"doc": "Type inferred from '\"171.35\"'"
},
{
"name": "ept",
"type": "string",
"doc": "Type inferred from '\"0.005\"'"
},
{
"name": "eps",
"type": "string",
"doc": "Type inferred from '\"85.57\"'"
},
{
"name": "longitude",
"type": "string",
"doc": "Type inferred from '\"-74.529094\"'"
},
{
"name": "mode",
"type": "string",
"doc": "Type inferred from '\"3\"'"
},
{
"name": "time",
"type": "string",
"doc": "Type inferred from '\"2018-07-18T23:46:40.000Z\"'"
},
{
"name": "climb",
"type": "string",
"doc": "Type inferred from '\"0.0\"'"
},
{
"name": "epc",
"type": "string",
"doc": "Type inferred from '\"nan\"'"
}
]
}
SQL %sql
CREATE EXTERNAL TABLE IF NOT EXISTS movidiussense (label5 STRING, runtime STRING, label1 STRING, diskfree STRING, top1 STRING, starttime STRING, label2 STRING, label3 STRING, top3pct STRING, host STRING, top5pct STRING, humidity DOUBLE, currenttime STRING, roll DOUBLE, uuid STRING, label4 STRING, tempf DOUBLE, y DOUBLE, top4pct STRING, cputemp2 DOUBLE, top5 STRING, top2pct STRING, ipaddress STRING, cputemp INT, pitch DOUBLE, x DOUBLE, z DOUBLE, yaw DOUBLE, pressure DOUBLE, top3 STRING, temp DOUBLE, memory DOUBLE, top4 STRING, imagefilename STRING, top1pct STRING, top2 STRING) STORED AS ORC LOCATION '/movidiussense'
%sql
CREATE EXTERNAL TABLE IF NOT EXISTS minitensorflow2 (image STRING, ts STRING, host STRING, score STRING, human_string STRING, node_id INT) STORED AS ORC LOCATION '/minifitensorflow2'
%sql
CREATE EXTERNAL TABLE IF NOT EXISTS gps (speed STRING, diskfree STRING, altitude STRING, ts STRING, cputemp DOUBLE, latitude STRING, track STRING, memory DOUBLE, host STRING, uniqueid STRING, ipaddress STRING, epd STRING, utc STRING, epx STRING, epy STRING, epv STRING, ept STRING, eps STRING, longitude STRING, mode STRING, time STRING, climb STRING, epc STRING) STORED AS ORC LOCATION '/gps'
%sql
CREATE EXTERNAL TABLE IF NOT EXISTS rainbow (tempf DOUBLE, cputemp DOUBLE, pressure DOUBLE, host STRING, uniqueid STRING, ipaddress STRING, temp DOUBLE, diskfree STRING, altitude DOUBLE, ts STRING,
tempf2 DOUBLE, memory DOUBLE) STORED AS ORC LOCATION '/rainbow'
References
https://community.hortonworks.com/articles/176932/apache-deep-learning-101-using-apache-mxnet-on-the.html https://cwiki.apache.org/confluence/display/MINIFI/Release+Notes#ReleaseNotes-Versioncpp-0.5.0 https://cwiki.apache.org/confluence/display/MINIFI/Release+Notes#ReleaseNotes-Version0.5.0 https://docs.hortonworks.com/HDPDocuments/HDF3/HDF-3.1.2/bk_release-notes/content/ch_hdf_relnotes.html#centos7 https://community.hortonworks.com/articles/108947/minifi-for-ble-bluetooth-low-energy-beacon-data-in.html https://community.hortonworks.com/content/kbentry/107379/minifi-for-image-capture-and-ingestion-from-raspbe.html NiFi Flows rainbow-server-processing.xml rainbow-minifi-ingest-in-nifi.xml
... View more
Labels:
07-16-2018
03:30 PM
Time to upgrade. Also check the logs sometimes there's corruption, sometimes it just takes a while to restart all the stopped processes.
... View more
07-14-2018
09:29 PM
3 Kudos
Scanning Documents into Data Lakes via Tesseract, Python, OpenCV and Apache NiFi Source: https://github.com/tspannhw/nifi-tesseract-python There are many awesome open source tools available to integrate with your Big Data Streaming flows. Take a look at these articles for installation and why the new version of Tesseract is different. I am officially recommending Python 3.6 or newer. Please don't use Python 2.7 if you don't have to. Friends don't let friends use old Python. Tesseract 4 with Deep Learning https://www.learnopencv.com/deep-learning-based-text-recognition-ocr-using-tesseract-and-opencv/ Github: https://github.com/spmallick/learnopencv/tree/master/OCR For installation on a Mac Laptop: brew install tesseract --HEAD
pip3.6 install pytesseract
brew install leptonica Note: if you have tesseract already, you may need to uninstall and unlink it first with brew. If you don't use brew, you can install another way. Summary
Execute the run.sh (https://github.com/tspannhw/nifi-tesseract-python/blob/master/pytesstest.py) . It will send a MQTT message of the text and some other attributes in JSON format to the tesseract topic in the specified MQTT broker. Apache NiFi will read from this topic via ConsumeMQTT The flow checks to see if it's valid JSON via RouteOnContent. We run MergeRecord to convert a bunch of JSON into one big Apache Avro File Then we run ConvertAvroToORC to make a superfast Apache ORC file for storage Then we store it in HDFS via PutHDFS Running The Python Script You could have this also hooked up to a scanner or point it at a directory. You could also have it scheduled to run every 30 seconds or so. I had this hooked up to a local Apache NiFi instance to schedule runs. This can also be run by MiniFi Java Agent or MiniFi C++ agent. Or on demand if you wish. Sending MQTT Messages From Python # MQTT
client = mqtt.Client()
client.username_pw_set("user","pass")
client.connect("server.server.com", 17769, 60)
client.publish("tesseract", payload=json_string, qos=0, retain=True) You will need to run: pip3 install paho-mqtt Create the HDFS Directory hdfs dfs -mkdir -p /tesseract
Create the External Hive Table (DDL Built by NiFi) CREATE EXTERNAL TABLE IF NOT EXISTS tesseract (`text` STRING, imgname STRING, host STRING, `end` STRING, te STRING, battery INT, systemtime STRING, cpu DOUBLE, diskusage STRING, memory DOUBLE, id STRING) STORED AS ORC
LOCATION '/tesseract';
This DDL is a side effect, it's built by our ORC conversion and HDFS storage commands. You could run that create script in Hive View 2, Beeline or another Apache Hive JDBC/ODBC tool. I used Apache Zeppelin since I am going to be doing queries there anyway. Let's Ingest Our Captured Images and Process Them with Apache Tika, TensorFlow and grab the metadata Consume MQTT Records and Store in Apache Hive Let's look at other fields in Zeppelin Let's Look at Our Records in Apache Zeppelin via a SQL Query (SELECT *FROM TESSERACT) ConsumeMQTT: Give me all the record from the tesseract topic from our MQTT Broker. Isolation from our ingest clients which could be 100,000 devices. MergeRecord: Merge all the JSON files sent via MQTT into one big AVRO File ConvertAVROToORC: converts are merged AVRO file PutHDFS Tesseract Example Schema in Hortonworks Schema Registry TIP: You can generate your schema with InferAvroSchema. Do that once, copy it and paste into Schema Registry. Then you can remove that step from your flow. The Schema Text {
"type": "record",
"name": "tesseract",
"fields": [
{
"name": "text",
"type": "string",
"doc": "Type inferred from '\"cgi cctong aiternacrety, pou can acces the complete Pro\nLance repesiiry from eh Provenance mens: The Provenance\n‘emu inchades the Date/Time, Actontype, the Unsque Fowie\nTD and other sata. Om the ar it is smal exci i oe:\n‘ick chs icon, and you get the flowin On the right, war\n‘cots like three inthe cic soemecaed gether Liege:\n\nLineage ts visualined as « lange direcnad sqycie graph (DAG) char\nSrones the seeps 1m she Gow where modifications oF routing ‘oot\nplace on the Aewiike. Righe-iieit « step lp the Lineage s view\nSetusls aboot the fowtle at that step ar expand the ow to ander:\nScand where & was potentially domed frum. Af the very bottom\nleft of the Lineage Oi a slider wath a play button to play the pro\n“sing flow (with scaled ame} and understand where tbe owtise\nSpent the meat Game of at whch PORN get muted\n\naide the Bowtie dealin, you cam: finn deed analy of box\n\ntern\n=\"'"
},
{
"name": "imgname",
"type": "string",
"doc": "Type inferred from '\"images/tesseract_image_20180613205132_c14779b8-1546-433e-8976-ddb5bfc5f978.jpg\"'"
},
{
"name": "host",
"type": "string",
"doc": "Type inferred from '\"HW13125.local\"'"
},
{
"name": "end",
"type": "string",
"doc": "Type inferred from '\"1528923095.3205361\"'"
},
{
"name": "te",
"type": "string",
"doc": "Type inferred from '\"3.7366552352905273\"'"
},
{
"name": "battery",
"type": "int",
"doc": "Type inferred from '100'"
},
{
"name": "systemtime",
"type": "string",
"doc": "Type inferred from '\"06/13/2018 16:51:35\"'"
},
{
"name": "cpu",
"type": "double",
"doc": "Type inferred from '22.8'"
},
{
"name": "diskusage",
"type": "string",
"doc": "Type inferred from '\"113759.7 MB\"'"
},
{
"name": "memory",
"type": "double",
"doc": "Type inferred from '69.4'"
},
{
"name": "id",
"type": "string",
"doc": "Type inferred from '\"20180613205132_c14779b8-1546-433e-8976-ddb5bfc5f978\"'"
}
]
} The above schema was generated by Infer Avro Schema in Apache NiFi. Image Analytics Results {
"tiffImageWidth" : "1280",
"ContentType" : "image/jpeg",
"JPEGImageWidth" : "1280 pixels",
"FileTypeDetectedFileTypeName" : "JPEG",
"tiffBitsPerSample" : "8",
"ThumbnailHeightPixels" : "0",
"label4" : "book jacket",
"YResolution" : "1 dot",
"label5" : "pill bottle",
"ImageWidth" : "1280 pixels",
"JFIFYResolution" : "1 dot",
"JPEGImageHeight" : "720 pixels",
"filecreationTime" : "2018-06-13T17:24:07-0400",
"JFIFThumbnailHeightPixels" : "0",
"DataPrecision" : "8 bits",
"XResolution" : "1 dot",
"ImageHeight" : "720 pixels",
"JPEGNumberofComponents" : "3",
"JFIFXResolution" : "1 dot",
"FileTypeExpectedFileNameExtension" : "jpg",
"JPEGDataPrecision" : "8 bits",
"FileSize" : "223716 bytes",
"probability4" : "1.74%",
"tiffImageLength" : "720",
"probability3" : "3.29%",
"probability2" : "6.13%",
"probability1" : "81.23%",
"FileName" : "apache-tika-2858986094088526803.tmp",
"filelastAccessTime" : "2018-06-13T17:24:07-0400",
"JFIFThumbnailWidthPixels" : "0",
"JPEGCompressionType" : "Baseline",
"JFIFVersion" : "1.1",
"filesize" : "223716",
"FileModifiedDate" : "Wed Jun 13 17:24:27 -04:00 2018",
"Component3" : "Cr component: Quantization table 1, Sampling factors 1 horiz/1 vert",
"Component1" : "Y component: Quantization table 0, Sampling factors 2 horiz/2 vert",
"Component2" : "Cb component: Quantization table 1, Sampling factors 1 horiz/1 vert",
"NumberofTables" : "4 Huffman tables",
"FileTypeDetectedFileTypeLongName" : "Joint Photographic Experts Group",
"fileowner" : "tspann",
"filepermissions" : "rw-r--r--",
"JPEGComponent3" : "Cr component: Quantization table 1, Sampling factors 1 horiz/1 vert",
"JPEGComponent2" : "Cb component: Quantization table 1, Sampling factors 1 horiz/1 vert",
"JPEGComponent1" : "Y component: Quantization table 0, Sampling factors 2 horiz/2 vert",
"FileTypeDetectedMIMEType" : "image/jpeg",
"NumberofComponents" : "3",
"HuffmanNumberofTables" : "4 Huffman tables",
"label1" : "menu",
"XParsedBy" : "org.apache.tika.parser.DefaultParser, org.apache.tika.parser.ocr.TesseractOCRParser, org.apache.tika.parser.jpeg.JpegParser",
"label2" : "web site",
"label3" : "crossword puzzle",
"absolutepath" : "/Volumes/seagate/opensourcecomputervision/images/",
"filelastModifiedTime" : "2018-06-13T17:24:07-0400",
"ThumbnailWidthPixels" : "0",
"filegroup" : "staff",
"ResolutionUnits" : "none",
"JFIFResolutionUnits" : "none",
"CompressionType" : "Baseline",
"probability5" : "1.12%"
}
This is built using a combination of Apache Tika, TensorFlow and other metadata analysis processors.
... View more
Labels:
07-11-2018
02:24 PM
2 Kudos
Capture Images from PicSum.com Free Images Process All the Images via TensorFlow Processor, SSD Predict via MMS and SqueezeNet v1.1 via MMS Apache Zeppelin SQL Against tblsqueeze11 Example Output from Squeeze v1.1 Storing Generic Data in HDFS via Schema Example SSD Data JSON High Level Flow From Server Apache NiFi Server Flows to Store Convert to Apache ORC Extract Attributes Convert JSON Arrays to Other Example Data Derived From TensorFlow Processor Schemas in Schema Registry Create Table in Zeppelin Query Table in Zeppelin Python Libraries git clone https://github.com/awslabs/mxnet-model-server.git
pip install opencv-python -U
pip install scikit-learn -U
pip install easydict -U
pip install scikit-image -U
pip install numpy -U
pip install mxnet -U
pip3.6 install opencv-python -U
pip3.6 install scikit-learn -U
pip3.6 install easydict -U
pip3.6 install scikit-image -U
pip3.6 install numpy -U
pip3.6 install mxnet -U Example Runs - Squeeze v1.1 mxnet-model-server --models squeezenet=squeezenet_v1.1.model --service mms/model_service/mxnet_vision_service.py --port 9999
[INFO 2018-07-10 16:50:26,840 PID:7730 /usr/local/lib/python3.6/site-packages/mms/request_handler/flask_handler.py:jsonify:159] Jsonifying the response: {'prediction': [[{'probability': 0.3365139067173004, 'class': 'n03710193 mailbox, letter box'}, {'probability': 0.1522996574640274, 'class': 'n03764736 milk can'}, {'probability': 0.08760709315538406, 'class': 'n03000134 chainlink fence'}, {'probability': 0.08103135228157043, 'class': 'n02747177 ashcan, trash can, garbage can, wastebin, ash bin, ash-bin, ashbin, dustbin, trash barrel, trash bin'}, {'probability': 0.04956872761249542, 'class': 'n02795169 barrel, cask'}]]}
[INFO 2018-07-10 16:50:26,842 PID:7730 /usr/local/lib/python3.6/site-packages/werkzeug/_internal.py:_log:88] 127.0.0.1 - - [10/Jul/2018 16:50:26] "POST /squeezenet/predict HTTP/1.1" 200 -
[INFO 2018-07-10 16:50:46,904 PID:7730 /usr/local/lib/python3.6/site-packages/mms/serving_frontend.py:predict_callback:467] Request input: data should be image with jpeg format.
[INFO 2018-07-10 16:50:46,960 PID:7730 /usr/local/lib/python3.6/site-packages/mms/request_handler/flask_handler.py:get_file_data:137] Getting file data from request.
[INFO 2018-07-10 16:50:47,020 PID:7730 /usr/local/lib/python3.6/site-packages/mms/serving_frontend.py:predict_callback:510] Response is text.
[INFO 2018-07-10 16:50:47,020 PID:7730 /usr/local/lib/python3.6/site-packages/mms/request_handler/flask_handler.py:jsonify:159] Jsonifying the response: {'prediction': [[{'probability': 0.1060439869761467, 'class': 'n02536864 coho, cohoe, coho salmon, blue jack, silver salmon, Oncorhynchus kisutch'}, {'probability': 0.06582894921302795, 'class': 'n01930112 nematode, nematode worm, roundworm'}, {'probability': 0.05008145794272423, 'class': 'n01751748 sea snake'}, {'probability': 0.03847070038318634, 'class': 'n01737021 water snake'}, {'probability': 0.03614763543009758, 'class': 'n09229709 bubble'}]]}
[INFO 2018-07-10 16:50:47,021 PID:7730 /usr/local/lib/python3.6/site-packages/werkzeug/_internal.py:_log:88] 127.0.0.1 - - [10/Jul/2018 16:50:47] "POST /squeezenet/predict HTTP/1.1" 200 -
mxnet-model-server --models SSD=resnet50_ssd_model.model --service ssd_service.py --port 9998
Apache MXNet Model Server Model Zoo https://github.com/awslabs/mxnet-model-server/blob/master/docs/model_zoo.md Connect to MMS /opt/demo/curl.sh
curl -X POST http://127.0.0.1:9998/SSD/predict -F "data=@$1" 2>/dev/null
/opt/demo/curl2.sh
curl -X POST http://127.0.0.1:9999/squeezenet/predict -F "data=@$1" 2>/dev/null
Flows mxnetserverlocal.xml mxnetmodelserver.xml Reference
https://community.hortonworks.com/articles/155435/using-the-new-mxnet-model-server.html https://community.hortonworks.com/articles/177232/apache-deep-learning-101-processing-apache-mxnet-m.html https://mxnet.incubator.apache.org/model_zoo/ https://medium.com/apache-mxnet/mxnet-1-2-adds-built-in-support-for-onnx-e2c7450ffc28 https://mxnet.incubator.apache.org/api/python/gluon/model_zoo.html https://www.kaggle.com/c/challenges-in-representation-learning-facial-expression-recognition-challenge/data https://github.com/onnx/models https://github.com/awslabs/mxnet-model-server/blob/master/docs/model_zoo.md#lstm-ptb https://github.com/awslabs/mxnet-model-server/blob/master/docs/model_zoo.md#arcface-resnet100_onnx
... View more
Labels:
07-08-2018
09:14 PM
if you can't ping, then networking is setup wrong on RPI. Home networking often has issues and blocks to stop this. You must make sure you have open ports and no firewalls blocking. Also make sure you really know the correct IP for your laptop/server. Then edit the /etc/hosts on the RPI put in that ip next to a name for it. Make sure NiFi is ready to accept remotes. then reboot. try ping again.
... View more
06-29-2018
09:27 PM
3 Kudos
Ingesting Blockchain data from btc.com and blockchain.com(.info). Like everything in Apache NiFi, this is trivial easy to ingest all these different feeds, process them, route them and store them for SQL access. API: blockchain.com https://blockchain.info/latestblock https://api.blockchain.info/charts/transactions-per-second?timespan=5weeks&rollingAverage=8hours&format=json https://blockchain.info/blocks/BTC.com?format=json https://api.blockchain.info/pools?timespan=5days https://api.blockchain.info/stats https://blockchain.info/ticker https://blockchain.info/tobtc?currency=USD&value=10000 Blocks For Today https://chain.api.btc.com/v3/block/date/${now():format('yyyyMMdd')} btc.com https://chain.api.btc.com/v3/block/latest https://chain.api.btc.com/v3/tx/unconfirmed Blockchain Stats Call {
"timestamp": 1.528924637E12,
"market_price_usd": 6284.846,
"hash_rate": 3.4875735626794174E10,
"total_fees_btc": 3517243180,
"n_btc_mined": 177500000000,
"n_tx": 208694,
"n_blocks_mined": 142,
"minutes_between_blocks": 9.5603,
"totalbc": 1709147500000000,
"n_blocks_total": 527318,
"estimated_transaction_volume_usd": 9.726263100037038E8,
"blocks_size": 130612249,
"miners_revenue_usd": 1.13766549673085E7,
"nextretarget": 528191,
"difficulty": 4940704885521,
"estimated_btc_sent": 15475738148615,
"miners_revenue_btc": 1810,
"total_btc_sent": 154234767570645,
"trade_volume_btc": 100767.92920045,
"trade_volume_usd": 6.333109167637314E8
}
Deeper Use Case Today's Blocks Apache Avro Schema in JSON Format Stored in Hortonworks Schema Registry {
"type": "record",
"name": "blocksfortoday",
"fields": [
{
"name": "height",
"type": "int",
"doc": "Type inferred from '527784'"
},
{
"name": "version",
"type": "int",
"doc": "Type inferred from '536870912'"
},
{
"name": "mrkl_root",
"type": "string",
"doc": "Type inferred from '\"c8f658ad595854f4c8c510b672447e838a2746e8724bfb26d0d127e5a4421385\"'"
},
{
"name": "timestamp",
"type": "int",
"doc": "Type inferred from '1529180826'"
},
{
"name": "bits",
"type": "int",
"doc": "Type inferred from '389609537'"
},
{
"name": "nonce",
"type": "int",
"doc": "Type inferred from '236046944'"
},
{
"name": "hash",
"type": "string",
"doc": "Type inferred from '\"00000000000000000017ca1d74bdee575dd48d4b3513eea2f7e06b313883d73d\"'"
},
{
"name": "prev_block_hash",
"type": "string",
"doc": "Type inferred from '\"00000000000000000000acf6259fffe63d36623c324f756faaf995a9e2896b87\"'"
},
{
"name": "next_block_hash",
"type": "string",
"doc": "Type inferred from '\"0000000000000000000000000000000000000000000000000000000000000000\"'"
},
{
"name": "size",
"type": "int",
"doc": "Type inferred from '189026'"
},
{
"name": "pool_difficulty",
"type": "long",
"doc": "Type inferred from '11831716619811'"
},
{
"name": "difficulty",
"type": "double",
"doc": "Type inferred from '4.940704885521827E12'"
},
{
"name": "tx_count",
"type": "int",
"doc": "Type inferred from '486'"
},
{
"name": "reward_block",
"type": "int",
"doc": "Type inferred from '1250000000'"
},
{
"name": "reward_fees",
"type": "int",
"doc": "Type inferred from '15691427'"
},
{
"name": "created_at",
"type": "int",
"doc": "Type inferred from '1529180835'"
},
{
"name": "confirmations",
"type": "int",
"doc": "Type inferred from '1'"
},
{
"name": "is_orphan",
"type": "boolean",
"doc": "Type inferred from 'false'"
},
{
"name": "curr_max_timestamp",
"type": "int",
"doc": "Type inferred from '1529180826'"
},
{
"name": "is_sw_block",
"type": "boolean",
"doc": "Type inferred from 'true'"
},
{
"name": "stripped_size",
"type": "int",
"doc": "Type inferred from '153817'"
},
{
"name": "weight",
"type": "int",
"doc": "Type inferred from '650477'"
},
{
"name": "extras",
"type": {
"type": "record",
"name": "extras",
"fields": [
{
"name": "pool_name",
"type": "string",
"doc": "Type inferred from '\"BTC.com\"'"
},
{
"name": "pool_link",
"type": "string",
"doc": "Type inferred from '\"https://pool.btc.com\"'"
}
]
},
"doc": "Type inferred from '{\"pool_name\":\"BTC.com\",\"pool_link\":\"https://pool.btc.com\"}'"
}
]
} QueryRecord Query SELECT *
FROM FLOWFILE
WHERE CAST(tx_count AS INT) > 0 Create an Apache Hive Table CREATE EXTERNAL TABLE IF NOT EXISTS blocksfortoday1 (height INT, version INT, mrkl_root STRING, timestamp INT, bits INT, nonce INT, hash STRING, prev_block_hash STRING, next_block_hash STRING, size INT, pool_difficulty BIGINT, difficulty DOUBLE, tx_count INT, reward_block INT, reward_fees INT, created_at INT, confirmations INT, is_orphan BOOLEAN, curr_max_timestamp INT, is_sw_block BOOLEAN, stripped_size INT, weight INT, extras STRUCT<pool_name:STRING, pool_link:STRING>)
STORED AS ORC
LOCATION '/blocksfortoday1' Example Apache Hive Query Run in Apache Zeppelin select * from blocksfortoday1 where CAST(tx_count as INT) > 500 order by created_at desc References: https://btc.com/ https://www.blockchain.com/en/explorer https://www.blockchain.com/en/api https://github.com/blockchain
... View more
Labels:
06-29-2018
09:20 PM
1 Kudo
Working with Infura.io Calling REST APIs is very easy with Apache NiFi, let's use this to ingest a lot of data about Ethereum blockchains and transactions. We can also ingest and examine network status data. Infura provides secure, reliable, scalable access to Ethereum and IPFS. Check out the current status: https://infura.io/status Apache NiFi Flows to Read From the Ethereum Blockchain via Infura REST APIs An Example REST Call We rename the file to make it unique and it note that it is from ethbtcfull API call. Example Data (JSON) {"base": "ETH", "quote": "BTC", "tickers": [{"bid": 0.0750827, "ask": 0.07530999, "volume": 5159.53235584, "timestamp": 1528924408, "exchange": "bitstamp"}, {"bid": 0.07519, "ask": 0.0752, "volume": 1938.0570499, "timestamp": 1528924408, "exchange": "gemini"}, {"bid": 0.07515, "ask": 0.07516, "volume": 10310.62442822, "timestamp": 1528924408, "exchange": "gdax"}, {"bid": 0.075208, "ask": 0.075226, "volume": 45253.638, "timestamp": 1528924409, "exchange": "hitbtc"}, {"bid": 0.075156, "ask": 0.07517, "volume": 25932.60119467, "timestamp": 1528924409, "exchange": "bitfinex"}, {"bid": 0.07503287, "ask": 0.0751326, "volume": 6713.29011055, "timestamp": 1528924409, "exchange": "exmo"}, {"bid": 0.075141, "ask": 0.075191, "volume": 136176.55, "timestamp": 1528924409, "exchange": "binance"}, {"bid": 0.073687, "ask": 0.07566, "volume": 99.58262408, "timestamp": 1528924409, "exchange": "quoine"}, {"bid": 0.074975, "ask": 0.075251, "volume": 698.857662, "timestamp": 1528924409, "exchange": "cex"}, {"bid": 0.07494, "ask": 0.07517503, "volume": 12079.03438486, "timestamp": 1528924409, "exchange": "livecoin"}, {"bid": 0.07421999, "ask": 0.07574378, "volume": 106.69757, "timestamp": 1528924410, "exchange": "btc_markets"}]} Calling INFURA REST APIs Note: For most use cases you do not need an API Key. Make sure you keep it under their limits and follow all of their terms of service. API Calls https://api.infura.io/v2/blacklist https://api.infura.io/v1/ticker/ethbtc/full https://api.infura.io/v1/ticker/ethbtc https://api.infura.io/v1/ticker/symbols Format The Files Example Expression Language ${filename:append('infurasymbols.'):append(${now():format('yyyymmddHHMMSS'):append(${md5}):append('.json')})} References:
https://blog.infura.io/getting-started-with-infura-28e41844cc89 https://infura.io/ https://infura.io/docs https://infura.io/status https://infura.docs.apiary.io/
... View more
Labels:
06-16-2018
02:38 PM
2 Kudos
Using Apache MXNet GluonCV with Apache NiFi for Deep Learning Computer Vision Source: https://github.com/tspannhw/OpenSourceComputerVision/ Gluon and Apache MXNet have been great for deep learning especially for newbies like me. It got even better! They added a Deep Learning Toolkit that is easy to use and has a number of great pre-trained models that you can easily use to do some general use cases around computer vision. So I have used a simple well-documented example that I tweaked to save the final image and send some JSON details via MQTT to Apache NiFi. This may sound familiar: https://community.hortonworks.com/articles/198912/ingesting-apache-mxnet-gluon-deep-learning-results.html GluonCV makes this even easier! Let's check it out. Again let's take a simpmle Python example tweak it, run it via a shell script and send the results over MQTT. See: https://gluon-cv.mxnet.io/build/examples_detection/demo_ssd.html#sphx-glr-build-examples-detection-demo-ssd-py Python Code: https://github.com/tspannhw/UsingGluonCV/tree/master This is the Saved Annotated Figure Simple Apache NiFi Flow to Ingest MQTT Data from GluonCV example Python and Store to Hive and Parquet and HBase. A simple flow:
ConsumeMQTT InferAvroSchema RouteOnContent MergeRecord (convert batches of json to single avro) ConvertAvroToORC PutHDFS PutParquet PutHbaseRecord Again Apache NiFi generates a schema for us from data examination. There's a really cool project coming out of New Jersey that has advanced schema generation looking at tables, I'll report on that later. We take it add, save to Schema Registry and are ready to Merge Records. One thing you may want to add is to turn regular types from: "type": "string" to "type": ["string","null"]. Schema {
"type": "record",
"name": "gluoncv",
"fields": [
{
"name": "imgname",
"type": "string",
"doc": "Type inferred from '\"images/gluoncv_image_20180615203319_6e0e5f0b-d2aa-4e94-b7e9-8bb7f29c9512.jpg\"'"
},
{
"name": "host",
"type": "string",
"doc": "Type inferred from '\"HW13125.local\"'"
},
{
"name": "shape",
"type": "string",
"doc": "Type inferred from '\"(1, 3, 512, 910)\"'"
},
{
"name": "end",
"type": "string",
"doc": "Type inferred from '\"1529094800.88097\"'"
},
{
"name": "te",
"type": "string",
"doc": "Type inferred from '\"2.4256367683410645\"'"
},
{
"name": "battery",
"type": "int",
"doc": "Type inferred from '100'"
},
{
"name": "systemtime",
"type": "string",
"doc": "Type inferred from '\"06/15/2018 16:33:20\"'"
},
{
"name": "cpu",
"type": "double",
"doc": "Type inferred from '23.2'"
},
{
"name": "diskusage",
"type": "string",
"doc": "Type inferred from '\"112000.8 MB\"'"
},
{
"name": "memory",
"type": "double",
"doc": "Type inferred from '65.8'"
},
{
"name": "id",
"type": "string",
"doc": "Type inferred from '\"20180615203319_6e0e5f0b-d2aa-4e94-b7e9-8bb7f29c9512\"'"
}
]
}
Example JSON {"imgname": "images/gluoncv_image_20180615203615_c83fed6f-2ec8-4841-97e3-40985f7859ad.jpg", "host": "HW13125.local", "shape": "(1, 3, 512, 910)", "end": "1529094976.237143", "te": "1.8907802104949951", "battery": 100, "systemtime": "06/15/2018 16:36:16", "cpu": 29.3, "diskusage": "112008.6 MB", "memory": 66.5, "id": "20180615203615_c83fed6f-2ec8-4841-97e3-40985f7859ad"} Table Generated CREATE EXTERNAL TABLE IF NOT EXISTS gluoncv (imgname STRING, host STRING, shape STRING, end STRING, te STRING, battery INT, systemtime STRING, cpu DOUBLE, diskusage STRING, memory DOUBLE, id STRING) STORED AS ORC LOCATION '/gluoncv' Parquet Table create external table gluoncv_parquet (imgname STRING, host STRING, shape STRING, end STRING, te STRING, battery INT, systemtime STRING, cpu DOUBLE, diskusage STRING, memory DOUBLE, id STRING) STORED AS PARQUET LOCATION '/gluoncvpar' Reference: https://gluon-cv.mxnet.io/ https://gluon-cv.mxnet.io/build/examples_detection/index.html https://medium.com/apache-mxnet/gluoncv-deep-learning-toolkit-for-computer-vision-9218a907e8da
... View more
Labels: