This how-to-guide shows you how to easily detect logos in an image with Clarifai's Logo Detector. The Logo Detector is useful any time you need spot and categorize logos in an image. Detecting product logos within images and videos is one of the most popular uses of computer vision AI, as brands look for better ways to protect their identity, monitor usage trends and provide targeted communications to their consumers.
Getting Started
First things first. You will need to set up a Clarifai account and create an application. This how-to article shows you how to detect logos with Clarifai API and through Portal. If you would like to detect logos via API, you will also need to generate an API key.
Detecting people with Clarifai Portal
You can do almost anything that Clarifai can do with Clarifai Portal, and we work hard to make Portal the world's easiest interface for using AI. Detecting logos with Portal is as simple as uploading your data, and setting up the right workflow.
Create your application and choose your base workflow
Simply log in to Clarifai Portal and create a new application. Select "General Detection" as your base workflow.
Navigate to Model Mode and create a new workflow
Next, we will want to create a new workflow that uses the logo model. Just navigate to Model Mode on the right hand sidebar and click "Create New Workflow" in the upper righthand corner of the screen.
Add the logo "visual detector" to your workflow
Now we will add just one model to the work flow: the people "visual detector". Be sure to select "clarifai" as the user in the lefthand dropdown menu. You can then filter your results by model type. Select "visual detector". Click "ADD" to add the model to your workflow, and then click "CREATE WORKFLOW"
Select your new "logo" workflow as the app workflow
Now navigate to view your image in Explorer. In the righthand sidebar you can click the "APP WORKFLOW" tab, and click the gear icon. Finally select your new workflow, and view your predictions.
Identify people in images hosted on the web via API
Here is an example of how to run a prediction on an image that is hosted on a URL. This snippet is in Python, but we offer support for many other client languages. Please refer to our API documentation for additional information.
First Create Your New Logo Workflow
from clarifai_grpc.grpc.api import service_pb2, resources_pb2 from clarifai_grpc.grpc.api.status import status_code_pb2 # This is how you authenticate. metadata = (('authorization', 'Key {{YOUR_CLARIFAI_API_KEY}}'),) post_workflows_response = stub.PostWorkflows( service_pb2.PostWorkflowsRequest( workflows=[ resources_pb2.Workflow( id="my-logo-workflow", nodes=[ resources_pb2.WorkflowNode( id="logo", model=resources_pb2.Model( id="006764f775d210080d295e6ea1445f93", model_version=resources_pb2.ModelVersion( id="09f3acb13bde404592c81254c5d87ae1" ) ) ), ] ) ] ), metadata=metadata ) if post_workflows_response.status.code != status_code_pb2.SUCCESS: raise Exception("Post workflows failed, status: " + post_workflows_response.status.description)
Now Use Your Workflow to Make Predictions on Images
from clarifai_grpc.grpc.api import service_pb2, resources_pb2 from clarifai_grpc.grpc.api.status import status_code_pb2 # This is how you authenticate. metadata = (('authorization', 'Key {{YOUR_CLARIFAI_API_KEY}}'),) post_workflow_results_response = stub.PostWorkflowResults( service_pb2.PostWorkflowResultsRequest( workflow_id="my-logo-workflow", inputs=[ resources_pb2.Input( data=resources_pb2.Data( image=resources_pb2.Image( url="https://samples.clarifai.com/metro-north.jpg" ) ) ) ] ), metadata=metadata ) if post_workflow_results_response.status.code != status_code_pb2.SUCCESS: raise Exception("Post workflow results failed, status: " + post_workflow_results_response.status.description) # We'll get one WorkflowResult for each input we used above. Because of one input, we have here # one WorkflowResult. results = post_workflow_results_response.results[0] # Each model we have in the workflow will produce one output. for output in results.outputs: model = output.model print("Predicted concepts for the model `%s`" % model.name) for concept in output.data.concepts: print("\t%s %.2f" % (concept.name, concept.value))