Facing some issue in using this as an api

#1
by codebat - opened
client = Client("https://lykeven-cogvlm.hf.space/")
result = client.predict(
    "Where is GET STARTED button",
    0.8,
    0.4,
    "https://storage.googleapis.com/publiccontent/Screenshot%202023-11-12%20at%2012.40.04%20AM.png",
    "null",
    "null",
    True,
    fn_index=1
)

Gave following:

Loaded as API: https://lykeven-cogvlm.hf.space/ โœ”

---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
Cell In[4], line 2
      1 client = Client("https://lykeven-cogvlm.hf.space/")
----> 2 result = client.predict(
      3     "Where is GET STARTED button",
      4     0.8,
      5     0.4,
      6     "https://storage.googleapis.com/publiccontent/Screenshot%202023-11-12%20at%2012.40.04%20AM.png",
      7     "null",
      8     "null",
      9     True,
     10     fn_index=1
     11 )

File ~/anaconda3/envs/browsertesting/lib/python3.10/site-packages/gradio_client/client.py:305, in Client.predict(self, api_name, fn_index, *args)
    301 if self.endpoints[inferred_fn_index].is_continuous:
    302     raise ValueError(
    303         "Cannot call predict on this function as it may run forever. Use submit instead."
    304     )
--> 305 return self.submit(*args, api_name=api_name, fn_index=fn_index).result()

File ~/anaconda3/envs/browsertesting/lib/python3.10/site-packages/gradio_client/client.py:1456, in Job.result(self, timeout)
   1441 def result(self, timeout: float | None = None) -> Any:
   1442     """
   1443     Return the result of the call that the future represents. Raises CancelledError: If the future was cancelled, TimeoutError: If the future didn't finish executing before the given timeout, and Exception: If the call raised then that exception will be raised.
   1444 
   (...)
   1454         >> 9
   1455     """
-> 1456     return super().result(timeout=timeout)

File ~/anaconda3/envs/browsertesting/lib/python3.10/concurrent/futures/_base.py:445, in Future.result(self, timeout)
    443     raise CancelledError()
    444 elif self._state == FINISHED:
--> 445     return self.__get_result()
    446 else:
    447     raise TimeoutError()

File ~/anaconda3/envs/browsertesting/lib/python3.10/concurrent/futures/_base.py:390, in Future.__get_result(self)
    388 if self._exception:
    389     try:
--> 390         raise self._exception
    391     finally:
    392         # Break a reference cycle with the exception in self._exception
    393         self = None

File ~/anaconda3/envs/browsertesting/lib/python3.10/concurrent/futures/thread.py:52, in _WorkItem.run(self)
     49     return
     51 try:
---> 52     result = self.fn(*self.args, **self.kwargs)
     53 except BaseException as exc:
     54     self.future.set_exception(exc)

File ~/anaconda3/envs/browsertesting/lib/python3.10/site-packages/gradio_client/client.py:1125, in EndpointV3Compatibility.make_end_to_end_fn.<locals>._inner(*data)
   1123 data = self.insert_state(*data)
   1124 if self.client.serialize:
-> 1125     data = self.serialize(*data)
   1126 predictions = _predict(*data)
   1127 predictions = self.process_predictions(*predictions)

File ~/anaconda3/envs/browsertesting/lib/python3.10/site-packages/gradio_client/client.py:1295, in EndpointV3Compatibility.serialize(self, *data)
   1293 data = list(data)
   1294 self._add_uploaded_files_to_data(uploaded_files, data)
-> 1295 o = tuple([s.serialize(d) for s, d in zip(self.serializers, data)])
   1296 return o

File ~/anaconda3/envs/browsertesting/lib/python3.10/site-packages/gradio_client/client.py:1295, in <listcomp>(.0)
   1293 data = list(data)
   1294 self._add_uploaded_files_to_data(uploaded_files, data)
-> 1295 o = tuple([s.serialize(d) for s, d in zip(self.serializers, data)])
   1296 return o

File ~/anaconda3/envs/browsertesting/lib/python3.10/site-packages/gradio_client/serializing.py:469, in JSONSerializable.serialize(self, x, load_dir, allow_links)
    467 if x is None or x == "":
    468     return None
--> 469 return utils.file_to_json(Path(load_dir) / x)

File ~/anaconda3/envs/browsertesting/lib/python3.10/site-packages/gradio_client/utils.py:615, in file_to_json(file_path)
    614 def file_to_json(file_path: str | Path) -> dict | list:
--> 615     with open(file_path) as f:
    616         return json.load(f)

FileNotFoundError: [Errno 2] No such file or directory: 'null'

Am I doing something wrong? Could you or someone help me get this right? Thanks in advance!!

Sign up or log in to comment