Spaces:
Runtime error
Runtime error
JSONDecodeError
#1
by
LandonBayer
- opened
Hi haor,
I've been working on accessing this project via the Inference API through Hugging Face, which it seems to do fine. The issue comes in the decoding, where utf-8 decoding throws the error "UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte". I assume this is due in some way to the VAE encode/decode cycle, but I'm not sure what to do about it. Trying to force a string with str() also gives it a decode error. If you could tell me what I can do to fix this, please do. Thank you for your help!
Here is my code:
import json
import requests
API_URL = "https://api-inference.huggingface.co/models/haor/Evt_V2"
API_TOKEN = "realapitoken"
headers = {"Authorization": f"Bearer {API_TOKEN}"}
def query(payload):
data = json.dumps(payload)
response = requests.request("POST", API_URL, headers=headers, data=data)
return json.loads(response.content.decode("utf-8"))
dat = query("best quality, illustration,highly detailed,1girl,upper body,beautiful detailed eyes, medium_breasts, long hair,grey hair, grey eyes, curly hair, bangs,empty eyes,expressionless, ((masterpiece)),twintails,beautiful detailed sky, beautiful detailed water, cinematic lighting, dramatic angle,((back to the viewer)),(an extremely delicate and beautiful),school uniform,black ribbon,light smile")
print(dat)
And here is another version that does the same (it chooses utf-8 by default):
from huggingface_hub.inference_api import InferenceApi
API_TOKEN = "realapitoken"
inf = InferenceApi(repo_id="haor/Evt_V2", token=API_TOKEN)
inf(inputs="best quality, illustration,highly detailed,1girl,upper body,beautiful detailed eyes, medium_breasts, long hair,grey hair, grey eyes, curly hair, bangs,empty eyes,expressionless, ((masterpiece)),twintails,beautiful detailed sky, beautiful detailed water, cinematic lighting, dramatic angle,((back to the viewer)),(an extremely delicate and beautiful),school uniform,black ribbon,light smile")
Let me know what I can do to make it work or test to clarify better.
Thank you!