jhoballah / Melanoma_JSY

BME 590 Final Project: Classification of skin lesions.
MIT License
2 stars 2 forks source link

Python-tk installation (matplotlib) #26

Closed ss842 closed 6 years ago

ss842 commented 6 years ago

image

i think the error is with the image we are trying to send through get_prediction

ss842 commented 6 years ago

@suyashkumar do you have any thoughts on this error? yasha is sending a decoded string through postman and my code is image_test_flask.py on branch imgproc. we tried an image from the melanoma database and ISIC_0011285.jpg from your repo, same error on both.

mlp6 commented 6 years ago

It looks like you are using your system-wide python 2.7 install (note that the errors are being thrown by /usr/local/lib/python2.7/; is that your intention?

suyashkumar commented 6 years ago

Is this running within a Docker container?

Looking at this line it appears that you're passing in the base64 string directly to Image.Open but it looks like it takes a filename? Try printing out image to the console to see what it actually is...

I would try to simply save the image to disk, as was done in the class base64 encode decode example. Lemme post the code here:

import base64

def encode_image_string(filename):
    with open(filename, "rb") as image_file:
        image_string = base64.b64encode(image_file.read())
        return image_string

def save_image_string(base64image, filename):
    with open(filename, "wb") as image_out:
        image_out.write(base64.b64decode(base64image))

if __name__ == '__main__':
    encoded_image = encode_image_string("pup.jpg")
    print(encoded_image)
    save_image_string(encoded_image, "pupper_new.jpg")

So what you could do to get MVP working is the following (not the cleanest, but the best place to start to get things working):

  1. Decode the base64 string into bytes.
  2. Save those bytes to temp.jpg on disk as seen above in save_image_string
  3. Read in temp.jpg using matplotlib.image's imread command, which will give you the correct numpy.ndarray to pass into get_prediction
ss842 commented 6 years ago

@suyashkumar currently having issues with python-tk not being installed and an error in line 6 of test_send.py where i try to import matplotlib as plot. i tried a variety of things such as sudo apt-get python3-tk in my vcm, adding python-tk, TkInter to requirements.txt, etc but didn't help

see commit 58725edac3422d4c14dcb2be31e98dbf8f81c82b for latest files

image

ss842 commented 6 years ago

i know @mlp6 commented on the python 2.7 which may be part of the problem here

image

it's going to /usr/lib/python2.7/ even though i have 3.6.3 installed in /home/vcm/miniconda/bin/python

ss842 commented 6 years ago

i also just "python -mpip install -U matplotlib" on my vm to directly download matplotlib, but am getting the same import error from /usr/lib/python2.7/lib-tk/Tkinter.py - we believe the error can be fixed if we can get the right path... any thoughts?

ss842 commented 6 years ago

update: we've resolved the issue of the python version by editing the base image in the dockerfile to python 3, but this did not resolve the import error itself

suyashkumar commented 6 years ago

Hey @ss842 did this get resolved? Just checking up!

ss842 commented 6 years ago

hi @suyashkumar it's not resolved yet but we aren't using matplotlib anymore so it hasn't been an obstacle