--- title: Task hackathon tag: hackathon irifellow --- Task === ## Architecture - User - Web (frontend) - Server (App engine) - ML engine ## Phase 1 ### Export model and deploy to mlengine - [source](https://medium.com/searce/creating-deep-learning-models-training-and-deploying-it-on-google-cloud-ml-engine-using-9a4ed6a84076) ```bash #ENVIRONMENT VARIABLES $ export MODEL_NAME kaggle_housing_price_prediction $ export MODEL_PATH=gs://cloud-ml-job- bucket/export/exporter/1545905371 #CREATE MODEL $ gcloud ml-engine models create $MODEL_NAME $ gcloud ml-engine versions create "version_1" --model $MODEL_NAME - -origin $MODEL_PATH ``` ### Web app: - [ ] Find template (Bao) - [ ] upload image - [ ] Send image to mlengine (Kien) - [ ] Have database to store price and label - [ ] Calculate price and show item on screen - [ ] Preprocess return result (Filter out none make sense detected item) [coco label](https://raw.githubusercontent.com/amikelive/coco-labels/master/coco-labels-paper.txt) ```python import numpy as np from googleapiclient import discovery from flask import Flask, jsonify, render_template, request import os os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = './cloudml-b436315c38f2.json' PROJECT = "gentle-voltage-235901" MODEL = "mnist" INPUT_NODE = "flatten_input" VERSION = "v1" def predict_json(project, model, instances, version=None): """Send json data to a deployed model for prediction. Args: project (str): project where the Cloud ML Engine Model is deployed. model (str): model name. instances ([Mapping[str: Any]]): Keys should be the names of Tensors your deployed model expects as inputs. Values should be datatypes convertible to Tensors, or (potentially nested) lists of datatypes convertible to tensors. version: str, version of the model to target. Returns: Mapping[str: any]: dictionary of prediction results defined by the model. """ # Create the ML Engine service object. # To authenticate set the environment variable # GOOGLE_APPLICATION_CREDENTIALS=<path_to_service_account_file> # CREDENTIALS = app_engine.Credentials() # service = discovery.build('ml', 'v1', credentials=CREDENTIALS) service = discovery.build('ml', 'v1') name = 'projects/{}/models/{}'.format(project, model) if version is not None: name += '/versions/{}'.format(version) response = service.projects().predict( name=name, body={'instances': instances} ).execute() if 'error' in response: raise RuntimeError(response['error']) return response['predictions'] ``` ## Phase 2 ### Model: #### Train on D2S dataset - [ ] https://www.mvtec.com/company/research/datasets/mvtec-d2s/ - [ ] Train fast r-cnn with backbone [vgg, resnet, inceptionet v2 ...] - [ ] Collect data of vietnamese product - [ ] Crawl Price of produce ### Web app: - [] Capture from webcam ## ## Bonus: - [ ] Know trade mark of each product (exp: diffrent price base on brand: bottle of water - aquafina)