Install OpenCV 4.1.2 on Raspbian Buster
$ chmod +x *.sh
$ ./download-opencv.sh
$ ./install-deps.sh
$ ./build-opencv.sh
$ cd ~/opencv/opencv-4.1.2/build
$ sudo make install| import functools | |
| import numpy as np | |
| import tensorflow.compat.v1 as tf | |
| from tensorflow.python.tpu import tpu_function | |
| BATCH_NORM_DECAY = 0.9 | |
| BATCH_NORM_EPSILON = 1e-5 | |
Install OpenCV 4.1.2 on Raspbian Buster
$ chmod +x *.sh
$ ./download-opencv.sh
$ ./install-deps.sh
$ ./build-opencv.sh
$ cd ~/opencv/opencv-4.1.2/build
$ sudo make install| # Copyright 2022 Google LLC. | |
| # SPDX-License-Identifier: Apache-2.0 | |
| # Author: Maithra Raghu <maithra@google.com> | |
| def compute_distance_matrix(patch_size, num_patches, length): | |
| """Helper function to compute distance matrix.""" | |
| distance_matrix = np.zeros((num_patches, num_patches)) |
| import torch | |
| from diffusers import FluxPipeline | |
| from torch import nn | |
| class ModelOffloaderV2: | |
| def __init__(self, model: nn.Module, record_stream: bool = False): | |
| # move model to pinned memory. keep a model copy in CPU pinned memory. | |
| for p in model.parameters(): | |
| p.data = p.data.cpu().pin_memory() |
| def get_classification_report(y_test, y_pred): | |
| '''Source: https://stackoverflow.com/questions/39662398/scikit-learn-output-metrics-classification-report-into-csv-tab-delimited-format''' | |
| from sklearn import metrics | |
| report = metrics.classification_report(y_test, y_pred, output_dict=True) | |
| df_classification_report = pd.DataFrame(report).transpose() | |
| df_classification_report = df_classification_report.sort_values(by=['f1-score'], ascending=False) | |
| return df_classification_report |
| import sys | |
| from collections import OrderedDict | |
| PY2 = sys.version_info[0] == 2 | |
| _internal_attrs = {'_backend', '_parameters', '_buffers', '_backward_hooks', '_forward_hooks', '_forward_pre_hooks', '_modules'} | |
| class Scope(object): | |
| def __init__(self): | |
| self._modules = OrderedDict() |
| # Copyright 2021 Google LLC. | |
| # SPDX-License-Identifier: Apache-2.0 | |
| import kfp | |
| import json | |
| import time | |
| from google.cloud import bigquery | |
| from google.cloud.exceptions import NotFound | |
| from kfp.v2.google.client import AIPlatformClient | |
| client = bigquery.Client() |