Skip to content

Instantly share code, notes, and snippets.

View hayatoy's full-sized avatar

hayatoy

View GitHub Profile
import base64
import io
import json
from PIL import Image
from google.cloud import aiplatform
PROJECT_ID = ""
LOCATION = "us-central1"
ENDPOINT_ID = ""
@hayatoy
hayatoy / app.py
Last active December 6, 2021 23:39
Vertex AI Prediction example
@app.route('/predict',methods=['GET','POST'])
def predict():
# Decode image
request_json = request.get_json(silent=True, force=True)
data = request_json['instances']
decoded = base64.urlsafe_b64decode(data[0]["b64"])
img_in_bytes = io.BytesIO(decoded)
img = Image.open(img_in_bytes).convert('RGB')
# Generate Anime image
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@hayatoy
hayatoy / snippet.py
Created May 2, 2019 15:06
picamera+overlay
for foo in camera.capture_continuous(stream,
format='rgb',
use_video_port=True):
# Make Image object from camera stream
stream.truncate()
stream.seek(0)
input = np.frombuffer(stream.getvalue(), dtype=np.uint8)
input = input.reshape((CAMERA_HEIGHT, CAMERA_WIDTH, 3))
image = Image.fromarray(input)
# image.save("out.jpg")
@hayatoy
hayatoy / dataflow_shuffle_example.ipynb
Last active August 27, 2018 19:24
Dataflow Shuffle Example
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@hayatoy
hayatoy / tensorflow_from_dataflow.py
Last active March 7, 2017 14:06
Training Multiple Models of TensorFlow using Dataflow
import apache_beam as beam
import apache_beam.transforms.window as window
options = beam.utils.pipeline_options.PipelineOptions()
google_cloud_options = options.view_as(beam.utils.pipeline_options.GoogleCloudOptions)
google_cloud_options.project = '{PROJECTID}'
google_cloud_options.job_name = 'tensorflow-gs'
google_cloud_options.staging_location = 'gs://{BUCKET_NAME}/binaries'
google_cloud_options.temp_location = 'gs://{BUCKET_NAME}/temp'