1

I am currently working on an AI webpage that enables users to upload datasets and do all kinds of stuff with that data in the cloud. I am using a react frontend with a django backend linked to a PostgreSQL and a blob storage on Azure.

Now my question is:

What is the common way to efficiently get the images as arrays from the blob storage into my django backend to run further python scripts (like augmentation) on them, while using my database models (so not by directly connecting to the blob storage)?

This line of code works to retrieve the images from blob using the url that was saved in my database and perform a simple rotation. But the "request.urlopen" takes very very long. There must be a better way...

class Image(models.Model):
    name = models.CharField(default='', max_length=100)
    image = models.FileField(upload_to='data', default='')
    dataset = models.ForeignKey(Dataset, on_delete=models.CASCADE)

img = Image.objects.filter(dataset=somedataset, user=someuser)
im = np.rot90(np.asarray(Image.open(BytesIO(request.urlopen(img['image']).read()))))
emilector
  • 35
  • 1
  • 8
  • You can refer https://stackoverflow.com/questions/56769671/how-to-download-an-azure-blob-storage-file-via-url-in-python, https://stackoverflow.com/questions/55170572/use-python-to-process-images-in-azure-blob-storage, https://www.toptal.com/python/beginners-guide-to-concurrency-and-parallelism-in-python – Madhuraj Vadde Mar 14 '22 at 07:18

0 Answers0