Skip to content

Commit

Permalink
ipynb change
Browse files Browse the repository at this point in the history
  • Loading branch information
gunho1123 committed Nov 2, 2023
1 parent 131843e commit 0382b99
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 22 deletions.
8 changes: 4 additions & 4 deletions official/projects/rngdet/configs/rngdet.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from official.vision.configs import common
from official.vision.configs import decoders
from official.vision.configs import backbones
from official.projects.rngdet import optimization as optimization_detr
#from official.projects.rngdet import optimization as optimization_detr


@dataclasses.dataclass
Expand Down Expand Up @@ -200,10 +200,10 @@ def rngdet_cityscale() -> cfg.ExperimentConfig:
max_to_keep=1,
best_checkpoint_export_subdir='best_ckpt',
best_checkpoint_eval_metric='AP',
optimizer_config=optimization_detr.OptimizationConfig({
optimizer_config=optimization.OptimizationConfig({
'optimizer': {
'type': 'detr_adamw',
'detr_adamw': {
'type': 'adamw',
'adamw': {
'weight_decay_rate': 1e-5,
'epsilon': 1e-08,
'global_clipnorm': 0.1,
Expand Down
83 changes: 65 additions & 18 deletions official/projects/rngdet/rngdet.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {
"cellView": "form",
"id": "tuOe1ymfHZPu"
Expand Down Expand Up @@ -53,35 +53,54 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"os.environ[\"CUDA_DEVICE_ORDER\"]=\"PCI_BUS_ID\"\n",
"os.environ[\"CUDA_VISIBLE_DEVICES\"]=\"1\"\n",
"os.environ[\"CUDA_VISIBLE_DEVICES\"]=\"0\"\n",
"\n",
"#import sys\n",
"#sys.path.append(\"/mnt/hdd-nfs-intern/ghpark/03_temp/models\")"
"import sys\n",
"sys.path.append(\"/mnt/hdd-nfs-intern/ghpark/03_temp/models\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"2023-11-02 06:12:04.508509: I tensorflow/core/platform/cpu_feature_guard.cc:183] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.\n",
"To enable the following instructions: SSE3 SSE4.1 SSE4.2 AVX, in other operations, rebuild TensorFlow with the appropriate compiler flags.\n"
]
}
],
"source": [
"import tensorflow as tf\n",
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"metadata": {
"id": "NHT1iiIiBzlC"
},
"outputs": [],
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/nsml/.local/lib/python3.10/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
" from .autonotebook import tqdm as notebook_tqdm\n",
"2023-11-02 06:12:08.643397: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1636] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 31136 MB memory: -> device: 0, name: Tesla V100-SXM2-32GB, pci bus id: 0000:3e:00.0, compute capability: 7.0\n"
]
}
],
"source": [
"from official.projects.rngdet.tasks import rngdet\n",
"from official.core import exp_factory\n",
Expand All @@ -93,11 +112,23 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n",
"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n",
"LOAD CHECKPOINT DONE\n",
"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n",
"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n"
]
}
],
"source": [
"ckpt_dir_or_file = '/mnt/hdd-nfs-intern/ghpark/03_temp/ckpt/test_10'\n",
"ckpt_dir_or_file = '/mnt/hdd-nfs-intern/ghpark/03_temp/ckpt/test_03_coslr'\n",
"ckpt = tf.train.Checkpoint(\n",
" backbone=model.backbone,\n",
" backbone_history=model.backbone_history,\n",
Expand All @@ -121,9 +152,24 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"2023-11-02 06:12:19.383224: I tensorflow/compiler/xla/stream_executor/cuda/cuda_dnn.cc:432] Loaded cuDNN version 8904\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"56 initial candidates extracted from the segmentation map...\n"
]
}
],
"source": [
"from PIL import Image\n",
"from official.projects.rngdet.eval import agent\n",
Expand All @@ -144,24 +190,25 @@
"logit_threshold = 0.75\n",
"roi_size = 128\n",
"\n",
"print(f'STEP 2: Interative graph detection...')\n",
"while 1:\n",
" agent.step_counter += 1\n",
" # crop ROI\n",
" sat_ROI, historical_ROI = agent.crop_ROI(agent.current_coord)\n",
" \n",
" sat_ROI = tf.expand_dims(sat_ROI, 0) / 255.0\n",
" # (gunho) historical_ROI / 255.0 in original code\n",
" historical_ROI = tf.expand_dims(historical_ROI, 0) / 255.0\n",
" historical_ROI = tf.expand_dims(historical_ROI, -1)\n",
" historical_ROI = tf.cast(historical_ROI, tf.float32)\n",
" print(tf.reduce_max(sat_ROI))\n",
" print(tf.reduce_max(historical_ROI))\n",
" # predict vertices in the next step\n",
" outputs, pred_segment, pred_keypoint = model(sat_ROI, historical_ROI, training=False)\n",
" # agent moves\n",
" # alignment vertices\n",
" outputs = outputs[-1]\n",
" pred_coords = outputs['box_outputs']\n",
" pred_probs = outputs['cls_outputs']\n",
" alignment_vertices = [[v[0]-agent.current_coord[0]+agent.crop_size//2,\n",
" v[1]-agent.current_coord[1]+agent.crop_size//2] for v in agent.historical_vertices]\n",
" pred_coords_ROI = agent.step(pred_probs,pred_coords,thr=logit_threshold)\n",
" \n",
" if agent.finish_current_image:\n",
Expand Down Expand Up @@ -220,7 +267,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.13"
"version": "3.10.12"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 0382b99

Please sign in to comment.