{"id":21930744,"url":"https://github.com/previsionio/calling-image-model","last_synced_at":"2026-05-04T19:38:13.289Z","repository":{"id":86604779,"uuid":"423794682","full_name":"previsionio/calling-image-model","owner":"previsionio","description":null,"archived":false,"fork":false,"pushed_at":"2021-11-02T11:12:19.000Z","size":25,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-22T12:48:53.360Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/previsionio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-11-02T10:14:31.000Z","updated_at":"2021-11-02T11:12:21.000Z","dependencies_parsed_at":null,"dependency_job_id":"7d81e032-e468-4699-a679-277366646a4b","html_url":"https://github.com/previsionio/calling-image-model","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/previsionio/calling-image-model","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/previsionio%2Fcalling-image-model","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/previsionio%2Fcalling-image-model/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/previsionio%2Fcalling-image-model/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/previsionio%2Fcalling-image-model/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/previsionio","download_url":"https://codeload.github.com/previsionio/calling-image-model/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/previsionio%2Fcalling-image-model/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32622681,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-04T10:08:07.713Z","status":"ssl_error","status_checked_at":"2026-05-04T10:08:02.005Z","response_time":58,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-28T23:11:17.395Z","updated_at":"2026-05-04T19:38:13.275Z","avatar_url":"https://github.com/previsionio.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Image model Calling\n\nThis repo is a boilerplate to call an object detector model host on [PrevisionIO platform](https://cloud.prevision.io).\n\nYou can [train your own model](https://doc.prevision.io/en/latest/studio/experiments/automl/images.html) or use  an [already deployed one](https://doc.prevision.io/en/latest/studio/deployments/index.html#inspect-and-monitor-a-deployed-experiment)\n\n## SETUP\n\n``` \ngit clone git@github.com:previsionio/calling-image-model.git\npython -m venv env\nsource env/bin/activate\npip install -r requirements.txt \n```\n\nIn order to call the model you need your model url, secret ID and access Key. They all can be found on the [deployment page of the model](https://doc.prevision.io/en/latest/studio/deployments/index.html#inspect-and-monitor-a-deployed-experiment).\n\nFill a .env file with your credentials ( used the provided .env.example) or put them in env var.\n\n```\nclient_id=\u003cYOUR_ID\u003e\nclient_secret=\u003cYOUR_SECRET\u003e\nmodel_url=\u003cYOUR_URL\u003e\n```  \n\n\n## Using the service\n\n\n```python\nimport model\ntestimg=open('banana_for_test.jpeg', 'rb')\npred = model.send(testimg)\nprint(pred)\n``` \n\n## Authorization flow\n\nWe use the OAuth2 Authorization flow which means :\n\n- you must first get an acess token from the Auth Server `https://accounts.prevision.io/auth/realms/prevision.io/protocol/openid-connect/token` \n- then put it in your API call header `Authorization`field  with a `Bearer`  :\n\n```\nAuthorization: Bearer \u003cACCESS_TOKEN\u003e\n``` \n\nSee [this explanation](https://stackoverflow.com/questions/11068892/oauth-2-0-authorization-header)\n\n## Exposte a flask API to your service\n\nA WSGI server is provided that you can launch with gunicorn :\n\n\n```\ngunicorn --bind 0.0.0.0:8080  --timeout 120  --limit-request-line 0   --access-logfile - run:app\n```\n\nThe service exposes two API you can test with whatever client you want :\n\n\n```sh\ncurl --location --request GET 'http://localhost:8080/api/mymodel/health'\n\n\u003e {\"msg\":\"I'm OK\"}\n\ncurl --location --request POST 'http://localhost:8080/api/mymodel/prediction' --form 'img=@\"./banana_for_test.jpeg\"'\n\n\u003e {\"infos\":26497,\"predictions\":[{\"detection_box\":[0.07150368033648791,0.25276153346328784,0.8937960042060988,0.4093567251461988],\"label\":\"pots\",\n\u003e \"probability\":0.0021450864151120186},{\"detection_box\":[0.3280757097791798,0.7875243664717348,0.9400630914826499,0.9928525016244314],\n\u003e \"label\":\"cartons\",\"probability\":0.002546289237216115}],\"source\":\"banana_for_test.jpeg\"}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprevisionio%2Fcalling-image-model","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprevisionio%2Fcalling-image-model","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprevisionio%2Fcalling-image-model/lists"}