This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val split :RDD[String] = rdd.flatMap(_.split(" ")) | |
| val trim :RDD[String] = split.map(_.trim.toLowerCase) | |
| val stopwordsRemoved = trim.filter( x => !Set("and", "the", "is", "to", "she", "he").contains(x)) | |
| val assignOne = stopwordsRemoved.map((_, 1)) | |
| val counts = assignOne.reduceByKey(_ + _) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val streamingContext: StreamingContext = new StreamingContext(sparkContext, Seconds(20)) | |
| val lines: ReceiverInputDStream[String] = streamingContext.socketTextStream("localhost", 9999) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val spark: SparkSession = SparkSession.builder() | |
| .master("local[*]") | |
| .appName("simple-app") | |
| .getOrCreate() | |
| val dataSet: Dataset[String] = spark.read.textFile("textfile.csv") | |
| val df: DataFrame = dataSet.toDF() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val conf = new SparkConf().setMaster("local[*").setAppName("simple-app") | |
| val sparkContext = new SparkContext(conf) | |
| //Loading data with Spark Context returns an RDD | |
| val rdd: RDD[String] = sparkContext.textFile("textfile.csv") | |
| //Also you can create an RDD by parallizing an existing Data | |
| val data: Array[Int] = Array(1, 2, 3, 4, 5, 6, 6, 7, 7) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| dataset = generate(tfrecordfiles) | |
| IM_SIZE = 224 # image size | |
| image_input = tf.keras.Input(shape=(IM_SIZE, IM_SIZE, 3), name='input_layer') | |
| # Some convolutional layers | |
| conv_1 = tf.keras.layers.Conv2D(32, | |
| kernel_size=(3, 3), | |
| padding='same', | |
| activation='relu')(image_input) | |
| conv_1 = tf.keras.layers.MaxPooling2D(padding='same')(conv_1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| scala> val examplelist = List(1, 2, 3, 4, 5) | |
| examplelist: List[Int] = List(1, 2, 3, 4, 5) | |
| scala> examplelist.map(x => List(x*x)) | |
| res1: List[List[Int]] = List(List(1), List(4), List(9), List(16), List(25)) | |
| scala> examplelist.flatMap(x => List(x*x)) | |
| res4: List[Int] = List(1, 4, 9, 16, 25) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| resource_field = {"Message": fields.String, | |
| "Image_Embedding": fields.List(fields.String), | |
| "ID_Embedding": fields.List(fields.String), | |
| "Confidence": fields.String, | |
| "Round Trip Time": fields.String, | |
| "Process First Image Time": fields.String, | |
| "Process Second Image Time": fields.String, | |
| "Generate and Compare Time": fields.String} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| resource_field = {"Message": fields.String, | |
| "Image_Embedding": fields.List(fields.String), | |
| "ID_Embedding": fields.List(fields.String), | |
| "Confidence": fields.String, | |
| "Round Trip Time": fields.String, | |
| "Process First Image Time": fields.String, | |
| "Process Second Image Time": fields.String, | |
| "Generate and Compare Time": fields.String} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| docker run -p 8500:8500 --mount type=bind,source=/home/sfx/models/,target=/models/2 -e MODEL_NAME=2 -t tensorflow/serving | |
| #please change the /home/sfx/models absolute path of model on your server |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| docker run -p 8501:8501 --mount type=bind,source=/path/to/my_model/,target=/models/my_model \ | |
| -e MODEL_NAME=my_model -t tensorflow/serving |
NewerOlder