Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Light wrapper for Microsoft's Cognitive Services API to facilitate data gathering for machine learning.
This is a thin python wrapper for Microsoft's Microsoft Cognitive Services API focused on collecting image training data for use in machine learning. I have based this library off of another repoisitory created by tristantao called py-ms-cognitive.
This module requires that you sign up for Microsoft's Microsoft Cognitive Services and acquire an application key.
To install py-ms-cognitive-ml I recommend using virtualenv
.
pip3 install py-ms-cognitive-ml
sudo apt-get install python3-pip
pip install virtualenv
cd ~/Desktop/ && mkdir bing-api && cd bing-api && mkdir output
virtualenv -p python3 bing-api-env
pip3 install py-ms-cognitive-ml
Remember to set the API_KEY
as your own.
# Imports
import requests
import os
from py_ms_cognitive_ml import PyMsCognitiveImageSearch
# Settings
search_terms = ["keys", "cats", "dogs"]
serach_quota_per_term = 5
results = []
total_downloads = 0
if not os.path.exists("output"):
os.mkdir("output")
# Main
for search_term in search_terms:
# Make API call
search_service = PyMsCognitiveImageSearch('API_KEY', search_term)
result_list = search_service.search_all(quota=serach_quota_per_term)
# Scrape images
if not os.path.exists("output/" + str(search_term)):
os.mkdir("output/" + str(search_term))
print("\nDownloading images for term: '" + str(search_term) + "'")
i = 0
urls = []
for i in range(0, len(result_list)):
print ("Downloading image from " + str(result_list[i].name))
# Download the image
try:
if result_list[i].url not in urls:
image_file = requests.get(result_list[i].url, stream=True)
if image_file.status_code == 200:
with open("output/" + search_term + "/" + str(i) + "." + result_list[i].extension, 'wb') as f:
f.write(image_file.content)
urls.append(result_list[i].url)
else:
raise requests.exceptions.RequestException
else:
print("Image already downloaded. Skipping image.")
except requests.exceptions.RequestException:
print("Something went wrong with the request. Skipping image.")
i += 1
results.append(str(len(urls)) + " images downloaded for term '" + str(search_term) + "'.")
total_downloads += len(urls)
print("\n")
for result in results:
print(result)
print(str(total_downloads) + " images based on " + str(len(search_terms)) + " search term(s) downloaded.")
FAQs
Light wrapper for Microsoft's Cognitive Services API to facilitate data gathering for machine learning.
We found that py-ms-cognitive-ml demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.