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 os | |
| import dotenv | |
| import requests | |
| dotenv.load_dotenv() | |
| class PiiBoundingBox(object): | |
| def __init__(self, x1: float, y1: float, x2: float, y2: float, page: int, pii_type: str): |
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
| console.log('redirector!') | |
| window.location = "www.google.com" |
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 numpy as np | |
| def filter_accelerations(df_acceleration, filter_length): | |
| filter_kernel = np.ones(filter_length) / filter_length | |
| z = df_acceleration['z'] | |
| filtered_z = np.convolve(z, | |
| filter_kernel, | |
| 'same') | |
| df_acceleration_filtered = df_acceleration.copy() | |
| df_acceleration_filtered['z'] = filtered_z |
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
| def identify_reps(df_acceleration): | |
| upward_thresh = 12.0 | |
| z_acc = df_acceleration['z'] | |
| # We want to the start and end location of every consecutive sequence of measurement above our threshold | |
| # Note: scipy.signal.find_peaks would accomplish this, but feel magical. So we do out ourselves. | |
| segment_start_locations = [] | |
| segment_end_locations = [] |
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 pylab as plt | |
| # calculate time difference from session start in seconds | |
| df_acceleration['t'] = (df_acceleration['timestamp'] - df_acceleration['timestamp'].min()) / 1000 | |
| # plot the x,y,z acceleration values on the same graph | |
| plt.figure(figsize=(8, 8)) | |
| plt.plot(df_acceleration['t'], df_acceleration['x'], label='x') | |
| plt.plot(df_acceleration['t'], df_acceleration['y'], label='y') | |
| plt.plot(df_acceleration['t'], df_acceleration['z'], label='z') | |
| plt.legend() |
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 os | |
| import pandas as pd | |
| import pylab as plt | |
| from moonsense.client import Client | |
| # get all the sessions we've recorded so far | |
| client = Client(secret_token=os.environ['MOONSENSE_SECRET_TOKEN']) | |
| sessions = client.list_sessions() | |
| session_acceleration_data = [] | |
| # go over every session | |
| for session in sessions: |
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
| curl --location --request POST 'https://www.proproductpix.org/api/clean_manual' \ | |
| --header 'Content-Type: multipart/form-data' \ | |
| --header 'x-api-key: YOUR_API_KEY_HERE' \ | |
| --form 'photo=@/path/to/your/photo' |
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
| a = 5 |
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
| def tf_blend_images(bkg_img, obj_img, object_pixels): | |
| object_shape = tf.shape(obj_img) | |
| cropped_bkg = tf.random_crop(bkg_img, object_shape) | |
| composed_image = (cropped_bkg * tf.cast(tf.logical_not(object_pixels), tf.uint8) + | |
| obj_img * tf.cast(object_pixels, tf.uint8)) | |
| # random saturation etc | |
| return composed_image |
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
| def gen_item(self): | |
| while True: | |
| bkg_image = random.sample(self.all_bkg_images, 1)[0] | |
| png_name = self.get_complete_png(cleaned_image=False) | |
| yield {'png_path': str(png_name), | |
| 'bkg_image': bkg_image, |
NewerOlder