Topic Thread

  • 1.  image upload

    Posted Tue September 10, 2019 08:34 AM
    Edited by Hafsah Lakhany Tue September 10, 2019 12:59 PM
    While trying to get output as a image in jupyter notebook , i can't see the image . i have drag -dropped the image in upload area  and use html<imgsrc > tag .
    Is there any other place to upload the image ??

    #jupyter-notebook #WatsonStudio

    Pranav Dwivedi

  • 2.  RE: image upload

    Posted Tue September 10, 2019 09:01 AM
    Edited by Sumit Goyal Tue September 10, 2019 09:01 AM
    Hello Pranav,

    Are you uploading an image from your local system to Watson Studio on Cloud and want to use that in a Jupyter Notebook? If yes, the below code snippet will help you do that.

    The files uploaded to Watson Studio from the drag and drop action are uploaded to the Cloud Object Storage bucket associated with the Project. The uploaded file then has to be made available to the Jupyter runtime. After uploading the image to the COS bucket, you should see it under the files tab on the sidebar. Select the `Insert StreamingBody Object`.

    The inserted code snippet will read your image in a Python StreamingBody object then you can write it to a file in the local runtime filesystem using the code snippet below.

    f = open('My_Image.png', 'wb')

    You can insert the image in your Jupyter notebook using the following code snippet.

    from IPython.display import Image
    from IPython.core.display import HTML 
    Image("My_Image.png", width=300, height=500)

    Note: The above code snippet is written in Python. This will need to be adjusted for other languages. Also, this stack overflow answer gives more details on the topic:

    Sumit Goyal