Laden Sie NDarray (Bild in OpenCV) als .JPG oder .png auf Google Cloud Storage hochPython

Python-Programme
Anonymous
 Laden Sie NDarray (Bild in OpenCV) als .JPG oder .png auf Google Cloud Storage hoch

Post by Anonymous »

Ich habe ähnliche Probleme wie das Hochladen eines Bytes -Images im Google Cloud -Speicher aus einem Python -Skript. < /p>

Ich habe diesen < /p>

ausprobiertfrom google.cloud import storage
import cv2
from tempfile import TemporaryFile
import google.auth
credentials, project = google.auth.default()
client = storage.Client()
# https://console.cloud.google.com/storage/browser/[bucket-id]/
bucket = client.get_bucket('document')
# Then do other things...
image=cv2.imread('/Users/santhoshdc/Documents/Realtest/15.jpg')
with TemporaryFile() as gcs_image:
image.tofile(gcs_image)
blob = bucket.get_blob(gcs_image)
print(blob.download_as_string())
blob.upload_from_string('New contents!')
blob2 = bucket.blob('document/operations/15.png')

blob2.upload_from_filename(filename='gcs_image')
< /code>

Dies ist der Fehler, der < /p>

aufpasst> Traceback (most recent call last): File
> "/Users/santhoshdc/Documents/ImageShapeSize/imageGcloudStorageUpload.py",
> line 13, in
> blob = bucket.get_blob(gcs_image) File "/Users/santhoshdc/.virtualenvs/test/lib/python3.6/site-packages/google/cloud/storage/bucket.py",
> line 388, in get_blob
> **kwargs) File "/Users/santhoshdc/.virtualenvs/test/lib/python3.6/site-packages/google/cloud/storage/blob.py",
> line 151, in __init__
> name = _bytes_to_unicode(name) File "/Users/santhoshdc/.virtualenvs/test/lib/python3.6/site-packages/google/cloud/_helpers.py",
> line 377, in _bytes_to_unicode
> raise ValueError('%r could not be converted to unicode' % (value,)) ValueError: could not be
> converted to unicode
< /code>

Kann mir jemand führen, was schief geht oder was ich falsch mache? < /p>

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post