Skip to content
Open
Show file tree
Hide file tree
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
21 changes: 21 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.26100.0",
"compilerPath": "cl.exe",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "windows-msvc-x64"
}
],
"version": 4
}
9 changes: 9 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"python-envs.pythonProjects": [
{
"path": "",
"envManager": "ms-python.python:conda",
"packageManager": "ms-python.python:conda"
}
]
}
300 changes: 300 additions & 0 deletions LQVG_test.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,300 @@
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": [],
"gpuType": "T4"
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
},
"accelerator": "GPU"
},
"cells": [
{
"cell_type": "markdown",
"source": [
"## **The modified source code compatible with colab (gdown does not work for downloading):**"
],
"metadata": {
"id": "kTnynktRAMnJ"
}
},
{
"cell_type": "code",
"source": [
"from google.colab import drive\n",
"drive.mount('/content/drive')"
],
"metadata": {
"id": "WixriWROqUUx"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"## **LQVG weights trained on DIOR-RSVG and RSVG-HR**"
],
"metadata": {
"id": "JVkx_5-QFK4o"
}
},
{
"cell_type": "code",
"source": [
"!gdown --folder https://drive.google.com/drive/folders/1uC9TAPOwiIbHcee6hSO_3b2Mwr-zDGtg?usp=drive_link -O drive/MyDrive/weights"
],
"metadata": {
"id": "dlUmSOwieC9o"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"cd /content/drive/.shortcut-targets-by-id/18OjYDfO70rO2e-oLMPmNbu2Z1WH7nppd/LQVG\n"
],
"metadata": {
"id": "KddNyUyDwvP6"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"!pip install torch torchvision torchaudio\n"
],
"metadata": {
"id": "gmmmP7yqvVf7"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"!pip install -r requirements.txt\n"
],
"metadata": {
"id": "NVWRfbjfwUYx"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"!pip install 'git+https://github.com/facebookresearch/fvcore'\n"
],
"metadata": {
"id": "3MbdnvA9sKI_"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"!pip install -U 'git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI'\n"
],
"metadata": {
"id": "nvEpgsttsY3L"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"cd /content/drive/.shortcut-targets-by-id/18OjYDfO70rO2e-oLMPmNbu2Z1WH7nppd/LQVG/models/ops"
],
"metadata": {
"id": "tUCBNrYGshhy"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"!python setup.py build install"
],
"metadata": {
"id": "ENyTettCskxg"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"cd ../.."
],
"metadata": {
"id": "bU-A2IBKsmo5"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"## Inference:"
],
"metadata": {
"id": "7g2sVjoVFQiJ"
}
},
{
"cell_type": "code",
"source": [
"!python3 inference_rsvg.py --dataset_file rsvg_mm --num_queries 10 --with_box_refine --binary --freeze_text_encoder \\\n",
"--resume /content/drive/MyDrive/weights/RSVG-HR/checkpoint.pth --backbone resnet50"
],
"metadata": {
"id": "x3dfhLHB9nET"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"## **Visualize some results:**"
],
"metadata": {
"id": "TQpWSEAMIQwF"
}
},
{
"cell_type": "code",
"source": [
"import os\n",
"from pathlib import Path\n",
"import math\n",
"from PIL import Image\n",
"import matplotlib.pyplot as plt\n",
"\n",
"# --- Config ---\n",
"IDS = [120, 159, 316, 328, 377, 502, 507, 510]\n",
"folder = \"/content/drive/MyDrive/LQVG/test_output/test\" # Input folder\n",
"save_path = \"/content/drive/MyDrive/grid/grid.png\" # Output file\n",
"cols = 4 # Grid columns\n",
"\n",
"# --- Ensure save directory exists ---\n",
"os.makedirs(os.path.dirname(save_path), exist_ok=True)\n",
"\n",
"# --- Functions ---\n",
"def load_images(root, ids):\n",
" \"\"\"Load images by IDs from a folder.\"\"\"\n",
" imgs = []\n",
" for i in ids:\n",
" name = f\"UASs_{i}.jpg\"\n",
" path = Path(root) / name\n",
" if not path.is_file():\n",
" print(f\"❌ Missing: {path}\")\n",
" continue\n",
" imgs.append(Image.open(path).convert(\"RGB\"))\n",
" print(f\"✅ Loaded: {path}\")\n",
" return imgs\n",
"\n",
"def show_grid(images, cols=4, save=None):\n",
" \"\"\"Display images in a grid and optionally save.\"\"\"\n",
" if not images:\n",
" print(\"⚠ No images to display.\")\n",
" return\n",
"\n",
" rows = math.ceil(len(images) / cols)\n",
"\n",
" # Scale figure size based on image dimensions\n",
" img_width, img_height = images[0].size\n",
" fig_width = cols * img_width / 100\n",
" fig_height = rows * img_height / 100\n",
"\n",
" plt.figure(figsize=(fig_width, fig_height))\n",
" for idx, img in enumerate(images, 1):\n",
" ax = plt.subplot(rows, cols, idx)\n",
" ax.imshow(img)\n",
" ax.axis(\"off\")\n",
"\n",
" if save:\n",
" plt.savefig(save, dpi=150, bbox_inches='tight', pad_inches=0)\n",
" print(f\"💾 Saved grid to: {save}\")\n",
"\n",
" plt.show()\n",
"\n",
"# --- Main ---\n",
"imgs = load_images(folder, IDS)\n",
"show_grid(imgs, cols=cols, save=save_path)\n"
],
"metadata": {
"id": "jprFeczaICMm"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"## Training:"
],
"metadata": {
"id": "bcyW0BLPFWCE"
}
},
{
"cell_type": "code",
"source": [
"!wget -O datasets/coco_eval.py https://raw.githubusercontent.com/facebookresearch/detr/main/datasets/coco_eval.py"
],
"metadata": {
"id": "Ug4WCa_WW42F"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"!python main.py \\\n",
" --dataset_file rsvg_mm \\\n",
" --rsvg_mm_path \"/content/drive/MyDrive/data\" \\\n",
" --binary \\\n",
" --with_box_refine \\\n",
" --batch_size 1 \\\n",
" --num_frames 1 \\\n",
" --epochs 70 \\\n",
" --lr_drop 40 \\\n",
" --num_queries 10 \\\n",
" --output_dir \"/content/drive/MyDrive/rsvg_dirs/r50_bidrection_fusion_10query_70epo_multiscale\" \\\n",
" --backbone resnet50 \\\n",
" --device cuda"
],
"metadata": {
"id": "dcooaiTTVGF4"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"jupyter nbconvert --to pdf LQVG-test.ipynb\n"
],
"metadata": {
"id": "XQfZsqqFWAVd"
},
"execution_count": null,
"outputs": []
}
]
}
28 changes: 28 additions & 0 deletions RSVG-HR/Annotations/rsvg_hr_test_10.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
UASs_120.jpg,2671.0,1921.0,2814.0,2104.0,Compact square-like cluster with roughly symmetrical slightly irregular outline, weed: erigeron canadensis, middle-center of lentil crop field
UASs_121.jpg,2195.0,2413.0,2568.0,2784.0,Moderately sized square-like cluster with irregular sprawling outline, weed: bassia scoparia, bottom-center of lentil crop field
UASs_123.jpg,1656.0,683.0,2047.0,1052.0,Moderately sized square-like cluster with irregular sprawling outline, weed: bassia scoparia, top-left of lentil crop field
UASs_124.jpg,2269.0,1248.0,2616.0,1695.0,Medium-sized square-like cluster with broadly irregular potentially sprawling outline, weed: ambrosia artemisiifolia, middle-center of lentil crop field
UASs_137.jpg,663.0,3508.0,985.0,3643.0,Medium-sized square-like cluster with broadly irregular potentially sprawling outline, weed: ambrosia artemisiifolia, bottom-left of lentil crop field
UASs_157.jpg,2665.0,13.0,2985.0,481.0,Medium-sized square-like cluster with broadly irregular potentially sprawling outline, weed: ambrosia artemisiifolia, top-center of lentil crop field
UASs_159.jpg,2442.0,3.0,2545.0,132.0,Moderately sized square-like cluster with irregular sprawling outline, weed: bassia scoparia, top-center of lentil crop field
UASs_180.jpg,498.0,3132.0,877.0,3366.0,Medium-sized square-like cluster with irregular somewhat elongated outline, weed: amaranthus tuberculatus, bottom-left of lentil crop field
UASs_181.jpg,153.0,3197.0,413.0,3479.0,Moderately sized square-like cluster with irregular sprawling outline, weed: bassia scoparia, bottom-left of lentil crop field
UASs_224.jpg,4683.0,528.0,4937.0,856.0,Medium-sized square-like cluster with broadly irregular potentially sprawling outline, weed: ambrosia artemisiifolia, top-right of lentil crop field
UASs_236.jpg,1347.0,2371.0,1571.0,2615.0,Moderately sized square-like cluster with irregular sprawling outline, weed: bassia scoparia, bottom-left of lentil crop field
UASs_237.jpg,396.0,2163.0,755.0,2512.0,Medium-sized square-like cluster with irregular somewhat elongated outline, weed: amaranthus tuberculatus, middle-left of lentil crop field
UASs_288.jpg,576.0,2168.0,669.0,2284.0,Compact square-like cluster with roughly symmetrical slightly irregular outline, weed: erigeron canadensis, middle-left of lentil crop field
UASs_316.jpg,539.0,3.0,740.0,279.0,Moderately sized square-like cluster with irregular sprawling outline, weed: bassia scoparia, top-left of lentil crop field
UASs_328.jpg,1772.0,3136.0,2140.0,3537.0,Medium-sized square-like cluster with broadly irregular potentially sprawling outline, weed: ambrosia artemisiifolia, bottom-left of lentil crop field
UASs_377.jpg,1438.0,1725.0,1641.0,1936.0,Medium-sized square-like cluster with irregular somewhat elongated outline, weed: amaranthus tuberculatus, middle-left of lentil crop field
UASs_496.jpg,17.0,64.0,223.0,282.0,Moderately sized square-like cluster with irregular sprawling outline, weed: bassia scoparia, top-left of lentil crop field
UASs_502.jpg,2349.0,1193.0,2516.0,1384.0,Compact square-like cluster with roughly symmetrical slightly irregular outline, weed: erigeron canadensis, middle-center of lentil crop field
UASs_503.jpg,2767.0,524.0,3121.0,916.0,Medium-sized square-like cluster with broadly irregular potentially sprawling outline, weed: ambrosia artemisiifolia, top-center of lentil crop field
UASs_504.jpg,2858.0,728.0,3325.0,1225.0,Medium-sized square-like cluster with irregular somewhat elongated outline, weed: amaranthus tuberculatus, top-center of lentil crop field
UASs_505.jpg,2813.0,1574.0,3069.0,1894.0,Medium-sized square-like cluster with irregular somewhat elongated outline, weed: amaranthus tuberculatus, middle-center of lentil crop field
UASs_506.jpg,1917.0,9.0,2100.0,162.0,Moderately sized square-like cluster with irregular sprawling outline, weed: bassia scoparia, top-center of lentil crop field
UASs_507.jpg,2219.0,360.0,2389.0,570.0,Medium-sized square-like cluster with irregular somewhat elongated outline, weed: amaranthus tuberculatus, top-center of lentil crop field
UASs_509.jpg,2428.0,7.0,2790.0,320.0,Moderately sized square-like cluster with irregular sprawling outline, weed: bassia scoparia, top-center of lentil crop field
UASs_510.jpg,2221.0,1071.0,2372.0,1229.0,Compact square-like cluster with roughly symmetrical slightly irregular outline, weed: erigeron canadensis, top-center of lentil crop field
UASs_660.jpg,1679.0,668.0,2066.0,1052.0,Moderately sized square-like cluster with irregular sprawling outline, weed: bassia scoparia, top-left of lentil crop field
UASs_661.jpg,1927.0,2768.0,2368.0,3189.0,Medium-sized square-like cluster with irregular somewhat elongated outline, weed: amaranthus tuberculatus, bottom-center of lentil crop field
UASs_93.jpg,166.0,2184.0,417.0,2396.0,Medium-sized square-like cluster with broadly irregular potentially sprawling outline, weed: ambrosia artemisiifolia, middle-left of lentil crop field
Loading