Best way to transform Jupyter notebook code in a web app - python-3.x

Suppose, I have a Jupyter notebook that contains the code of Image Captioning. Let's say this is our example notebook. This is a simple machine learning model where the workflow is like loading the data, training the model, and using the model to predict the caption for any image.
What I want to learn is how to make a simple publicly available web app (like this) where the users can just upload their image or provide a link to their image and get the required captions as output.

You can try to use Mercury. It tranforms Jupyter notebooks into web app by adding YAML header in the first raw cell in the notebook. You can easily define an image upload as input. Example YAML config:
title: App title
description: App description
params:
my_image:
input: file
label: Please upload image
maxFileSize: 1MB
In the next cell you need to define variable with file name
my_image = "my_image.png"
In the rest cells you should have your notebooks cells.

Related

Azure Search - Highlights - Locating in image

Just looking for guidance or even a general outline on approach here.
I am using azure search to OCR a batch of pdfs. I have turned on hit highlighting and I am successfully getting results back there that I am looping through / displaying in my view for the end user. I was looking on expanding that functionality to show the pdf images with the highlighting on the images themselves like in the JFK azure example. I am not proficient in react and seem to be getting lost there.
I am assuming I need to save off the OCR images to a data store for reference using the normalized_images that are created? I do have pdfs locally I can load but assume the OCR images maybe different. Have turned on GeneratedNormalizedImagesPerPage and turned on cache which creates files in my storage account.
Then I assume I need to pull the associated image, display it, use the highlight results and pull a corresponding bounding box where the phrase was detected? Problem with that approach is that I do not see any association between the highlight hit and the location (bounding box) of the hit nor the associated image file the hit was on.
Probably way off on approach here but any guidance is appreciated.
Edit 1
I did noticed the items on this page in the JFK example: https://github.com/microsoft/AzureSearch_JFK_Files/tree/master/JfkWebApiSkills/JfkWebApiSkills
Would trying to replicate the ImageStore (so those are stored in my storage account) and then the HocrGenerator (appears to handle points in a doc) into my skillset for my index be the approach?
There are a few steps here:
you need to save the layoutText from the OCR skill somewhere the UI can access it. The JFK Files demo converts it to a HOCR (to display in the UI) and saves it in index as a field in the index so that it is retrieved in the search results. HOCR isn't necessary and you may find it more efficient to store the layout in blobs using a knowlege store object projection.
save the extracted images into blob storage using a file projection into the knowledge store. Keep in mind that the images may be resized in the process and the coordinates will match the resized image saved to the store. If you want to map the coordinates to the original image see this.
At search time, map the highlight to the the metadata. You will find this code in the nodejs frontend, however it may be simpler to follow in the original demo by following the code here. Essentially you just find the first occurrence of the highlighted word in the metadata, display the associated image, and calculate the bounding region of the word.

AWS Textract can not recognize the table of the second page of PDF document

I need to extract table information from a billing copy using AWS Textract. It gives me almost perfect results every time but for some PDF document, it does not give me the table results of the second page.
code examples used: AWS Official Documentation
image(JPEG) of first page is
image(JPEG) of second page is
So, AWS gives me the first 20 entries output as CSV. But for the second page of the image the result of CSV is:
and most importantly, I found the same results in a similar type of PDFs which has 21 entries and one entry exists on the second page of PDF. I have already used PyPDF2 to merge pdf pages into one page but doesn't solve my problem. Is there any OpenCV tools do I need to use?
Please suggest to me any possible suggestions for these types of issues.

Python Flask image manipulation librery

I google it, but the number of library are overwhelming,
I'm looking for a image manipulation library, written in Python that I can implement in Flask;
I need to solve this simple sets of operations:
Upload the image.
Resize / scale the image (maintained the proportions).
Save the new image in a specific path with a specific name.
Remove the original image.
Also I notice that many promising project are unchanged in the last 2 years....

Updating lines in Excel when changes to S3 occur

In a project I am running an AWS Sagemaker Jupyter notebook instance that heavily interacts with files (gathering, converting, computing, interacting) and after every step the files are moved from folder to folder to prepare for the next interaction. I was wondering if there was any way to set some form of chart (like excel) that creates/updates a row when a file enters a folder. The charts end goal is to be used as some form of tracker, to see what stage all the different files are in.
Examples of how the desired chart should look like below
Chart Style 1
Chart Style 2
One way in which you could achieve this is by pushing the data programmatically to a central Google Spreadsheet and use the data from there to create charts.
You could use the GSpread Library in Python to push the data after certain steps in your code are run successfully. We use this extensively to push data to Google Sheets every day.
You would need to check the API rate limits enforced by Google Cloud which can be increased as per your requirements.

How to export Azure Machine Learning output to CSV

I have created an Azure ML experiment which will give the output as predicted probability values and some charts such as bar chart, pie chart, etc. Now I am able to see the outputs in Azure ML's output page.
How can I export my Azure ML experiment results to CSV (or any other similar format)?
You can just configure that by using the modules under Data Format Conversions. Have a look here and here. Documentation is in progress, unluckily.
Once you've trained your model, publish it as a web service. Then from published service, you can Download Excel Workbook. Through this workbook, it will run your web service with the data you input into excel. Then it will show the predicted values.
You can add a module called convert to csv in your experiment.
The Run selected module.
Right click after the module is run and click on 'Download'

Resources