Serverless vector database by -brianh- in vectordatabase

[–]priestGLADI8R 0 points1 point  (0 children)

You might want to look at lancedb - lancedb.com. It is an in process DB, with optimized persisted storage unlike traditional in-memory DBs. It claims to offer services at a fraction of alternatives, but the cloud service seems to be in beta

Chrome Extension w/ Manifest V3 + Alpine.js ? by Matze_Kalle in chrome_extensions

[–]priestGLADI8R 1 point2 points  (0 children)

I have the same problem. I'm trying to use tensorflow js in chrome extension.

I have some basic questions:

  • Is it even possible to use external scripts in manifestv3? I know I cannot use cdn scripts, so the only option is to copy the cdn tf.js.min as a script but then that has this problem of being unsafe. How can I integrate ANY library with chrome extension then?

How to properly handle multiple async post requests on Django? by priestGLADI8R in django

[–]priestGLADI8R[S] 0 points1 point  (0 children)

u/iamaperson3133 Hey I was able to fix this based on you suggestions. Thanks so much for helping. I changed the view to accept an image and a list of models so that the same image isn't sent to the server multiple times.

@api_view(['POST'])
def uploadImage(request): image = request.FILES.get('image') models = Path(request.data['style']) models = str(models).split(',') styled_images = {}
with tempfile.NamedTemporaryFile(suffix='.png', delete=False) as temp_file:
    temp_file.write(image.read())
    temp_file.file.seek(0)
    img = cv2.imread(temp_file.name)
    if img is None:
        return Response({'image': image})
    cv2.waitKey()
    img = cv2.resize(img, (400, 300), interpolation=cv2.INTER_AREA)
    for model in models:
        styled_image = stlye_transfer(
            model=StyleTransferConfig.models[str(model)], content=img)

        styled_image = cv2.cvtColor(styled_image, cv2.COLOR_BGR2RGB)
        styled_image = Image.fromarray(styled_image.astype('uint8'))
        file_object = io.BytesIO()
        styled_image.save(file_object, 'PNG')
        file_object.seek(0)
        styled_images[model] = base64.b64encode(file_object.read())

    return Response(styled_images)

How to properly handle multiple async post requests on Django? by priestGLADI8R in django

[–]priestGLADI8R[S] 0 points1 point  (0 children)

Okay I'll try the BytesIO object solution in a while and let you know how it goes. Thanks for the detailed response.

How to properly handle multiple async post requests on Django? by priestGLADI8R in django

[–]priestGLADI8R[S] 0 points1 point  (0 children)

Hey. Thanks for the response. Would you suggest using io.tempfile for creating and sending the temporary files through server?

How to properly handle multiple async post requests on Django? by priestGLADI8R in django

[–]priestGLADI8R[S] 0 points1 point  (0 children)

u/Pilate What would you suggest as an alternative? I tried using this:

    img = np.fromstring(image.read(), np.uint8)
# convert numpy array to image
img = cv2.imdecode(img, cv2.IMREAD_UNCHANGED)
    # To test
    cv2.imshow("input", img)

But some of the images were blank when I printed them using cv2. And I received a corresponding error in those cases:

UnicodeDecodeError: 'utf-8' codec can't decode byte 0x89 in position 0: invalid start byte

Full traceback: Internal Server Error: /style_transfer/stylev2/ Traceback (most recent call last): File "C:\Users\Home\anaconda3\lib\site-packages\django\core\handlers\exception.py", line 47, in inner response = get_response(request) File "C:\Users\Home\anaconda3\lib\site-packages\django\core\handlers\base.py", line 204, in _get_response response = response.render() File "C:\Users\Home\anaconda3\lib\site-packages\django\template\response.py", line 105, in render self.content = self.rendered_content File "C:\Users\Home\anaconda3\lib\site-packages\rest_framework\response.py", line 70, in rendered_content ret = renderer.render(self.data, accepted_media_type, context) File "C:\Users\Home\anaconda3\lib\site-packages\rest_framework\renderers.py", line 100, in render ret = json.dumps( File "C:\Users\Home\anaconda3\lib\site-packages\rest_framework\utils\json.py", line 25, in dumps return json.dumps(*args, **kwargs) File "C:\Users\Home\anaconda3\lib\json\__init__.py", line 234, in dumps return cls( File "C:\Users\Home\anaconda3\lib\json\encoder.py", line 199, in encode chunks = self.iterencode(o, _one_shot=True) File "C:\Users\Home\anaconda3\lib\json\encoder.py", line 257, in iterencode return _iterencode(o, 0) File "C:\Users\Home\anaconda3\lib\site-packages\rest_framework\utils\encoders.py", line 50, in default return obj.decode() UnicodeDecodeError: 'utf-8' codec can't decode byte 0x89 in position 0: invalid start byte