Skip to content

Commit

Permalink
No public description
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 680700455
  • Loading branch information
Google Health authored and sebbaur committed Oct 1, 2024
1 parent 0f46157 commit 6f68e04
Showing 1 changed file with 7 additions and 25 deletions.
32 changes: 7 additions & 25 deletions health_acoustic_representations/hear_demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -351,47 +351,29 @@
" print(f\"Attempt {retries} failed. Retrying in {delay} seconds...\")\n",
" time.sleep(delay)\n",
"\n",
" raise Exception(\"Unexpected error in make_prediction_with_exponential_backoff\")\n",
"\n",
"\n",
"# 1000 batches of 4 clips. This is the format expected for the raw audio endpoint\n",
"# (202). For the GCS URI endpoint, you would need to format this appropriately.\n",
"instances = np.random.uniform((1000, 4, 32000)) # update with your data\n",
"\n",
"with concurrent.futures.ThreadPoolExecutor(max_workers=50) as executor:\n",
" futures = [executor.submit(make_prediction_with_exponential_backoff, client, endpoint, instance) for instance in instances]\n",
"\n",
" for future in concurrent.futures.as_completed(futures):\n",
" try:\n",
" responses.append(future.result())\n",
" except Exception as e:\n",
" print(\"An error occurred:\", e)"
" raise Exception(\"Unexpected error in make_prediction_with_exponential_backoff\")\n"
],
"outputs": [],
"execution_count": null
},
{
"metadata": {
"id": "zGWp-xf8ny0G"
"id": "Vx3gaUe0cb_h"
},
"cell_type": "code",
"source": [
"import time\n",
"import concurrent.futures\n",
"\n",
"start_time = time.time()\n",
"responses = []\n",
"# 1000 batches of 4 clips. This is the format expected for the raw audio endpoint\n",
"# (202). For the GCS URI endpoint, you would need to format this appropriately.\n",
"instances = np.random.uniform((1000, 4, 32000)) # update with your data\n",
"\n",
"with concurrent.futures.ThreadPoolExecutor(max_workers=50) as executor:\n",
" futures = [executor.submit(make_prediction, client, endpoint, instance) for instance in instances]\n",
" futures = [executor.submit(make_prediction_with_exponential_backoff, client, endpoint, instance) for instance in instances]\n",
"\n",
" for future in concurrent.futures.as_completed(futures):\n",
" try:\n",
" responses.append(future.result())\n",
" except Exception as e:\n",
" print(\"An error occurred:\", e)\n",
"\n",
"print(time.time() - start_time)"
" print(\"An error occurred:\", e)"
],
"outputs": [],
"execution_count": null
Expand Down

0 comments on commit 6f68e04

Please sign in to comment.