Hi,
I am trying to build the Javascript interface for the Gradio project and I am having troubles finding the URL endpoint of the predict method.
This is what it looks like in the course:
And this is how it looks like in my project:
Thanks,
Cristina
2 Likes
ForBo7
(Salman Naqvi)
June 30, 2023, 7:16am
2
Reading from the docs , I think you can now only access the API through the Python or JS snippets shown in your screenshot.
However, try copying the format of the link in the course and see if it works.
https://hf.space/embed/crismun/first/+/api/predict
2 Likes
squid
(Suchit G)
July 1, 2023, 6:00pm
3
Hi, I too was unable to figure how to use the API. So, I ended up using HuggingFace embeds instead. Those turned out to be cooler and better!
1 Like
ForBo7
(Salman Naqvi)
July 2, 2023, 7:51am
4
They’re also handy if one doesn’t know JavaScript!
1 Like
The API endpoint is the client url plus /run/predict
, I sucessfully hit your endpoint with:
base64_image=$(base64 /tmp/dog.jpg)
curl -X POST -H "Content-Type: application/json" -d '{"data": ["'"$base64_image"'"]}' https://crism
un-first.hf.space/run/predict
which returned:
{"data":[{"label":"Dog","confidences":[{"label":"Dog","confidence":0.9844999313354492},{"label":"Cat","confidence":0.015500036999583244}]}],"is_generating":false,"duration":0.6749627590179443,"average_duration":0.6749627590179443}
Embedding is pretty cool as well, here’s an example: 02: Production | fast.ai course
3 Likes
Hi,
That looks cool. Can you point to a tutorial on how to create HuggingFace embeds?
Thanks