I am trying to read a saved model, such that it (the saved model) can complete a sequence, given the first few codons of a sequence (that are uploaded into the file_uploader)
The Code:
import streamlit as st
import tensorflow as tf
import tensorflow_io as tfio
import numpy as n
from Bio import SeqIO
def main():
st.title('Covid-19 Mutation Forecasting App')
menu = ['Forecast Mutation', 'About The App']
choice = st.sidebar.selectbox('Select Activity', menu)
if choice == 'Forecast Mutation':
st.subheader('Mutation Forecasting Workspace')
uploaded_file = st.file_uploader('Upload a Sequence File:')
if uploaded_file is not None:
# To read file as bytes:
protein_sequence = uploaded_file.getvalue()
st.write('The File...', uploaded_file.name, '...Successfully Uploaded!')
st.write(protein_sequence)
next_step = st.checkbox('Forecast')
if next_step:
protein_sample = protein_sequence[0].seq
model = tf.saved_model.load('next_sequence_generator')
states = None
next_char = tf.constant([str(protein_sample)])
result = [next_char]
for n in range(1273):
next_char, states = model.generate_one_step(next_char, states=states)
result.append(next_char)
generated_sequence = tf.strings.join(result)[0].numpy().decode("utf-8")
else:
st.subheader('About This App')
st.caption('Given the first few codons of a SARS-CoV-2 Spike Protein, '
'the App predicts and display the complete sequence of the mutant')
if __name__ == '__main__':
main()
Traceback:
File "C:\Users\Sir Roberto\AppData\Local\Programs\Python\Python310\lib\site-packages\streamlit\scriptrunner\script_runner.py", line 475, in _run_script
exec(code, module.__dict__)
File "C:\Users\Sir Roberto\PycharmProjects\SARS_CoV_2_Mutation_Forecasting_GUI\SARS_CoV_2_Mutation_Forecasting_GUI.py", line 51, in <module>
main()
File "C:\Users\Sir Roberto\PycharmProjects\SARS_CoV_2_Mutation_Forecasting_GUI\SARS_CoV_2_Mutation_Forecasting_GUI.py", line 29, in main
protein_sample = protein_sequence[0].seq
I think you may be under a wrong impression that we are here to troubleshoot all your app problems. Your membership is not even a day old, and already you asked several questions that are all of the same variety - something is wrong either with your script syntax, but error messages are always clear if you invest a bit of time to figure out where they are and what they mean.