R15 error while deploying on heroku

While deploying my app on heroku it’s giving me a R15 error. I am trying to deploy multiple recommendation system in one web app…

[from bokeh.models.widgets import Div

import streamlit as st

import pickle

import pandas as pd

import numpy as np

import requests

import json

import books_api

def app():

st.title('Book recommender')

df=pd.read_csv('apps/df.csv')

df1=pd.read_csv('apps/data.csv',error_bad_lines = False,warn_bad_lines=False)

title = df1['title'].drop_duplicates()

auth=df1['authors'].drop_duplicates()

with open('model.pkl','rb') as f:

    model=pickle.loads(f.read())



model.fit(df)

dist, idlist = model.kneighbors(df)

def book_covers(name):

    cover=[]

    try:

        book_id = df1[df1['title'] == name].index

        book_id = book_id[0]

    except IndexError:

        pass

    for newid in idlist[book_id]:

        cover.append(df1.loc[newid].isbn)

    return cover



def auth_covers(name):

    auth_list = []

    auth_id = df1[df1['authors'] == name].index

    auth_id = auth_id[0]

           

    for newauthid in idlist[auth_id]:

        auth_list.append(df1.loc[newauthid].isbn)

    return auth_list



def Recommender(name):

        book_list = []

        try:

            book_id = df1[df1['title'] == name].index

            book_id = book_id[0]

        except IndexError:

            pass

        for newid in idlist[book_id]:

            book_list.append(df1.loc[newid].title)

        return book_list



def author(auth_name):

        auth_list = []

        auth_id = df1[df1['authors'] == auth_name].index

        auth_id = auth_id[0]

           

        for newauthid in idlist[auth_id]:

            auth_list.append(df1.loc[newauthid].authors)

        return auth_list

def author_book(auth_name):

    books=[]

    auth_id = df1[df1['authors'] == auth_name].index

    auth_id = auth_id[0]

    for newauthid in idlist[auth_id]:

        books.append(df1.loc[newauthid].title)

    return books

def details(isbn):

    try:

        api = books_api.Api()

        json_data = api.list(f'isbn:{isbn}')

        data =json_data['items'][0]

        return (data['volumeInfo']['previewLink'])

    except KeyError:

        pass

side=st.radio("systems",["Book Recommendation","Author recommendation"])

if side=="Book Recommendation":

    book_input=st.selectbox('Enter the book name:',title)

    output1=Recommender(book_input)

    if st.button('Show Recommendation'):

        st.write(f"The Recommended Books for **{book_input}**: ")

        for i in range(1,len(output1)):

            st.write(f'{i}) {output1[i]}')

            isbn=book_covers(book_input)

            url="http://covers.openlibrary.org/b/isbn/{}-L.jpg".format(isbn[i])

            st.image(url)

            link = f'[More Info]({details(isbn[i])})'

            st.markdown(link, unsafe_allow_html=True)

                               

if side=="Author recommendation":

    author_input=st.selectbox("Enter the author's name:",auth)

    output2=author(author_input)

    output3=author_book(author_input)

    if st.button('Show Recommendation'):

        st.write(f"The Recommended authors for **{author_input}**:")

        for j in range(1,len(output2)):

            st.write(f'''{j})Author: {output2[j]}      

                 Book recommended for the author: {output3[j]}''')

            isbn1=auth_covers(author_input)

            url="http://covers.openlibrary.org/b/isbn/{}-L.jpg".format(isbn1[j])

            st.image(url)

            link = f'[More Info]({details(isbn1[j])})'

            st.markdown(link, unsafe_allow_html=True)](https://code) 

I am guessing there is some memory leak issue here

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.