GithubHelp home page GithubHelp logo

azure-samples / cognitive-services-rest-api-samples Goto Github PK

View Code? Open in Web Editor NEW
203.0 35.0 258.0 32.85 MB

This is a repo for cognitive services REST API samples in 4 languages: C#, Java, Node.js, and Python.

Home Page: https://azure.microsoft.com/en-us/services/cognitive-services/

License: Other

C# 31.46% JavaScript 9.79% Java 15.18% Python 2.26% HTML 34.29% Go 0.65% PHP 0.28% Ruby 1.21% CSS 0.39% Swift 4.40% Shell 0.11%

cognitive-services-rest-api-samples's Introduction

page_type languages products description urlFragment
sample
csharp
html
java
javascript
swift
python
azure
This repo provides code samples for cognitive services APIs.
cognitive-services-REST-api-samples

Samples for REST APIs in Cognitive Services

This repo provides code samples for Azure Cognitive Services APIs. There are sections for Language, Search, and Vision, using various progamming languages. Note that these are just simple wrappers to the APIs. For SDKs and SDK samples there are separate repos (see below for references).

Cognitive Services introduction: https://azure.microsoft.com/en-us/services/cognitive-services/

Cognitive Services docs: https://docs.microsoft.com/en-us/azure/cognitive-services/

Getting Started

These REST samples require some steps:

  1. Copy the sample into your favorite IDE or text editor.
  2. Get a subscription key and endpoint from your API service (for example, Computer Vision or Bing Search, etc.) If you have not created the Azure service you need, go here to get a free (or paid) account: https://azure.microsoft.com/en-us/free/?WT.mc_id=A261C142F
  3. Add your key and endpoint to your environment variables with the naming as shown in the code sample.
  4. Install libraries if needed (instructions on the ones needed are in the sample).
  5. Compile and run the sample through your IDE or the command line.
  6. (Optional) You may want to download the whole repo first:
    git clone https://github.com/Azure-Samples/cognitive-services-REST-api-samples

Resources

SDK Samples

Service-specific SDK Samples

cognitive-services-rest-api-samples's People

Contributors

aahill avatar anrothmsft avatar dargilco avatar diberry avatar erhopf avatar gowtham2712 avatar gowthu2712 avatar gracehao-pactera avatar harishkrishnav avatar laujan avatar lazerwalker avatar microsoftopensource avatar mikedodaro avatar msftgits avatar nitinme avatar nschonni avatar olduroja avatar patrickfarley avatar rlagh2 avatar ronak25 avatar v-jaswel avatar v-rajagt-zz avatar wiazur avatar xinyzhou avatar yibosun avatar yonet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cognitive-services-rest-api-samples's Issues

Required minimum Node.js bump for Azure SDK

Minimum Node.js version may be incorrect

This issue was created because the following file has been flagged with an out-of-date version number for Node.js: Tutorials/Bing-Web-Search/README.md

Required Fix: The Azure SDK now supports a minimum Node.js version of LTS (long term support).

Please fix this file to indicate LTS support and remove the specific version number it currently references found on line 18. If you find your code sample no longer works when moving up to the LTS version, please log an issue against the specific Azure SDK at https://github.com/azure/azure-sdk-for-js.

Required Exception If you can't change this file to support the minimum LTS of Node.js, please comment on this issue with the reason and details so we can refine our file search.

#DocIndexProject_nodejs


Document Details

Required minimum Node.js bump for Azure SDK

Minimum Node.js version may be incorrect

This issue was created because the following file has been flagged with an out-of-date version number for Node.js: Tutorials/Bing-Image-Search/README.md

Required Fix: The Azure SDK now supports a minimum Node.js version of LTS (long term support).

Please fix this file to indicate LTS support and remove the specific version number it currently references found on line 16. If you find your code sample no longer works when moving up to the LTS version, please log an issue against the specific Azure SDK at https://github.com/azure/azure-sdk-for-js.

Required Exception If you can't change this file to support the minimum LTS of Node.js, please comment on this issue with the reason and details so we can refine our file search.

#DocIndexProject_nodejs


Document Details

Incorrect endpoint in Bing Image Search Tutorial

This issue is for a: (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

The Bing Web Image Search Tutorial (Tutorials/Bing-Image-Search) doesn't get any image.

The endpoint in the public/js/script.js is not correct.

BING_ENDPOINT = "https://api.cognitive.microsoft.com/bing/v7.0/images/search";

Mention any other details that might be useful

The correct endpoint is:

BING_ENDPOINT = "https://api.bing.microsoft.com/v7.0/images/search";

Tags changed for description of a person laid on the floor. Description used to contain "lay" if image comprised a person on the floor. This is no longer the case.

This issue is for a: (mark with an x)

- [ ] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [x] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

Capture an image and submit to vision service to return tags. Tags do not contain a version of a word synonymous with "lay", "laid down", "fallen", etc.

Any log messages given by the failure

None

Expected/desired behavior

One of the tags should indicate the orientation or position of a person..."laying", "standing", "sitting", or similar

OS and Version?

Any Windows - mine is UWP

Versions

Current Cognitive services API

Mention any other details that might be useful

I first built a prototype in 2017, and tested the image description capabilities of Google and MS Cognitive services. For my use case MS was better, simply because both services would say they saw a person, but only Microsoft reported "lay" as in "laid down".

This was critical to my progressing discussion of using Cognitive Services to prototype home care devices.


Thanks! We'll be in touch soon.

SearchResults not found anywhere

On the introduction code, there is this line:

SearchResults results = new SearchResults(new HashMap<String, String>(), response);

I added all the imports, but this class does not exist. Using Java SE Dev Kit 8 update 191 64-bit.

Request to update guide on how to export/download Custom QA knowledge bases via REST API.

Please provide us with the following information:

This issue is for a: (mark with an x)

- [ ] bug report -> please search issues before submitting
- [ ] feature request
- [X] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

Please navigate to the following Custom QA REST API links.

When exporting Custom QA KB, the following APIs are issued.

  1. Custom QA Export API to export knowledge base
    https://learn.microsoft.com/en-us/rest/api/cognitiveservices/questionanswering/question-answering-projects/get-export-status?tabs=HTTP

  2. The above API returns a URL in the operation-location header. Then, this may be used as a parameter to issue the Custom QA Get Export Status API to get the resultURL for download.
    https://learn.microsoft.com/en-us/rest/api/cognitiveservices/questionanswering/question-answering-projects/get-export-status?tabs=HTTP

In the 2nd step, it mentions that the purpose of Get Export Status API is to _"get the status of an Export job, once job completes, returns the project metadata, and assets.", which may be confusing for the user as the 2nd step only returns a resultURL for download. Then, an additional API request needs to be issued by using the resultURL value and subscription key. The additional step cannot be used to download the file directly from a browse for example, but it requires a tool like Postman to Send and Download the result to file. Or, by clicking Send to send the request and Save Response when a valid response is received. Please see the sample image below.

image

Thank you and hope you may consider the above suggestions for future enhancements!

Any log messages given by the failure

Expected/desired behavior

OS and Version?

Windows 7, 8 or 10. Linux (which distribution). macOS (Yosemite? El Capitan? Sierra?)

Versions

Mention any other details that might be useful


Thanks! We'll be in touch soon.

Sending Batch request to azure cognitive API for TEXT-OCR

I am calling azure cognitive API for OCR text-recognization and I am passing 10-images at the same time simultaneously (as the code below only accepts one image at a time-- that is 10-independent requests in parallel) which is not efficient to me, from processing point of view, as I need to use extra modules i.e: Celery and multiprocessing.

So, is there a way to send all the 10-images in a single request and get the output at once then do post processing?

import time
from io import BytesIO

import cv2
import requests
from PIL import Image as PILImage
from PIL import Image
file_list = []

headers = {
    "Ocp-Apim-Subscription-Key": "<API-KEY>",
    'Content-Type': 'application/octet-stream'}

p = "symbol_sample.jpg"
print(p,"p")

def recognise_text(p):
    p = cv2.imread(p)
    cropped_image = PILImage.fromarray(p)
    buffer = BytesIO()
    cropped_image.save(buffer, format="JPEG")
    image_bytes = buffer.getvalue()
    try:
        response = requests.post(
            "https://centralindia.api.cognitive.microsoft.com/vision/v2.0/recognizeText?mode=Printed",
            headers=headers,
            data=image_bytes
        )
        header_link = str(response.headers['Operation-Location'])
        while (True):
            headers_get = {
                "Ocp-Apim-Subscription-Key": "<API-KEY>"",
                'Content-Type': 'application/json'
            }
            result = requests.get(
                url=header_link,
                headers=headers_get
            )
            response_r = result.json()
            if response_r["status"] == "Succeeded":
                return response_r
            else:
                time.sleep(4)
    except Exception as e:
        print(e)
        return ""
    
image1="symbol_sample.jpg"
o = recognise_text(image1)
print(o)

Any help would be really appreciated.

Output searchable PDF or hOCR

Please provide us with the following information:

This issue is for a: (mark with an x)

- [ ] bug report -> please search issues before submitting
- [x] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

microsoft Read API not providing hOCR output or searhable PDF.

Any log messages given by the failure

Expected/desired behavior

Output should be searchable PDF

OS and Version?

Windows 7, 8 or 10. Linux (which distribution). macOS (Yosemite? El Capitan? Sierra?)

Versions

v2.0,v 2.1

Mention any other details that might be useful


Thanks! We'll be in touch soon.

OCR API Send Bounding Box to Search?

Please provide us with the following information:

This issue is for a: (mark with an x)

- [ ] bug report -> please search issues before submitting
- [ ] feature request
- [ X] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Question

Is it possible to send the OCR API a specific bounding box area to analyze?

  • Example:
    • I have a huge image (4000px X 3000px) with text sprinkled throughout.
    • I'm only interested in text in a certain region (300px X 300px) in each image (think title block on large engineering document)
    • Is there a way to run OCR on ONLY a given bounding box area of each image?

Thank you

Speech Translation with REST API

Hello,
I am using speech to text batch transcription via REST API. Is there a possibility to set target language i.e. make translation together with transcription?

I am able to have it when use Speech SDK so wonder if it is possible to have the same functionality with REST API?

Thank you!

Getting error message "3001- Preprocessing failed" and additional "Unable to download blob"

Following the quickstart for Train a Form Recognizer model and extract form data by using the REST API with cURL (https://docs.microsoft.com/en-us/azure/cognitive-services/form-recognizer/quickstarts/curl-train-extract)

When I get to Train a Form Recognizer model and I call the API curl -i -X POST "https:///formrecognizer/v2.0-preview/custom/models" -H "Content-Type: application/json" -H "Ocp-Apim-Subscription-Key: " --data-ascii "{ "source": """"}"

I get a JSON response showing each of the files but they all return a message "unable to download blob"

See screenshot:

image

BingWebSearchv7.java API Error

HI,

I am running BingWebSearchv7.java as it is with my custom query and API key value.

I am getting the following error--

java.io.FileNotFoundException: https://api.bing.microsoft.com/bing/v7.0/search?q=site%3Alinkedin.com++%22Owner%22++%22Web+Hosting%22+
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)
at BingWebSearch.SearchWeb(BingWebSearch.java:88)
at BingWebSearch.main(BingWebSearch.java:44)

I have correctly specified the API key and request URL. However, the above error typically occurs for a File Not Found (404 or 410).

Please let me know what is wrong here?

The URL I am searching for is here--

"https://api.bing.microsoft.com/bing/v7.0/search?q=site%3Alinkedin.com++%22Owner%22++%22Web+Hosting%22+"

Yours sincerely,
Arvind.

python example is not working

Please provide us with the following information:

This issue is for a: (mark with an x)

- [ ] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

Any log messages given by the failure

else:
Error: unexpected 'else' in "else"

Expected/desired behavior

OS and Version?

win10

Train request- Error 1002

Hello everybody,

i recently got access to the Microsoft Form Recognizer Preview. After setting up a Form Recognizer Ressource and a Blob Storage Container, i put together a train request according to the Quickstart Documentation. Dispatching my request always leads me to the Error Code 1002 like this:

$ error":{"code":"1002","message":"Train request is either invalid or missing required parameters. Please reference the API reference and retry your request."}}

I already added 5 documents of the same type to my Blob Storage and followed the steps of the Quickstart guide very precisely. After i repeated this process for a few times and always obtained the same result, i dont know what to do.

I would be very glad if someone could help me with this issue. Thank you in advance.

Cheers
puN1ka

Error shown in Ink recogniser java app

Please provide us with the following information:

This issue is for a: (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

git cloned cognitive services-REST-api-samples and then navigated to the project java/inkRecognition/android-sample-app, Built successfully through android studio and connected an android phone and it runs successfully. Opened a recognizer app in the android device and after writing on it gave the below error.

Any log messages given by the failure

Code: JSON ErrorMessage: Exception Thrown During JSON Error Handling Target: JSONDetails

Expected/desired behavior

To show the recognized output.

OS and Version?

Windows 7, 8 or 10. Linux (which distribution). macOS (Yosemite? El Capitan? Sierra?)
MacOs(Sierra)

Versions

10.14.4

Mention any other details that might be useful

Android version 8.1.0


Thanks! We'll be in touch soon.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.