Closed Monesh-97 closed 3 years ago
This issue occurs with the files and versions below.
@moneshj
File Location: https://github.com/bknyaz/sgg/blob/master/Visualize_SG_predictions.ipynb
train, val_splits = VG.splits(data_dir=data_dir,
num_val_im=5000,
mrcnn=detector_model == 'mrcnn',
min_graph_size=-1,
max_graph_size=-1,
filter_non_overlap=mode == 'sgdet')
train_loader, val_loaders = VGDataLoader.splits(train, val_splits,
mode='rel',
batch_size=1,
num_workers=0,
num_gpus=1)
val_loader, val_loader_zs, test_loader, test_loader_zs = val_loaders
detector = RelModelStanford(train_data=train,
num_gpus=1,
mode=mode,
use_bias=False,
detector_model=detector_model,
RELS_PER_IMG=1024)
print("Loading EVERYTHING from %s" % checkpoint_path)
ckpt = torch.load(checkpoint_path, map_location='cpu')
success = optimistic_restore(detector, ckpt['state_dict'])
assert success, 'something wrong when loading the detector'
detector.to(device)
detector.eval()
detector.detector.eval()
detector.detector.mode = 'refinerels' if mode == 'sgdet' else 'gtbox'
print('done')
TRAIN DATASET
Loading GQA-train questions...
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
<ipython-input-3-a4a33e4a7f77> in <module>
4 min_graph_size=-1,
5 max_graph_size=-1,
----> 6 filter_non_overlap=mode == 'sgdet')
7
8 train_loader, val_loaders = VGDataLoader.splits(train, val_splits,
~/donggu/sgg/dataloaders/visual_genome.py in splits(cls, *args, **kwargs)
315 """ Helper method to generate splits of the dataset"""
316 print('\nTRAIN DATASET')
--> 317 train = cls('train', *args, **kwargs)
318
319 print('\nVAL DATASET (ALL)')
~/donggu/sgg/dataloaders/visual_genome.py in __init__(self, mode, data_dir, filter_empty_rels, num_im, num_val_im, filter_duplicate_rels, filter_non_overlap, max_graph_size, min_graph_size, mrcnn, device, training_triplets, exclude_left_right)
116 # Use only images having question-answer pairs in the balanced split
117 print('Loading GQA-%s questions...' % mode)
--> 118 with open(os.path.join(data_dir, data_name, '%s_balanced_questions.json' % f_mode), 'rb') as f:
119 Q_dict = json.load(f)
120 self.image_ids = set()
FileNotFoundError: [Errno 2] No such file or directory: '/scratch/ssd/data/GQA/train_balanced_questions.json'
It looks like there were some issues downloading GQA data. I suggest to download it manually using the link from here: https://github.com/bknyaz/sgg/blob/d2a78168cfcec95f27a1e6e8d66e636ed62d9736/lib/download.py#L12 And unpack according to the folder structure I describe in README.md
https://yadi.sk/d/FGOzRP649rZ2kQ
The downloaded file is downloaded as .gz.
Uncompress using the command gzip -d GQA_scenegraphs.gz. Caution! : The downloaded file is "GQA_scenegraphs.gz", but you need to change the file name to "GQA_scenegraphs.tar.gz" using the mv command and unzip it using the tar -zxvf command!
When uncompressed, the following files are shown in the list.
./
./readme.txt
./readme_q.txt
./test_balanced_questions.json
./testdev_balanced_questions.json
./train_balanced_questions.json
./val_balanced_questions.json
./sceneGraphs/
./sceneGraphs/train_sceneGraphs.json
./sceneGraphs/val_sceneGraphs.json
./sceneGraphs/readme_sg.txt
./.submission_all_questions.json.swp
./train_images.json
./val_images.json
Move the file to the correct location using the command below.
mv ./"Downloaded Files dir"/. data_path/GQA/.
data_path/GQA/.
ubuntu@nipa2019-0494:~/donggu/sgg/data_path/GQA$ ll -h
total 1.1G
drwxr-xr-x 3 ubuntu ubuntu 327 Feb 20 22:50 ./
drwxrwxr-x 4 ubuntu ubuntu 27 Feb 16 11:54 ../
-rw-rw-r-- 1 ubuntu ubuntu 165M Feb 20 22:37 GQA_scenegraphs.tar
-rw-r--r-- 1 ubuntu ubuntu 2.2K Mar 26 2019 readme_q.txt
-rw-r--r-- 1 ubuntu ubuntu 920 Feb 1 2019 readme.txt
drwxr-xr-x 2 ubuntu ubuntu 85 Oct 26 2019 sceneGraphs/
-rw-r--r-- 1 ubuntu ubuntu 1.0K Nov 5 2019 .submission_all_questions.json.swp
-rw-r--r-- 1 ubuntu ubuntu 11M Feb 3 2019 test_balanced_questions.json
-rw-r--r-- 1 ubuntu ubuntu 11M Mar 26 2019 testdev_balanced_questions.json
-rw-r--r-- 1 ubuntu ubuntu 776M Feb 3 2019 train_balanced_questions.json
-rw-r--r-- 1 ubuntu ubuntu 764K Mar 30 2020 train_images.json
-rw-r--r-- 1 ubuntu ubuntu 109M Feb 3 2019 val_balanced_questions.json
-rw-r--r-- 1 ubuntu ubuntu 109K Mar 30 2020 val_images.json
I followed your instructions, but I have the same problem. Please tell me if I am doing it wrong.
TRAIN DATASET
Loading GQA-train questions...
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
<ipython-input-3-a4a33e4a7f77> in <module>
4 min_graph_size=-1,
5 max_graph_size=-1,
----> 6 filter_non_overlap=mode == 'sgdet')
7
8 train_loader, val_loaders = VGDataLoader.splits(train, val_splits,
~/donggu/sgg/dataloaders/visual_genome.py in splits(cls, *args, *kwargs) 315 """ Helper method to generate splits of the dataset""" 316 print('\nTRAIN DATASET') --> 317 train = cls('train', args, **kwargs) 318 319 print('\nVAL DATASET (ALL)')
~/donggu/sgg/dataloaders/visual_genome.py in init(self, mode, data_dir, filter_empty_rels, num_im, num_val_im, filter_duplicate_rels, filter_non_overlap, max_graph_size, min_graph_size, mrcnn, device, training_triplets, exclude_left_right) 116 # Use only images having question-answer pairs in the balanced split 117 print('Loading GQA-%s questions...' % mode) --> 118 with open(os.path.join(data_dir, data_name, '%s_balanced_questions.json' % f_mode), 'rb') as f: 119 Q_dict = json.load(f) 120 self.image_ids = set()
FileNotFoundError: [Errno 2] No such file or directory: '/scratch/ssd/data/GQA/train_balanced_questions.json'
8. When I run the source code below, I suddenly get this error. can I ignore this notification when running your source code?
```python
import torch
import numpy as np
import pandas as pd
import time
import pickle
import cv2
import networkx as nx
import matplotlib.pyplot as plt
from collections import defaultdict
from config import BOX_SCALE, IM_SCALE
from dataloaders.visual_genome import VGDataLoader, VG
In /home/ubuntu/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle:
The savefig.frameon rcparam was deprecated in Matplotlib 3.1 and will be removed in 3.3.
In /home/ubuntu/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle:
The verbose.level rcparam was deprecated in Matplotlib 3.1 and will be removed in 3.3.
In /home/ubuntu/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle:
The verbose.fileo rcparam was deprecated in Matplotlib 3.1 and will be removed in 3.3.
/scratch/ssd/data/
Therefore, I modified the source code to an absolute path to fit my path. The source code below is the part. Make sure to correct your path correctly too.
# data_dir = '/scratch/ssd/data/'
# I have confirmed that there are no files in these paths.
# "/scratch/ssd/data/"
# Therefore, I modified the source code to an absolute path to fit my path.
data_dir = '/home/ubuntu/donggu/sgg/data_path/'
VG.split = 'gqa' # set VG, GQA or VTE split here to use as a global variable
checkpoint_path = '/mnt/data/bknyazev/checkpoints/VG/62566/vgrel.pth' # 'gqa_sggen_62566.pth'
mode = 'sgdet'
device = 'cpu'
num_gpus = 1
detector_model = 'mrcnn'
# should be loaded after settings some params
from lib.pytorch_misc import *
from lib.evaluation.sg_eval import BasicSceneGraphEvaluator, calculate_mR_from_evaluator_list, eval_entry
from lib.rel_model_stanford import RelModelStanford
Yes, in the notebook you need to change the path appropriately.
Thank you @bknyaz
Sorry for reopening this, but where can I download the ckpt mentioned in the notebook, @bknyaz and @donggu-kang ?