ranjaykrishna / visual_genome_python_driver

A python wrapper for the Visual Genome API
MIT License
354 stars 90 forks source link

`GetSceneGraphOfImage` function call hangs #8

Closed ebigelow closed 7 years ago

ebigelow commented 8 years ago

I have been unable to use the GetSceneGraphOfImage function in the API recently. When I used it about a month ago, it would be extremely slow - from 1 to 10 minutes to load a single scene graph. As of last night, I have been unable to acquire any scene graphs. Once I call the function, it seems to hang infinitely (for at least 10-12 hours).

If I interrupt the process while it's hanging, I get the following trace:

---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
<ipython-input-8-2265c0abc8cf> in <module>()
----> 1 scene_graph = vg.GetSceneGraphOfImage(id=image_id)

/Users/eric/code/visual_genome_python_driver/src/api.pyc in GetSceneGraphOfImage(id)
     71 def GetSceneGraphOfImage(id=61512):
     72   image = GetImageData(id=id)
---> 73   data = utils.RetrieveData('/api/v0/images/' + str(id) + '/graph')
     74   if 'detail' in data and data['detail'] == 'Not found.':
     75     return None

/Users/eric/code/visual_genome_python_driver/src/utils.pyc in RetrieveData(request)
     18   connection = httplib.HTTPSConnection("visualgenome.org", '443')
     19   connection.request("GET", request)
---> 20   response = connection.getresponse()
     21   jsonString = response.read()
     22   data = json.loads(jsonString)

/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.pyc in getresponse(self, buffering)
   1134 
   1135         try:
-> 1136             response.begin()
   1137             assert response.will_close != _UNKNOWN
   1138             self.__state = _CS_IDLE

/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.pyc in begin(self)
    451         # read until we get a non-100 response
    452         while True:
--> 453             version, status, reason = self._read_status()
    454             if status != CONTINUE:
    455                 break

/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.pyc in _read_status(self)
    407     def _read_status(self):
    408         # Initialize with Simple-Response defaults
--> 409         line = self.fp.readline(_MAXLINE + 1)
    410         if len(line) > _MAXLINE:
    411             raise LineTooLong("header line")

/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.pyc in readline(self, size)
    478             while True:
    479                 try:
--> 480                     data = self._sock.recv(self._rbufsize)
    481                 except error, e:
    482                     if e.args[0] == EINTR:

/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.pyc in recv(self, buflen, flags)
    732                     "non-zero flags not allowed in calls to recv() on %s" %
    733                     self.__class__)
--> 734             return self.read(buflen)
    735         else:
    736             return self._sock.recv(buflen, flags)

/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.pyc in read(self, len, buffer)
    619                 v = self._sslobj.read(len, buffer)
    620             else:
--> 621                 v = self._sslobj.read(len or 1024)
    622             return v
    623         except SSLError as x:

KeyboardInterrupt: 
PaulGwamanda commented 7 years ago

See related issue below https://github.com/ranjaykrishna/visual_genome_python_driver/commit/578f9456e28519169a7dd2998042e9b601565678

wang-tf commented 7 years ago

I solved this problem by using:

import ssl
ssl._create_default_https_context = ssl._create_unverified_context
ebigelow commented 7 years ago

@wang-tf Ah, this works for me. It took some extra time the first call I made to the API, but since that first call went through, I've been able to download other scene graphs fairly quickly.