App deployment : Zeit stuck on "analyzing"

Hi !

I used the following to deploy a dogs vs cats classifier.
For some reason, the classifier is stuck on “analyzing”.

Here is my code :

from starlette.applications import Starlette
from starlette.responses import HTMLResponse, JSONResponse
from starlette.staticfiles import StaticFiles
from starlette.middleware.cors import CORSMiddleware
import uvicorn, aiohttp, asyncio
from io import BytesIO

from fastai import *
from import *

learner_file_url = ‘
learner_file_name = ‘export’
classes = [‘cat’, ‘dog’]
path = Path(file).parent

app = Starlette()
app.add_middleware(CORSMiddleware, allow_origins=[’*’], allow_headers=[‘X-Requested-With’, ‘Content-Type’])
app.mount(’/static’, StaticFiles(directory=‘app/static’))

async def download_file(url, dest):
if dest.exists(): return
async with aiohttp.ClientSession() as session:
async with session.get(url) as response:
data = await
with open(dest, ‘wb’) as f: f.write(data)

async def setup_learner():
await download_file(learner_file_url, path/f’{learner_file_name}.pkl’)
return load_learner(path)

loop = asyncio.get_event_loop()
tasks = [asyncio.ensure_future(setup_learner())]
learn = loop.run_until_complete(asyncio.gather(*tasks))[0]

def index(request):
html = path/‘view’/‘index.html’
return HTMLResponse(

@app.route(’/analyze’, methods=[‘POST’])
async def analyze(request):
data = await request.form()
img_bytes = await (data[‘file’].read())
img = open_image(BytesIO(img_bytes))
return JSONResponse({‘result’: str(learn.predict(img)[0])})

if name == ‘main’:
if ‘serve’ in sys.argv:, host=‘’, port=5042)

you’ll find the app here :
and the model here :

I just have no clue what I did wrong. Can anybody help me out with that ?

edit : @arunoda ? I just saw you told people they could ping you ^^

1 Like

Zeit was removed from the list of services because it no longer works I think. You should try one of the 3 ways still listed. My recommendation is to go with Render at first, it’s really easy.


Hi !

thanks for your feedback ! I think in this case this page shouldn’t exist anymore :

it makes it look official, like a service FASTAI recommends. What do you think ?

The page about Zeit is no longer in the menu of the website. I think the page is still there because it was easier to remove it from the menu and assume people wouldn’t find it without a direct link like you.

this page is still active. The steps mentioned on that page are not working though. @jeremy

Hi, these steps won’t work anymore. The page still exists, but as PierreO mentionned it has been removed from the website’s menu, AND now it is also removed from the enriched videos. So nobody should end up on this page, except somebody who peruse the forums. But then they’ll find our posts and realize it’s not working :wink:

Hi @bdubreu
Were you able to solve your problem of your app being stuck at “analyzing”? I am using GCP and my app is stuck at analyzing.
Have no idea about what could be the problem.


Have you dealt with it? I have same problem. Don’t know what to do

1 Like

Hi @DDB89,
The problem is in file.
change “return JSONResponse({‘result’: learn.predict(img)[0]})”
to " return JSONResponse({‘result’: str(learn.predict(img)[0])})".
It worked in my case and app ran.
Hope this helps!

1 Like

Can you send whole this block from async def analyze. This didn’t help, unfortunatelly.

It was needed to change the pytorch version in requirements.txt from 1.0.1 to 1.1.0.
Everything worked!

Great job. Couldn’t resolve the issue so I moved to “render”, but three months later they started to ask me for money ^^

That’s great to hear. Did you performed both the changes the one I suggested in and updating pytorch version in requirements.txt or just updated the pytorch version?

I already had the string you wrote in, so the problem was in Pytorch version.

For me I noticed If the image is over 200kb, it gets stuck on analysing.