Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,43 @@
"source": [
"# Intro\n",
"\n",
"This notebook aims at downloading sequences infos(images and bboxes) from a Distant/Real Pyronear Alert API isntance in order to recreate alerts/sequences with ease in local dev environnement\n",
"This notebook aims at downloading sequences data(images and bboxes) from a Distant/Real Pyronear Alert API isntance in order to recreate alerts/sequences with ease in local dev environnement\n",
"\n",
"You need to have accesses to a distant api and provide ```DISTANT_API_URL```, ```DISTANT_ALERT_API_LOGIN```, ```DISTANT_ALERT_API_PASSWORD```\n",
"\n",
"And obvisouly, fill ```SEQUENCE_ID_LIST``` with the sequence id you want in order to download related data\n",
"Then, \n",
"- either fill ```SEQUENCE_ID_LIST``` with the sequence ids you want in order to download related data (pick api admin credentialsi if you intend to download alert from various organisation)\n",
"- or let ```SEQUENCE_ID_LIST``` empty, pick a day to download by filling ```DAY_TO_DOWNLOAD``` (in this case, yyou need credentials from the organisation you want to download seq data)\n",
"\n",
"Also, you can fill ```TRIANGULATED_SEQUENCE_LIST``` with sequences id that triangulates\n",
"\n",
"\n",
"If you do not have anything from above, do not worry, you can use the notebook \"send_real_alerts\" to send some alerts to local env dev"
]
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "649157c6-0ce3-4324-a7b6-15c911ddaf36",
"metadata": {},
"outputs": [],
"source": [
"SEQUENCE_ID_LIST = [15462, 15463, 15561, 15526, 13880, 13572, 13537, 12997, 12562, 15376, 15526]\n",
"BASE_DIRECTORY = \"../data/alert_samples\" # directory where to put sequences data"
"BASE_DIRECTORY = \"../data/alert_samples\" # directory where to put sequences data\n",
"DAY_TO_DOWNLOAD = \"2025-08-26\" #YYYY-MM-DD\n",
"SEQUENCE_ID_LIST = [] #fullfill this with alerts id"
]
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "4e511d97-245c-45cc-9216-a16d31b663aa",
"metadata": {},
"outputs": [],
"source": [
"import requests\n",
"from dotenv import load_dotenv\n",
"import os\n",
"\n",
"import pandas as pd\n",
"from pyroclient import Client\n",
"\n",
"load_dotenv(\"../.env\")\n",
Expand All @@ -49,7 +54,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"id": "ac07ba29-68d0-42d2-bafe-e94d961ec6c2",
"metadata": {},
"outputs": [],
Expand All @@ -72,8 +77,32 @@
},
{
"cell_type": "code",
"execution_count": 4,
"id": "07192f5f-9a69-41a4-9a97-1f1fcefaaf5b",
"execution_count": null,
"id": "512ce6f1-76db-43b6-adb3-131942e8a95e",
"metadata": {},
"outputs": [],
"source": [
"response = api_client.fetch_sequences_from_date(DAY_TO_DOWNLOAD, limit=50)\n",
"api_sequences = pd.DataFrame(response.json())\n",
"api_sequences.head()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1fa5e0df-a090-4f96-ae9a-cd54f365d2c2",
"metadata": {},
"outputs": [],
"source": [
"# you can also reproduce all alerts from this day\n",
"if len(SEQUENCE_ID_LIST)==0:\n",
" SEQUENCE_ID_LIST = list(api_sequences[\"id\"])"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d3c12b1d-54f1-4d8d-b591-dc04ecc35db2",
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -133,29 +162,10 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"id": "b2d033e9-7ce2-4cf4-995e-01ea2c15e235",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"== Download Alerts data for sequence ID 15462 - camera serre-de-barre-01 at 2025-09-29_13-56-58\n",
"== Download Alerts data for sequence ID 15463 - camera brison-03 at 2025-09-29_13-58-36\n",
"== Download Alerts data for sequence ID 15561 - camera pouncho-agast-01 at 2025-10-01_06-18-57\n",
"== Download Alerts data for sequence ID 15526 - camera pouncho-agast-01 at 2025-09-30_15-29-49\n",
"== Download Alerts data for sequence ID 13880 - camera fontaneilles-01 at 2025-09-04_07-34-32\n",
"== Download Alerts data for sequence ID 13572 - camera pouncho-agast-01 at 2025-08-29_06-59-39\n",
"== Download Alerts data for sequence ID 13537 - camera pouncho-agast-01 at 2025-08-28_15-31-17\n",
"== Download Alerts data for sequence ID 12997 - camera pouncho-agast-01 at 2025-08-17_15-52-27\n",
"== Download Alerts data for sequence ID 12562 - camera pouncho-agast-01 at 2025-08-06_12-32-09\n",
"== Download Alerts data for sequence ID 15376 - camera pouncho-agast-02 at 2025-09-28_10-52-39\n",
"== Download Alerts data for sequence ID 15526 - camera pouncho-agast-01 at 2025-09-30_15-29-49\n",
"Download complete\n"
]
}
],
"outputs": [],
"source": [
"single_alerts = os.path.join(BASE_DIRECTORY, \"single_sequences\")\n",
"os.makedirs(single_alerts, exist_ok=True)\n",
Expand All @@ -173,23 +183,10 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"id": "68a2cff8-f847-4e6c-8c74-37b7ecffc9af",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"== Download Alerts data for sequence ID 10535 - camera moret-sur-loing-01 at 2025-07-14_11-22-05\n",
"== Download Alerts data for sequence ID 10537 - camera nemours-02 at 2025-07-14_11-24-10\n",
"== Download Alerts data for sequence ID 10538 - camera croix-augas-02 at 2025-07-14_11-24-31\n",
"== Download Alerts data for sequence ID 15462 - camera serre-de-barre-01 at 2025-09-29_13-56-58\n",
"== Download Alerts data for sequence ID 15463 - camera brison-03 at 2025-09-29_13-58-36\n",
"Download complete\n"
]
}
],
"outputs": [],
"source": [
"\n",
"TRIANGULATED_SEQUENCE_LIST = [10535, 10537, 10538, 15462, 15463]\n",
Expand All @@ -199,14 +196,6 @@
"\n",
"dl_seqs_in_target_dir(TRIANGULATED_SEQUENCE_LIST, triangulated_dir, api_client)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ffd56f84-ec77-4843-837a-06de85232c94",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down