Skip to content

Commit e70cced

Browse files
committed
update RF-DETR fine-tuning notebook
1 parent 3a16de2 commit e70cced

File tree

1 file changed

+76
-76
lines changed

1 file changed

+76
-76
lines changed

notebooks/how-to-finetune-rf-detr-on-detection-dataset.ipynb

Lines changed: 76 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,10 +1088,10 @@
10881088
{
10891089
"cell_type": "markdown",
10901090
"source": [
1091-
"## Run Inference with Fine-tuned RF-DETR Model"
1091+
"## Evaluate Fine-tuned RF-DETR Model"
10921092
],
10931093
"metadata": {
1094-
"id": "xT1tPwZS_-6t"
1094+
"id": "X_9c113E39QP"
10951095
}
10961096
},
10971097
{
@@ -1213,6 +1213,80 @@
12131213
"execution_count": null,
12141214
"outputs": []
12151215
},
1216+
{
1217+
"cell_type": "code",
1218+
"source": [
1219+
"import supervision as sv\n",
1220+
"from tqdm import tqdm\n",
1221+
"from supervision.metrics import MeanAveragePrecision\n",
1222+
"\n",
1223+
"targets = []\n",
1224+
"predictions = []\n",
1225+
"\n",
1226+
"for path, image, annotations in tqdm(ds):\n",
1227+
" image = Image.open(path)\n",
1228+
" detections = model.predict(image, threshold=0)\n",
1229+
"\n",
1230+
" targets.append(annotations)\n",
1231+
" predictions.append(detections)"
1232+
],
1233+
"metadata": {
1234+
"colab": {
1235+
"base_uri": "https://localhost:8080/"
1236+
},
1237+
"id": "szxs3PZsBVxa",
1238+
"outputId": "59c4660d-8e15-41a3-c842-a5b98bb022ea"
1239+
},
1240+
"execution_count": null,
1241+
"outputs": [
1242+
{
1243+
"output_type": "stream",
1244+
"name": "stderr",
1245+
"text": [
1246+
"100%|██████████| 169/169 [00:03<00:00, 44.91it/s]\n"
1247+
]
1248+
}
1249+
]
1250+
},
1251+
{
1252+
"cell_type": "code",
1253+
"source": [
1254+
"map_metric = MeanAveragePrecision()\n",
1255+
"map_result = map_metric.update(predictions, targets).compute()\n",
1256+
"print(map_result)"
1257+
],
1258+
"metadata": {
1259+
"colab": {
1260+
"base_uri": "https://localhost:8080/"
1261+
},
1262+
"id": "fxqvXOQcsRF2",
1263+
"outputId": "df467d54-e4ad-4b40-b65f-46bb6cfc5ca7"
1264+
},
1265+
"execution_count": null,
1266+
"outputs": [
1267+
{
1268+
"output_type": "stream",
1269+
"name": "stdout",
1270+
"text": [
1271+
"Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.568\n",
1272+
"Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.908\n",
1273+
"Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.580\n",
1274+
"Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.321\n",
1275+
"Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.758\n",
1276+
"Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.809\n"
1277+
]
1278+
}
1279+
]
1280+
},
1281+
{
1282+
"cell_type": "markdown",
1283+
"source": [
1284+
"## Run Inference with Fine-tuned RF-DETR Model"
1285+
],
1286+
"metadata": {
1287+
"id": "xT1tPwZS_-6t"
1288+
}
1289+
},
12161290
{
12171291
"cell_type": "code",
12181292
"source": [
@@ -1345,80 +1419,6 @@
13451419
}
13461420
]
13471421
},
1348-
{
1349-
"cell_type": "markdown",
1350-
"source": [
1351-
"## Evaluate Fine-tuned RF-DETR Model"
1352-
],
1353-
"metadata": {
1354-
"id": "X_9c113E39QP"
1355-
}
1356-
},
1357-
{
1358-
"cell_type": "code",
1359-
"source": [
1360-
"import supervision as sv\n",
1361-
"from tqdm import tqdm\n",
1362-
"from supervision.metrics import MeanAveragePrecision\n",
1363-
"\n",
1364-
"targets = []\n",
1365-
"predictions = []\n",
1366-
"\n",
1367-
"for path, image, annotations in tqdm(ds):\n",
1368-
" image = Image.open(path)\n",
1369-
" detections = model.predict(image, threshold=0)\n",
1370-
"\n",
1371-
" targets.append(annotations)\n",
1372-
" predictions.append(detections)"
1373-
],
1374-
"metadata": {
1375-
"colab": {
1376-
"base_uri": "https://localhost:8080/"
1377-
},
1378-
"id": "szxs3PZsBVxa",
1379-
"outputId": "59c4660d-8e15-41a3-c842-a5b98bb022ea"
1380-
},
1381-
"execution_count": null,
1382-
"outputs": [
1383-
{
1384-
"output_type": "stream",
1385-
"name": "stderr",
1386-
"text": [
1387-
"100%|██████████| 169/169 [00:03<00:00, 44.91it/s]\n"
1388-
]
1389-
}
1390-
]
1391-
},
1392-
{
1393-
"cell_type": "code",
1394-
"source": [
1395-
"map_metric = MeanAveragePrecision()\n",
1396-
"map_result = map_metric.update(predictions, targets).compute()\n",
1397-
"print(map_result)"
1398-
],
1399-
"metadata": {
1400-
"colab": {
1401-
"base_uri": "https://localhost:8080/"
1402-
},
1403-
"id": "fxqvXOQcsRF2",
1404-
"outputId": "df467d54-e4ad-4b40-b65f-46bb6cfc5ca7"
1405-
},
1406-
"execution_count": null,
1407-
"outputs": [
1408-
{
1409-
"output_type": "stream",
1410-
"name": "stdout",
1411-
"text": [
1412-
"Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.568\n",
1413-
"Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.908\n",
1414-
"Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.580\n",
1415-
"Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.321\n",
1416-
"Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.758\n",
1417-
"Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.809\n"
1418-
]
1419-
}
1420-
]
1421-
},
14221422
{
14231423
"cell_type": "markdown",
14241424
"source": [

0 commit comments

Comments
 (0)