Closed PythonX-001 closed 9 months ago
Hey There! This is due to Craiyon enabling Cloudflare's "I am under attack" mode that verifies if the request is a genuine browser one. We did try to fix it in the latest update using cloudscraper (atleast for the synchronous calls)
Try running pip install -U craiyon.py
to update the wrapper to the latest version and try again.
Do let me know if it doesn't work. If it continues to behave this way, I might probably end up either using headless-selenium browser or PySide2's rich html browser widget to get a workaround this.
CC: #17
pip install -U craiyon.py
Unfortunately nothing has changed
Same
Also having these problems under 1.1.0
for both sync and async calls.
Yup, I'm still having this issue as of 2023/09/18. Not sure how to deal with it at the moment, tried just about everything I could think of. "requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)"
not working on Colab too
JSONDecodeError Traceback (most recent call last) /usr/local/lib/python3.10/dist-packages/requests/models.py in json(self, **kwargs) 973 # Catch JSON-related errors and raise as requests.JSONDecodeError 974 # This aliases json.JSONDecodeError and simplejson.JSONDecodeError --> 975 raise RequestsJSONDecodeError(e.msg, e.doc, e.pos) 976 977 @property
JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Thanks for the reminder. I'll try to find a workaround this and push the changes.
Refer to this comment regarding more details: https://github.com/FireHead90544/craiyon.py/issues/19#issuecomment-1906038250
TL;DR: Removed the cloudscraper dependency and switched to using headers. v3 works normally, v1 sometimes fails. If you're using the v3 model, it should it work now.
Make sure to update the wrapper by running: pip install -U craiyon.py
Reopen the issue if this issue still persists.
Just recently got the time to test it out again for myself. I ran 'pip install -U craiyon.py', so it's updated. Unfortunately, this still seems to be a problem. The error of 'json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)' still persists. I'm unable to get something as simple as the following to work:
from craiyon import Craiyon generator = Craiyon() result = generator.generate("Photorealistic image of shrek eating earth", negative_prompt="spoon", model_type="art") print(result.description) result.save_images()
This, of course, is just one of the examples given in the Craiyon API documentation on how to use it. Any fix would be appreciated!
Any updates?
generator = Craiyon() # Instantiates the api wrapper result = generator.generate("Photorealistic image of shrek eating earth")
print(result.images) # Prints a list of the Direct Image URLs hosted on https://img.craiyon.com
for url in result.images: print(url)
when i run the code i get this error ; Traceback (most recent call last): File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\models.py", line 971, in json return complexjson.loads(self.text, **kwargs) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\json__init__.py", line 346, in loads return _default_decoder.decode(s) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\json\decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "e:\FILES\Documents\Python projects\ELLIOT-BOT\gen 2\advanced_AI.py", line 153, in
result = generator.generate("Photorealistic image of shrek eating earth")
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\craiyon\craiyon.py", line 48, in generate
resp = resp.json()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\models.py", line 975, in json
raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
i dont know here is the prob here