Published unlisted
Edited
Aug 24, 2022
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
img = FileAttachment("ocr_test_index.jpg").image()
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
mutable result = null
Insert cell
result.data[0]
Insert cell
author = "nielsr"
Insert cell
model = "TrOCR-handwritten"
Insert cell
requestExample = fetch('https://hf.space/embed/'+author+'/'+model+'/+/api/predict/', {
// should cascade, testing
// if available locally first e.g http://localhost/ , e.g curl localhost:9000/generate/?content=penguins%20on%20pirate%20boat
// if not own server e.g https://fabien.benetou.fr/webml/ ,
// if not HF
// ideally testing wouldn't involve timeouts but rather service/model cached discovery via e.g a (cached) JSON endpoint
// ideally if not available locally but privacy constraints demand it, see if fetchable via e.g cog
method: "POST",
body: JSON.stringify( {"data":[ dataImageFromAPI ]}),
headers: { "Content-Type": "application/json" }
}).then(function(response) { return response.json(); }).then(function(json_response){
mutable result = json_response
})
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more