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
import base64 | |
import io | |
import json | |
from PIL import Image | |
from google.cloud import aiplatform | |
PROJECT_ID = "" | |
LOCATION = "us-central1" | |
ENDPOINT_ID = "" |
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
@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.
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
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") |
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.
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
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' |