MCPcopy Index your code
hub / github.com/TensorPy/TensorPy / classify_image_url

Function classify_image_url

tensorpy/image_base.py:86–101  ·  view source on GitHub ↗

Classify an image from a URL.

(image_url)

Source from the content-addressed store, hash-verified

84
85
86def classify_image_url(image_url):
87 """ Classify an image from a URL. """
88 downloads_folder = settings.DOWNLOADS_FOLDER
89 hex_name = 'temp_image_%s' % uuid.uuid4().hex
90 hex_name_png = hex_name + '.png'
91 hex_name_jpg = hex_name + '.jpg'
92 web_core.save_file_as(image_url, hex_name_png)
93 convert_image_file_to_jpg(
94 "%s/%s" % (downloads_folder, hex_name_png))
95 os.rename(downloads_folder + "/" + hex_name_png,
96 downloads_folder + "/temp_image_png.png")
97 best_guess = classify_image.external_run(
98 "%s/%s" % (downloads_folder, hex_name_jpg))
99 os.rename(downloads_folder + "/" + hex_name_jpg,
100 downloads_folder + "/temp_image_jpg.jpg")
101 return best_guess.strip()
102
103
104def get_image_classification(image_url):

Callers 2

get_image_classificationFunction · 0.85
classifyFunction · 0.85

Calls 1

Tested by

no test coverage detected