Kartikeya
(Kartikeya Bhardwaj)
November 5, 2019, 7:01am
1
I successfully deployed my Image Classifier as a web-app on Render.
Right now ,I can only upload one image and get a prediction for that.
My project requires me to send a folder of multiple images (~100) to the web-app and get back the predictions.
How should I modify the POST request so that I can send multiple images for prediction at once ?
Should I expose my model as a REST-API instead of a web-app to make things simpler?
muellerzr
(Zachary Mueller)
November 5, 2019, 12:08pm
2
Here’s an example for downloading images from a user uploaded CSV document and then creates the request via a folder. You care about the second half
import csv
import StringIO
@app.route('/analyze', methods=['POST'])
async def analyze(request):
data = await request.form()
content = await (data['file'].read())
s = str(content, 'utf-8')
data = StringIO(s)
!mkdir('Downloaded_Images')
download_images(data, 'Downloaded_Images')
path2 = Path('Downloaded_Images')
data = ImageList.from_folder(path)
learn = load_learner(path, export_file_name, test=data)
y, _ = learn.get_preds(DatasetType.Test)
y = torch.argmax(y, dim=1)
preds = [learn.data.classes[int(x)] for x in y]
rm -r 'Downloaded_Images'
resultsFile = open('results.csv', 'wb')
wr = csv.writer(resultsFile)
wr.writerows([preds])
return FileResponse('results.csv')
2 Likes
Would you mind sharing the steps of how you did this? I have no idea about the process.
So far, I have opened an account on Render. What do I do next?
Hi dmitry2020 Hope all is well and you are having a splendid day.
Below are 2 links that will be very helpful in deploying your app on render.com
https://course.fast.ai/deployment_render.html
Hi everyone,
I’m the founder of Render , a new cloud provider that makes it trivial to deploy webapps in production. Some of you might know me from Crestle which I built back in 2017 (it is now owned and operated by doc.ai ).
I’ve created a guide for deploying fast.ai models on Render: https://course-v3.fast.ai/deployment_render.html
Render is still invite only, but I’d love for fast.ai users to be able to deploy their models on it just as easily as they train their models on Crestle. The guide…
The first link is the process to deploy on render.com
the second link is the thread for resolving issues when deploying.
Particularly look at posts with pip list This is essential in deploying your model successfully.
You can use the code in a previous post in this thread, to do inference on multiple files.
Hope this helps.
Cheers mrfabulous1